Documentos de Académico
Documentos de Profesional
Documentos de Cultura
RHCSA-1
OS
UNIX
It is a complete operating System.
It comes with all the programs such as editor, compilers
etc.,
It Comes with Various file systems such as AIX, HP
UX,Solaris.
It was designed as a multiuser operating system.
Other wellknown operating systems included Windows,
Macintosh System 7, and MSDOS.
LINUX
Its not a operating system.
Its a free clone of the UNIX kernel, and like GNU
tools has succeeded beyond all expectations.
The kernel (from german kern,means core) is the main
component of most computer operating systems; its a
bridge between application software to the hardware of
a computer.
There are also free Unix variants as well, but they are
less likely to use GNU tools because of the
philosophical differences in code sharing and
licensing.
All linux distribution include installation and
management tools,gnu Utilities Such as cp, mv , ls and
gnu editors.
LINUX DISTROS
LINUX vs WINDOWS
S.No.
LINUX OS
WINDOWS OS
1.
2.
Windows Os is expensive.
3.
4.
5.
6.
7.
8.
BOOTING
Booting is a process or set of operations that loads and
hence starts the operating system, starting from the
point when user switches on the power button.
BIOS
BIOS stands for Basic Input/Output System
Performs some system integrity checks (POSTPower On
Self Test)
Searches, loads, and executes the boot loader
program.
It looks for boot loader in floppy, cdrom, or hard
drive. You can press a key (typically F12 of F2, but
it depends on your system) during the BIOS startup
to change the boot sequence.
Once the boot loader program is detected and loaded
into the memory, BIOS gives the control to it.
So, in simple terms BIOS loads and executes the MBR
boot loader.
MBR
MBR stands for Master Boot Record.
It is located in the 1st sector of the bootable disk.
Typically /dev/hda, or /dev/sda
MBR is less than 512 bytes in size. This has three
components:
GRUB
GRUB stands for Grand Unified Bootloader.
It is a Multiboot boot loader.
If you have multiple kernel images installed on your
system, you can choose which one to be executed.
GRUB displays a splash screen, waits for few seconds,
if you dont enter anything, it loads the default
kernel image as specified in the grub configuration
file.
GRUB has the knowledge of the filesystem (the older
Linux loader LILO didnt understand filesystem).
Grub configuration file is /boot/grub/grub.conf
(/etc/grub.conf is a link to this).
The following is sample grub.conf of Linux.
As you notice from the above info, it contains kernel
and initrd image.
So, in simple terms GRUB just loads and executes Kernel
and initrd images.
KERNEL
Once
INIT
(initialization)
Looks at the /etc/inittab file to decide the Linux run
level.
Following are the available run levels
0
1
2
3
4
5
halt
Single user mode
Multiuser, without NFS
Full multiuser mode
unused
X11
6 reboot
RUN LEVELS
When the
services
sendmail
from the
Run
Run
Run
Run
Run
Run
Run
level
level
level
level
level
level
level
0
1
2
3
4
5
6
/etc/rc.d/rc0.d/
/etc/rc.d/rc1.d/
/etc/rc.d/rc2.d/
/etc/rc.d/rc3.d/
/etc/rc.d/rc4.d/
/etc/rc.d/rc5.d/
/etc/rc.d/rc6.d/
LINUX HIERARCHY
pwd command :
It is used to display the present (or) current working directory.
Syntax:
#pwd
Example:
# pwd
/root
date command :
date command is used to print the system date and time.
Syntax:
# date
Example:
#date
#date s yyyymmdd hh:mm:ss
cal command :
cal command is used to print the calendar of the current month.
Syntax:
# cal
Example:
#cal
# cal 3
#cal 2015
cd command:
The following command is used to change from one directory to
another directory.
Syntax:
#cd <directory name>
Example:
#cd .. To a directory one level up (parent directory)
#cd switch to previous working directory
#cd / To the / (slash) directory
#cd /root To switch to root directory
Absolute path:
# cd /test/team
Relative path:
A file or folder which starts without under / is called as relative path.
A shortcut path of file is called relative path.
Example:
# cd ../team
ls command:
It is used to list the files & folders in a present working directory.
Syntax:
ls <option> [argument]
Options:
l
a
d
h
R
i
t
Z
Example:
#ls l /root
#ls ldZ /home
mkdir command :
It is used to create a directory.
Syntax:
mkdir <option> directory name
Options:
p parents (To create multiple directories)
Example:
#mkdir /data /data1
#mkdir p /soft/dvd/os
cat command:
It is use to create a file and view the content in the file.
Syntax:
#cat <file name>
Example1:
# cat > test = To create the file CTL+d to save the file
# cat test
= following command to view the file content
#cat >> test = The following command is used to append a text to
the file.
touch command:
It is used to update the time stamps of a file and create an empty file.
Syntax:
,
#touch [filename]
Example:
cp command:
Syntax:
#cp <option> [source] [destination]
Options:
a
p
v
r
f
Example:
#cp rvf /root/data /soft/ = copy command with multiple options
mv command:
The following command is used to move and rename the files and
directories.
Syntax:
#mv <source> <destination>
Example:
# mv
rm command:
Syntax:
Options:
Example:
/root/songs /opt/
# mv /songs /mp3songs
whatis command:
It searches the short manual page descriptions in the whatis database
for each keyword & and print a oneline description to standard output for each match.
Syntax:
Example:
info command:
Syntax:
Example:
man command:
#whatis <keyword>
# whatis mv
It is used to provide the full information about the command.
#info <option> command
#info mkdir
history Command:
It is used d to view list of used commands.
Syntax:
#history [options]
Options :
Example:
#history
#history c
Echo:
It is used to display the set of characters in the terminal
window. And it is widely used in scripting language in linux.
Syntax:
Example:
echo arguments
#echo my company name is sysadmin
#echo $HOSTNAME
#echo $SHELL
#echo $HOME
head command:
It is used to view first ten line of the file content.
Syntax:
#head [options] <arguments>
Options :
Example:
<value>
#head /etc/passwd
#head 5 /etc/passwd
tail command:
It is used to view last ten line of the file content.
Syntax:
#tail [options] <arguments>
Options :
Example:
<value>
#tail /etc/passwd
#tail 5 /etc/passwd
sort command:
It is used d to view the file content in ascending and
descending order.
Syntax:
Options :
f
r
Example:
( ascending order )
( descending order )
#sort f /etc/passwd
#sort r /etc/passwd
less command:
It is used d to view the file one page at a time.
Syntax:
#less <argument>
Example:
#less /etc/passwd
more command:
It is used d to view the big file little by little.
Syntax:
#more <argument>
Example:
cut command:
Syntax:
#more /etc/passwd
it is used to get particular field, column or character.
#cut [options] <arguments>
Example:
rsync command:
It is used to synchronize faster, flexible replacement for rcp.
Syntax:
rsync [src HOST] [des HOST]
Example:
rsync test tom@172.24.0.254:/home/tom
scp command:
It is used to copies the files between hosts on a network. It use for data transfer
& uses the same authentication & provides the same security as SSH.
Syntax:
scp <options> host1 host2
Example:
scp r data tom@172.24.0.254:/home/tom
GREP
GrepstandsforGlobalsearchforRegularExpressionsandPrint.
Mostofususegrepjustforfindingthewordsinafile.
Thepowerofgrepcomeswithusingitsoptionsandregular
expressions.
Youcananalyzelargesetsoflogfileswiththehelpofgrep
command.
Syntax:
grep[options]pattern[listoffiles]
Examples:
!grep
grep"Error"logfile.txt
grepi "UNix"file.txt
grep"^[09].*"file.txt
grepv"^$"file.txt
Runningthelastexecutedgrepcommand
Searchforastringinafile
Caseinsensitivesearch
Specifyingthesearchstringasa
regularexpressionpattern.
Displayingthenonemptylines
FIND
FindisoneofthepowerfulutilityofUnix(orLinux)used
forsearchingthefilesinadirectoryhierarchy.
Syntax:
find[conditions][pathnames]
Examples:
!find
(lastexecutedfindcommand)
findname"sum.java
(fileusingname)
findiname "sum.java
(usingnameandignoringcase)
find/etcname"*java*
(filesinaspecificdirectory)
findmindepth 2maxdepth 5namesum.java
(filesinthesubdirectoriesbetweenlevel1&4)
find.types(or)d(or)f (Findingsocketfiles(or)dir(or)files)
findtypedname".*
(Findinghiddendirectories)
find.typefname".*
(Findinghiddenfiles)
find.perm777
(filesbasedonthefilepermissions)
find.size1M(or)+1M(or)1M(filessizeisexactly1M/large/small)
find.typed(or)femptydelete(removeemptydir(or)files)
find.mmin 30
(modified30minutesback)
find.mtime 1
(modified1dayback)
Vi & Vim
This "vi" tutorial is intended for those who wish to master and advance their skills beyond the
basic features of the basic editor. It covers buffers, "vi" command line instructions, interfacing
with UNIX commands, and ctags. The vim editor is an enhanced version of vi. The
improvements are clearly noticed in the handling of tags.
The advantage of learning vi and learning it well is that one will find vi on all Unix based
systems and it does not consume an inordinate amount of system resources. Vi works great over
slow network ppp modem connections and on systems of limited resources. One can completely
utilize vi without departing a single finger from the keyboard. (No hand to mouse and return to
keyboard latency)
NOTE: Microsoft PC Notepad users who do not wish to use "vi" should use "gedit" (GNOME
edit) or "gnp" (GNOME Note Pad) on Linux. This is very similar in operation to the Microsoft
Windows editor, "Notepad". (Other Unix systems GUI editors: "dtpad", which can be found in
/usr/dt/bin/dtpad for AIX, vuepad on HP/UX, or xedit on all Unix systems.)
Start
Vi or
Vim
Command
Mode
Enter Insert
Mode
:w
q!
Esc
Back to
command mode
Insert mode
Press
a,I,o,Ins
Insert Mode
Command Mode
Execute Mode
Parameters
User Management
Password Aging
Group Administration
Switching Accounts
Sudo
Files&Directories
foruser
1. Basic files for user & groups
/etc/shadow
/etc/passwd
/etc/gshadow
/etc/group
/etc/sudoers
/etc/profile
~/.bash_profile
/etc/bashrc
interactive nonlogin shell started at the commandline using a shell program such as
/bin/bash or /bin/sh. Executed by ~/.bashrc
PasswordfileFormat
1.
username
password
Password,X=referenceto/etc/shadow,empty=nopassword,*or!=nologinpossible
2.
1.
2.
3.
4.
5.
6.
7.
8.
9.
Username:yourloginname
Password:encryptedpassword.$1$standsforMD5,$2a$isBlowfish,$5$isSHA256 and$6$ isSHA512.
Lastpasswordchange:Whenwasthepasswordlastchanged.
Minimum:Theminimumnumberofdaysrequiredbetweenpasswordchangei.ethenumberofdaysleftbefore
theuserisallowedtochangehis/herpassword.
Maximum:Themaximumnumberofdaysthepasswordisvalid(afterthatuserisforcedtochangehis/her
password)
Warn:numberofdaysbeforepasswordisexpirethatuseriswarnedthatpasswordmustbechanged
Inactive:Thenumberofdaysafterpasswordexpirethataccountisdisabled
Expire:Whenwasthataccountisdisabled.i.eanabsolutespecifyingwhentheloginmaynolongerbeused.
Specialflag:Thisfieldisreservedforfurtheruse.
UserManagement
1. Useradd
addnewuser
a.Addingnewuser
#useradd user1
b.Listdefaultsetting
#useradd D
#useradd D s /bin/sh
//changedefaultshell
c.Supplementarygroups
#useradd G mail user2
d.HomeDirectory
#useradd d /home/samihome user3
e.Changeskeldirectory
#useradd m k /etc/skel2 user4
f.Specificshell
#useradd s /bin/sh user5
///etc/shells
g.Specificuid
#useradd u 550 user6
h.Accountexpire
#useradd e 2015/10/30 user7
2.Usermod
modifyusersdata
a.Shellanddirectorychange
#usermod s /bin/csh d /home/samihome m tom
b.Loginnamechange
#usermod l nathan (new) tom(old)
c.Lockandunlockuser
#usermod L tom
//lock
#usermod U tom
//unlock
d.NewUID
#usermod u 510 tom
e.Expiredate
#usermod e 2015/11/30 tom
#usermod e tom
//removeexpiredate
3.Userdel
deleteuser
a.Deleteuserandleavinghomedirectory
#userdel tom
h.Deleteuserwithhomedirectory
#userdel r tom
PASSWORD AGING
GROUP ADMINISTRATION
1. Group Administration
A user can be participant to more than one group at the same time.
A user who is member of a group can change to that group without password but a user NOT member
can only change to that group password exit and the user gives it.
One or more user can become group administrator for specific groups.
Group Administrator can:
Primary group
every user must be a member of at least one group, which is identified by the numeric GID
in /etc/passwd
Secondary group
A user may be listed as member of additional groups in the relevent entries in the /etc/group
Created whenever a new user is added to the system and has the same name as the user for
which it was created
Example:
[sami@server~]$id
Uid=501(tom) gid=502(tom) groups=502(tom),506(admin)
SWITCHING ACCOUNTS
1.
Su
a. Syntax
su [-] [user]
su [-] [user] c command
b. Allows the user to temporarily become another user in command line
c. Default user is root
d. The option makes the new shell a login shell
e. Most systems log the use of su to change to the root account
2. Example
$su
$su
$su tom
$su l tom
TochangeSSHport:
#vim /etc/ssh/sshd_config
Port 3434
#service sshd restart
#vim /etc/ssh/sshd_config
#PermitRootLogin yes (remove#andpermitrootloginyesorno)
#service sshd restart
#vim /etc/ssh/sshd_config
#PasswordAuthentication yes (remove#andpermitpasswordauthyes/no)
#service sshd restart
#vim /etc/ssh/sshd_config
AllowUsers user2
or
AllowUsers user2@IP
DenyUsers user1
#service sshd restart
SUDO
1. Sudo
a. Purpose: to delegate root privileges to non-root users.
b. Users listed in /etc/sudoers execute commands with
An effective user id of 0
A group id of roots group
c. An administrator is contacted if a user not listed in /etc/sudoers attempts to use sudo
2. Example
a. Default Syntax
User
MACHINE=COMMANDS
root
ALL=(ALL)
ALL
c. Allows members of the sys groups to run networking, service management apps
%sys
%whell ALL=(ALL)
ALL
%whell ALL=(ALL)
ALL
f. Allows member of the users group to mount and unmount the cdrom as a root
%users
1.
Package checking
2. Package installation
#yum install system-config-users
File Permissions
Umask :
umask is the value with this umask mask value kernel can identify who is going to create a file or
directory. Umask is the command to find out umask value
root users umask 022
normal users umask 002
Example 1:
$ umask 333
$ umask
0333
File
- 666 0333
Directory
- 777 0333
=> 333
=> 444
Example 2:
$ umask 777
$ umask
0777
File
- 666 777
Directory
- 777 777
=> 000
=> 000
==> - - - - - - - - - ==> d- - - - - - - - -
Chmod command:
It is used to change the permissions for files and directories. The permission
instruction can be issued either
symbolic method
numeric method
Standard files & directories permission
# ls l
-rw- r r--rwx r-x r-x
File permissions is made for three groups of users:
The owner of the file.
For user => u
One of the groups existing on the system.
For group => g
All other users.
For others => o
Options:
u
g
o
a
+
=
Symbolic method :
r wx s t -
read
write
execute or cd
set user id bit or group
sticky bit
Syntax:
chmod u+w, go-w <file or folder name>
chmod u= rw <file or folder name>
Example 1:
The following command is used to add a permission for the permission of folder.
# chmod u+rwx,g+rw,o+r /songs
Example 2
The following command is used to remove the permission of files.
# chmod u-rwx,g-rwx,o-rwx /song.mp3
Numeric method:
File permissions
read
write
execute
all
4
2
1
7
read,write
read,execute
write,execute
no permission
Syntax :
chmod <UGO> <folder name>
chmod <-options> <file name>
=> 6
=> 5
=> 3
=> 0
Example 1:
The following command is used to modify the folder permissions.
# chmod 755 /movie
Example 2:
The following command is used to modify the file permissions.
# chmod 755
/movie/movie.avi
Chown command:
It is used to change the ownership of the files & directories.
Syntax:
chown <-options> [argument]
Example:
The following command is used to change the ownership
# chown R tom data
Chgrp command:
It is used to change group of the file / directories.
Syntax:
chgrp <-options> argument
Example:
The following command is used to change the group.
# chgrp technical /data
Special Permission
& ACL
Special Permission : SUID, SGID and Sticky Bit
File System ACLs
Three categories to which file permission apply
User, Group, Other
Permission
Effect on Directory
r (read)
w (write)
x (executable)
Sticky Bit:
When set on a directory, users with write access to the directory can
only files they own in the directory.
Syntax:
Chmod o+t
Chmod 0-t
Effect on Directory
SGID chmod u+g file File executes as group that owns the file
"sticky bit"
chmod o+t file
No effect
ACLs Commands:
setfacl sets an ACL entry on a file
getfacl gets the list of ACL entries on a file
Syntax:
setfacl u:<username>:<perms> <filename>
setfacl g:<username>:<perms> <filename>
getfacl <filename>
Example:
#setfacl m u:sysadmin:r-x/data
#setfacl m g:admin:rwx /data
#setfacl x u:sysadmin /data
#setfacl b /data
Tar Command
Tar is an archiving program created to store, maintain, modify and extract files from an archive file
known as a tarfile. A tarfile may be made on a tape drive, however, it is also common to write a
tarfile to a normal file. Is most widely used command to create compressed archive files and that
can be moved easily from one disk to another disk or one server to another server.
Usage and Options
Wildcards can be used to extract out a bunch of files matching the given wildcards.
Linux Filesystem
Management
Part 1 Filesystem Management
Chapter 1 Filesystem Management Process
Chapter 2 Device Recognition
Chapter 3 Disk Partitions
Chapter 4 Making Filesystem
Part 2 How to use New Filesystem
Chapter 5 Filesystem Labels
Chapter 6 Mount points & /etc/fstab
Chapter 7 Mount & Unmount
Chapter 8 Handing Swap files and Partitions
Filesystem Management
Process
1.Objectives
Upon completion of this unit, you should be able to:
Manage virtual memory
Add new drives and partitions
Mount filesystems
How to use new Filesystem
2.Over view: Adding new Filesystems to the Filesystem tree
1)Identify Device: /dev/hda or /dev/sda
2)Partition Device: fdisk, sfdisk, GNU parted, Partprobe
3)Make Filesystem: mkfs, mkfs.ext3, mkfs.ext4, mkfs.xfs, mkfs.vfat
4)Label filesystem: e2lable, tune2fs
5)Create entry in /etc/fstab: mount points, mount, and fsck
6)Mount new filesystem: mount, umount
Device Recognition
1.BIOS a list of device to start Operating System (CD, hard disk)
2.First sector of the first cylinder at hard disk Master Boot Record
3.Master Boot Record (MBR) contains:
a.Executables code to load operating system Boot Loader
b.GRUB Grand Unified Boot Loader in Linux systems
c.Space for partition tables information, Including:
Hard Disk type IDE (hda, hdb), SCSI or SATA (sda, sdb)
Partition id Linux swap, Linux , Linux LVM, RAID, DOS
Partition type Primary, Extended and Logical
Partition has each size sector, blocks or cylinders
Starting cylinder for partition 1 cylinder is about 8 MB
Number of cylinder for partition
Disk Partition
1.Types of partitions
a.Primary Partitions: supports only 4 partitions per drive
b.Extended Partitions: one of Primary, includes all Logical partitions
c.Logical partitions: permits the definition of more than four
partitions
2.Total maximum number of partitions supported by the Kernel:
a.63 for IDE drives
b.15 for SCSI or SATA drives
3.Why partition drives?
a.Containment: security breach, user demand
b.Performance: Keeping data together which reduce disk head seek
c.Quotas: using specific file partition
Recovery: easy backup and recovery
4.Managing Partitions
1)Create Partitions using:
a.fdisk most commonly used partitioning program
# fdisk /dev/sda
b)sfdisk more accurate and flexible than fdisk
#sfdisk /dev/sda
c)GNU parted advanced partition manipulation ( create, copy, resize,
etc.)
#parted l /dev/sda
#yum install gparted y ; gparted &
2)Partprobe /proc/partitions
Need to reboot after creating new partition so that kernel reads new partition
table
Reinitializes the kernels inmemory version of the partition table without
rebooting again
#partprobe
#kpartx a /dev/sda; kpartx l /dev/sda
Making Filesystems
1.Mkfs Creating file system
Mkfs.ext3, mkfs.ext4, mkfs.xfs, mkfs.vfat, mkfs.msdos
Specific filesystem utilities can be call directly
#mkfs t ext4 /dev/sda5
(or)
#mkfs.ext4 /dev/sda5
2.mke2fs [options] device
#mke2fs j L data b 2048 i 4096 /dev/sda6
L: filesystem label
j: journaling
b: block size
i: inode per ever 4 kb of disk space
Filesystems Labels
1.e2label filesystem label
a.e2label special _dev_file
#e2label /dev/sda5 data; e2label /dev/sda5
b.Mount label=fslabel mount _point
#mount LABEL=data /data
c.See labels and filesystem type of all devices
#blkid
1.Tune2fs Adjust filesystem parameters
Reserved blocks, default mount options, fsck frequency
a.View current settings
#dumpe2fs /dev/sda5
b.Modify the percentage of reserved clocks
#tune2fs m 10 /dev/sda5
c.Set the default mount options
#tune2fs o acl,user_xattr /dev/sda1
d.Disable mandatory filesystem checks
#tune2fs i0 c0 /dev/sda5
Summary
Five steps to control linux filesystems
1.Bios recognition
2.Creating partitions fdisk, gparted, sfdisk
3.Making filesystems for new partition mkfs
4.Labeling new partitions e2label
5.Mounting and using new filesystem
mount, /etc/fstab
In Linux, Logical Volume Manager (LVM) is a device mapper target that provides logical
volume management for the Linux kernel. Most modern Linux distributions are LVM-aware
to the point of being able to have their root file systems on a logical volume.
Heinz Mauelshagen wrote the original LVM code in 1998, taking its primary design
guidelines from the HP-UX's volume manager.
LVM is commonly used for the following purposes:
Managing large hard disk farms by allowing disks to be added and replaced without downtime
or service disruption, in combination with hot swapping.
On small systems (like a desktop at home), instead of having to estimate at installation time
how big a partition might need to be in the future, LVM allows file systems to be easily
resized later as needed.
Performing consistent backups by taking snapshots of the logical volumes.
Creating single logical volumes of multiple physical volumes or entire hard disks (somewhat
similar to RAID 0, but more similar to JBOD), allowing for dynamic volume resizing.
LVM can be considered as a thin software layer on top of the hard disks and partitions, which
creates an abstraction of continuity and ease-of-use for managing hard drive replacement, repartitioning, and backup.
OSI LAYER
The Open System Interconnection (OSI) model defines a
networking framework to implement protocols in
seven layers.
Private IP
Class A 10.0.0.0
Class B 172.16.0.0
class C 192.168.0.0
Public IP
APIPA IP:
169.254.0.1
10.255.255.255
172.31.255.255
192.168.255.255
169.254.255.254
Peer-to-peer network
Temporary ip
Note : Maximum 255 IP address in a single N/W card can assign as alias
i) # ifconfig eth0:0 192.168.6.146 255.255.255.0
ii) # ifconfig eth0:1 192.168.6.150 255.255.255.0 up
iii) # ifconfig eth0:2 192.168.6.151/24
# service network restart > It will destroy the temporary ip
Permonent IP Address
cd /etc/sysconfig/networkscripts/
ls l | grep ifcfgeth
cp p ifcfgeth0 ifcfgeth0:1
vim ifcfgeth0:1
DEVICE=eth0:1
ONBOOT=yes
HWADDR=00:0c:29:3e:a7:a4
IPADDR=192.168.6.150
TYPE=Ethernet
BOOTPROTO=none
NETMASK=255.255.255.0
NAME="System eth0:1"
ifconfig eth0:1
service NetworkManager stop
chkconfig NetworkManager on
service iptables stop
service ip6tables stop
chkconfig ip6tables on
chkconfig iptables on
service network restart
ifconfig a
watch ifconfig
ip addr show
ip route show
ip 4 addr show
ip 6 addr show
ethtool
#ethtool eth0 >
#ethtool t eth0 online > HW component LAN card is
working perfectly or not
#ethtool t eth0 offline
#ethtool i eth0 >
driver information
#ethtool s eth0 speed 100 autoneg off
#ethtool a eth0 > Display auto negotiation on or off
#ethtool s eth0
netstat
#netstat in
#service network restart
#ifconfig
#setup
# cat /etc/hosts
#hostname server1.verizon.com ====To set the hostname temporary
To set the hostname permenant
[root@server ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server.verizon.com
To Put DNS entry
[root@desktop75 ~]# cat /etc/resolv.conf
search example.com
nameserver 192.168.0.254
IP FORWARDING
Enable ip forwarding on your machine.
Temporarily set:
# sysctl w net.ipv4.ip_forward=1
[OR]
# echo 1 > /proc/sys/net/ipv4/ip_forward
Permanently set:
# vim /etc/sysctl.conf
net.ipv4.ip_forward=1
#vim /etc/sysconfig/network
FORWARD_IPV4=true
# sysctl p /etc/sysctl.conf
[OR]
# systemctl restart network.service
NOTE: sysctl configure kernel parameters at runtime
VERIFICATION:
# sysctl a | grep net.ipv4.ip_forward
# cat /proc/sys/net/ipv4/ip_forward
GUI
#systemconfignetworktui
(or)
#setup
Note :
Port Information can be seen in the file: /etc/services
#cat /etc/services | grep i telnet
#yum install telnet* y
# telnet 192.168.0.85 22 > port no
#netstat an | grep w 22
#netstat ant
Iface
eth0
PORT FORWARDING
SYNTAX FOR RHEL6:
ssh L local-port:remote-hostname:remote-port
username@hostname
SYNTAX FOR RHEL7:
#firewallcmd permanent addrichrule='rule
family=ipv4 source address=clientIP forwardport
port=5243 prfamily=ipv4 sotocol=tcp toport=22'
#firewallcmd reload
#firewallcmd listrichrules
Verfication On Client Machine:
#ssh serverIP p 5243
HARDWARE
MANAGEMENT
dmidecode - DMI table decoder
# dmidecode t <keywords/number>
dmidecode: an argument 't Type number or keyword
expected.
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
Information
Type
Information
BIOS
10
On Board Devices
System
11
OEM Strings
Base Board
12
Chassis
13
BIOS Language
Processor
14
Group Associations
Memory Controller
15
Memory Module
16
Cache
17
Memory Device
Port Connector
18
System Slots
19
Type
Information
Type
Information
20
31
21
32
System Boot
22
Portable Battery
33
23
System Reset
34
Management Device
24
Hardware Security
35
25
36
26
Voltage Probe
37
Memory Channel
27
Cooling Device
38
IPMI Device
28
Temperature Probe
39
Power Supply
29
40
Additional Information
30
41
Onboard Device
Additionally, type 126 is used for disabled entries and type 127 is an endoftable
marker. Types 128 to 255 are for OEMspecific data.
dmidecode will display these entries by default, but it can only decode them when
the vendors have contributed documentation or code for them.
Keyword
Types
bios
0, 13
system
baseboard
2, 10, 41
chassis
processor
memory
5, 6, 16, 17
cache
connector
slot
CPU Information
dmidecode t processor
cat /proc/cpuinfo > All the info. about the cpu
lscpu
cat /proc/cpuinfo | grep processor
cat /proc/cpuinfo | grep cores
grep "core id" /proc/cpuinfo
cat /proc/cpuinfo | grep processor | wc l
cat /proc/cpuinfo | grep core | wc l
nproc
Note : The nproc command just prints out the number of processing units available. Note
that the number of processing units might not always be the same as number of
cores.
Note: can see the usage of your CPU cores using top
command.
Open a Terminal.
Type top. You will see some information about tasks,
memory etc.
Type 1 to show individual CPU usage
Note : you can follow the below steps to install lshw tools,
then you can use it
1.wget http://ezix.org/software/files/lshwB.02.14.tar.gz
tar zxvf lshwB.02.14.tar.gz
cd lshwB.02.14
make && make install
RAM
# dmidecode t memory | grep "Type"
# dmidecode t 17 | grep i Type
# dmidecode t 17
# lshw class memory
PCI (Peripheral Component Interconnect)
#lspci
00:19.0 Ethernet controller: Intel Corporation 82579V Gigabit Network Connection (rev
05)
1
2
3
4
DISK Information
# lspci | grep i scsi
or
# lspci | grep i sata
# lspci | grep i eth
# cd /sys/bus/pci
# ls
cd devices/
# ls
# cd 0000:00:19.0
# ls
# cat device
# cat /proc/scsi/scsi
# hdparm i /dev/sda > HDD Model No & Serial NO
# free m
# lsblk
# mount | column t
# mount | column t | grep ext
# dmidecode | grep ^Handle | wc l
# dmidecode | grep structures
To add a HDD
# lspci | grep i scsi
# cd /sys/bus/pci/devices
#ls
# cd 0000\:00\:10.0/
#ls
Note : open one duplicate terminal and watch
#udevadm monitor
Note : add a HDD in virtula server then scan
#fdisk l
# echo " " > /sys/class/scsi_host/host2/scan
Note : you can monitor the process
Note : Now remove the HDD
# echo 1 > /sys/block/sdb/device/delete
# fdisk l
Note : Now remove the HDD physically
#cd net/
#cd e1000
#ls
#modinfo e1000 | more
# ethtool i eth0
#lspci | grep i eth
/sys/class/net/eth0/device/driver
#ls l
modprobe r e1000 > To remove a lan card driver
Go to console and enter the command
#modprobe e1000
# service network restart
Now go to putty reload the server
To Change the HW address
step 1: bring down the interface
# ifconfig a
# ifconfig eth2 down
#ifconfig eth2 hw ether 00:01:02:03:04:05
DU
The Linux du (Disk Usage) is a standard Unix/Linux
command, used to check the information of disk usage of
files and directories on a machine.
The du command also displays the files and directory
sizes in a recursively manner.
Syntax:
du <options> <file or dir name>
Options
-h
-s
-a
-k
-m
--exclude
time
Descriptions
Human Readable Format
summary
all the files and directories
Kilobyte(size in 1024 bytes)
Megabytes (MB)
exclude any file formats.
Ex: du ah exclude="*.txt" /home
modification of time
Ex: du ha time /home
DD COMMAND
This tool is mainly used for copying and converting data, hence it stands for
Data Duplicator.
Only superuser can execute this command. You should be very careful while
using this command as improper usage may cause huge data loss. So, some
people consider this tool as Data Destroyer.
Syntax of dd command
dd if=<source file name> of=<target file name> [Options]
Command
dd if=/dev/sda of=/tmp/sdadisk.img
dd if=/tmp/sdadisk.img of=/dev/sda
Command
Backing up MBR
dd if=/tmp/mbr.img of=/dev/sda
Command
Command
Command