Rhcsa 1 PDF
Rhcsa 1 PDF
Rhcsa 1 PDF
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.
GNU/Linux:
� The GNU system along with Unix or Linux as it’s kernel make
a complete operating system.
LINUX
�Debian
� Ubuntu
�Slackware Linux
� Suse
�Redhat Enterprise
� Fedora
� CentOS
LINUX DISTROS
LINUX vs WINDOWS
S.No. LINUX OS WINDOWS OS
3. All flavors of Linux come from different All flavors of windows come from
companies like Red Hat, Debian , Microsoft.
Slackware , etc.,
4. Linux can boot from primary partition Windows must boot from the first hard
or logical partition inside an extended disk and must boot from a primary
partition. partition.
5. Linux is multiuser system. Windows is single user system.
7. Linux files names are case sensitive. Windows files names are not case
sensitive.
8. Linux uses ext2,ext3,ext4 and xfs file Windows Uses FAT12,FAT16,FAT32 and
systems. NTFS file Systems.
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
� date command :
� 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 long listing (properties)
a hidden files & normal files
d folder properties
h human readable format
R recursive in tree structure
i Inode number
t sort by time format.
Z display security context of the files
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:
# touch /test /hp /ibm linux solaris =� To create multiple file on
single line command
� cp command:
It is used to copy the file or directory (by using Absolute or Relative
path)
Syntax:
#cp <option> [source] [destination]
Options:
a archive ( It will not modify the time and date)
p preserve ( It will not modify file permission)
v verbose (explain what is being done)
r recursive (To copy all folder)
f force (Force to copy)
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 /root/songs /opt/ =� To move one location to another
location
# mv /songs /mp3songs =� To rename the directory or file
� rm command:
The following command is used to remove files.
Syntax:
rm <filename>
Options:
i interactive (prompt before removal)
r recursive (remove directory and their
contents recursively)
v verbose (explain what is being done)
Example:
#rm rvf /root/data.txt
� 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:
#whatis <keyword>
Example:
# whatis mv
� info command:
It is used to provide the full information about the command.
Syntax:
#info <option> command
Example:
#info mkdir
� man command:
It is used to view online manual pages of any command. Almost every
command has a man “page”.
Syntax:
#man <option> command
Example:
# man cp
� history Command:
It is used d to view list of used commands.
Syntax:
#history [options]
Options :
c =� clear (Clear the history)
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:
echo ‘arguments’
Example:
#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 :
<value>
Example:
#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 :
<value>
Example:
#tail /etc/passwd
#tail 5 /etc/passwd
� sort command:
It is used d to view the file content in ascending and
descending order.
Syntax:
#sort [options] <arguments>
Options :
f ( ascending order )
r ( descending order )
Example:
#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:
#more /etc/passwd
� cut command:
it is used to get particular field, column or character.
Syntax:
#cut [options] <arguments>
Example:
#cut d : f1 /etc/passwd [option is delimiter (i.e) separated by “ : “ ]
#cut c 26 file.txt [ Character 2 to 6 only display ]
� nautilus command:
It is used to view the files & folders in a graphical browser.
Syntax:
nautilus [directory name]
Example:
# nautilus /mnt/
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
� Grep stands for Global search for Regular Expressions and Print.
� Most of us use grep just for finding the words in a file.
� The power of grep comes with using its options and regular
expressions.
� You can analyze large sets of log files with the help of grep
command.
� Syntax:
grep [options] pattern [list of files]
� Examples:
!grep Running the last executed grep command
grep "Error" logfile.txt Search for a string in a file
grep i "UNix" file.txt Case insensitive search
grep "^[09].*" file.txt Specifying the search string as a
regular expression pattern.
grep v "^$" file.txt Displaying the nonempty lines
FIND
� Find is one of the powerful utility of Unix (or Linux) used
for searching the files in a directory hierarchy.
� Syntax:
find [conditions] [pathnames]
� Examples:
!find (last executed find command)
find name "sum.java“ (file using name)
find iname "sum.java“ (using name and ignoring case)
find /etc name "*java*“ (files in a specific directory)
find mindepth 2 maxdepth 5 name “sum.java”
(files in the subdirectories between level 1 & 4)
find . type s (or) d (or) f (Finding socket files (or) dir (or )files)
find type d name ".*“ (Finding hidden directories)
find . type f name ".*“ (Finding hidden files)
find . perm 777 (files based on the file permissions)
find . size 1M(or)+1M(or)1M (files size is exactly 1M/large/small)
find . type d (or) f empty –delete(remove empty dir (or)files)
find . mmin 30 (modified 30 minutes back)
find . mtime 1 (modified 1 day back)
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.)
Enter Insert
Start Mode
Command
Vi or
Mode
Vim
:w
q!
Esc
Back to Press
command mode Insert mode
a,I,o,Ins
There are three types of mode
� Insert Mode
� Command Mode
� Execute Mode
�Insert mode - inserting/appending text �Cut, Paste and delete
�Exiting
~/.bash_profile execute to configure your shell before the initial command prompt.
interactive nonlogin shell started at the commandline using a shell program such as
/etc/bashrc
/bin/bash or /bin/sh. Executed by ~/.bashrc
Password file Format
Password, X=reference to /etc/shadow, empty=no password, *or !=no login possible
2. Shadow File Format ( /etc/shadow )
sami:$6$i7.SAQK2$U9dSrT4E9tEoLEBfS:16729:0:99999:7:::
1 2 3 4 5 6
1. User name: your login name
2. Password : encrypted password. “$1$” stands for MD5, “$2a$” is Blowfish, “$5$” is SHA256 and “$6$” is SHA512.
3. Last password change: When was the password last changed.
4. Minimum: The minimum number of days required between password change i.e the number of days left before
the user is allowed to change his/her password.
5. Maximum: The maximum number of days the password is valid ( after that user is forced to change his/her
password)
6. Warn: number of days before password is expire that user is warned that password must be changed
7. Inactive: The number of days after password expire that account is disabled
8. Expire: When was that account is disabled. i.e an absolute specifying when the login may no longer be used.
9. Special flag: This field is reserved for further use.
User Management
1. Useradd add new user
a. Adding new user
#useradd user1
b. List default setting
#useradd D
#useradd D s /bin/sh //change default shell
c. Supplementary groups
#useradd G mail user2
d. Home Directory
#useradd d /home/samihome user3
e. Change skel directory
#useradd –m k /etc/skel2 user4
f. Specific shell
#useradd s /bin/sh user5 // /etc/shells
g. Specific uid
#useradd u 550 user6
h. Account expire
#useradd –e 2015/10/30 user7
2. Usermod modify user’s data
a. Shell and directory change
#usermod s /bin/csh d /home/samihome m tom
b. Login name change
#usermod l nathan (new) tom(old)
c. Lock and unlock user
#usermod L tom //lock
#usermod U tom //unlock
d. New UID
#usermod u 510 tom
e. Expire date
#usermod e 2015/11/30 tom
#usermod e “” tom //remove expire date
3. Userdel delete user
a. Delete user and leaving home directory
#userdel tom
h. Delete user with home directory
#userdel –r tom
4. Pwconv & pwunconv : combine or separate /etc/passwd and /etc/shadow
#pwconv
#grep root /etc/shadow
#pwunconv
#grep root /etc/shadow ; grep root /etc/passwd
#ls -l /etc/passwd /etc/shadow
5. Creating password for user
a. Passwd
#passwd tom
#passwd -S tom // To check the passwd status of user account
6. Password lock and unlock for user
#passwd -l tom
#passwd -u tom
7. Login without password - empty field
#grep tom/etc/shadow
tom::16729:0:99999:7:::
8. Blocking login by emergent situation
#vi /etc/nologin
Under system checking currently
Please login again after 20:00!!!
9. Listing user information
#finger –l tom
10. How to monitor user
a. Monitor file
• /var/run/utmp : keeps track of the current login state of each user.
• /var/log/wtmp : records all login and logouts history.
• /var/log/btmp : records failed login attempts.
b. Monitoring command
Show who is logged on and what they are doing.
#whoami
Reports the most recent login of all users or of a given user from /var/log/lastlog
#lastlog
Contains all the bad or failed login attempts.
#lastb
Show who is logged on
#who
PASSWORD AGING
every user must be a member of at least one group, which is identified by the numeric GID
Primary group
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
User private group
which it was created
Example:
[sami@server~]$id
Uid=501(tom) gid=502(tom) groups=502(tom),506(admin)
3. Group management commands
a. groupadd – adding group
#groupadd admin
#groupadd –r admin //start group id 101 and increase up to GID 499
#groupadd –g 600 HR
a. Syntax
su [-] [user]
su [-] [user] –c command
2. Example
•$su
•$su –
•$su – tom
•$su –l tom
SSH stands for secure shell.
#yum install openssh* y
#service sshd start
#chkconfig sshd on
#service sshd status
#ssh (ipaddress of target pc)
#ssh user@(ipaddress of user)
#ssh X user@(ipaddress of user with graphical)
How to give banner warning at the time of SSH login
#vim /etc/issue.net
Dont enter to my system..!
#vim /etc/ssh/sshd_config
Banner /etc/issue.net
#service sshd restart
To change SSH port:
#vim /etc/ssh/sshd_config
Port 3434
#service sshd restart
#vim /etc/ssh/sshd_config
#PermitRootLogin yes (remove # and permit root login yes or no)
#service sshd restart
#vim /etc/ssh/sshd_config
#PasswordAuthentication yes (remove # and permit password auth yes/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 root’s 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
b. Allow root to run any commands anywhere
root ALL=(ALL) ALL
c. Allows members of the ‘sys’ groups to run networking, service management apps
%sys ALL=NETWORKING, SERVICES, DELEGATING, PROCESSESS
d. Allows people in group wheel to run all commands
%whell ALL=(ALL) ALL
e. Same thing without a password
%whell ALL=(ALL) ALL
f. Allows member of the users group to mount and unmount the cdrom as a root
%users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
3. How to use sudo
a. Set up sudo Environment in /etc/sudoers as group member
%whell ALL=(ALL) ALL
#usermod –G 10 tom
tom$froups
e. Sudo logging
Defaults logfile=/var/log/sudolog
#touch /var/log/sudolog
$sudo ls /
GUI Tool for
User Management
1. Package checking
#rpm –qa | grep system-config-users
2. Package installation
#yum install system-config-users
Example 2:
$ umask 777
$ umask
0777
File - 666 – 777 => 000 ==> - - - - - - - - - -
Directory - 777 – 777 => 000 ==> d- - - - - - - - -
�Chmod command:
It is used to change the permission’s for files and directories. The permission
instruction can be issued either
symbolic method
numeric method
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 4 read,write => 6
write 2 read,execute => 5
execute 1 write,execute => 3
all 7 no permission => 0
Syntax :
chmod <UGO> <folder name>
chmod <-options> <file name>
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
r (read) Contents of the can be read Content of the directory (file names) can be
listed
w (write) Contents of the can be changed Any file in directory can be created or deleted
x (executable) Content of the file can be executed as Content of the directory can be accessed
acommand (dependent on file's own permission)
SUID (set UID):
When executable file is run, it executes as the user that owns it,
not as the user that ran it.
Syntax:
chmod u+s <file> =� sets SUID permission on a file
chmod u-s <file> =� removes SUID permission
Syntax:
chmod g+s <file> =� sets SGID permission on a file
chmod g-s <file> =� removes SGID permission for a file
chmod g+s <directory> =� sets SGID permission on a directory
chmod g-s <directory> =� removes SGID permission for a directory
� 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.
To check the size of any tar, tar.gz and tar.bz2 archive file, use the following command.
# tar -czf - doc.tar | wc -c
For tar.gz/bz2 files use the “z” and “j” option respectively.
Linux Filesystem
Management
• 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 kernel’s inmemory version of the partition table without
rebooting again
#partprobe
#kpartx –a /dev/sda; kpartx –l /dev/sda
Making Filesystems
Heinz Mauelshagen wrote the original LVM code in 1998, taking its primary design
guidelines from the HP-UX's volume manager.
• 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, re-
partitioning, and backup.
To create a LVM, we need to run through the following steps.
• Select the physical storage devices for LVM
• Create the Volume Group from Physical Volumes
• Create Logical Volumes from Volume Group
Then run
#partprobe (or) partx -a -v /dev/sda / /we informed new partition tables reload to os
#fdisk -l
Now we prepare our new partitions for PV:
#pvcreate /dev/sda1
#pvdisplay (or) pvscan (or) pvs
Now we prepare our PV partitions for VG:
#vgcreate oracle /dev/sda1
#vgdisplay (or) vgscan (or) vgs
Now we prepare our VG partitions for LV:
#lvcreate -L 500M oracle -n db01
#lvcreate -L 500M oracle -n db02
#lvdisplay (or) lvscan (or) lvs
Now we create a directory for mount those LVM's:
#mkdir /data1
#mkdir /data2
Now we format those LVM's into ext4 FS:
#mkfs.ext4 /dev/oracle/db01
#mkfs.ext4 /dev/oracle/db02
Mount those LVM's into permanent mount:
#vim /etc/fstab
/dev/oracle/db01 /data1 ext4 defaults 0 0
/dev/oracle/db02 /data2 ext4 defaults 0 0
:wq
#mount -a
#df -Th
Now let's enlarge /data1 500M to 1GB:
#lvextend -L +500M /dev/oracle/db01
#resize2fs /dev/oracle/db01
#df -Th
How to rename VG
#vgrename java sql
How to split VG
#vgsplit sql veritas /dev/sda5
How to merge 2 VG
#vgmerge -v veritas sql
How LV create with PE size
#lvcreate -l 16 -n /dev/veritas/db01
How to activate and deactivate LV
#lvchange -a y /dev/veritas/db01
#lvdisplay
#lvchange -a n /dev/veritas/db01
#lvdisplay
How to restore the removed VG
#lvremove -f /dev/veritas/db01
#lvs
#vgremove -f veritas
#vgs
Once removed LV and VG and follow the steps VG restoration
#cd /etc/lvm/archive
#ls
#cat veritas-vg_00000-106603032.vg
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
To stop ipv6 protocols permanently
#vim /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
#sysctl p
p > Load in sysctl settings from the file specified.
Note : To disable a particular network card like eth0 permanently
#vim /etc/sysctl.conf
net.ipv6.conf.eth0.disable_ipv6 = 1
#sysctl p
Note : To disable a particular network card like eth0 Temporary
# echo 1 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6
I successfully disabled IPv6 once putting the following lines in
/etc/sysctl.conf:
net.ipv6.conf.all.disable_ipv6 = 1net.ipv6.conf.default.disable_ipv6 =
1net.ipv6.conf.lo.disable_ipv6 = 1
How to Display Routing Table
# route n
# netstat rn
# ip route list
#ifconfig br0:2 192.168.1.63/24
# route add default gw 192.168.1.1
# route n
Kernel IP routing table
# route del default gw 192.168.0.254
#vim /etc/resolv.conf
search example.com
#nameserver 192.168.0.254
nameserver 203.145.184.13
nameserver 203.145.184.32
# ping google.com
GUI
#systemconfignetworktui
(or)
#setup
Note :
Port Information can be seen in the file: /etc/services
#netstat ant >It will gives network statistics(which port number of the server is
connected to which port number of client)
# dmidecode –t <keywords/number>
dmidecode: an argument 't‘ Type number or keyword
expected.
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
The SMBIOS specification defines the following DMI types:
Type Information Type Information
0 BIOS 10 On Board Devices
1 System 11 OEM Strings
2 Base Board 12 System Configuration Options
3 Chassis 13 BIOS Language
4 Processor 14 Group Associations
5 Memory Controller 15 System Event Log
6 Memory Module 16 Physical Memory Array
7 Cache 17 Memory Device
8 Port Connector 18 32bit Memory Error
9 System Slots 19 Memory Array Mapped
Address
Type Information Type Information
20 Memory Device Mapped Address 31 Boot Integrity Services
baseboard 2, 10, 41
chassis 3 Keywords are matched caseinsensitively.
processor 4 The following command lines are equivalent:
memory 5, 6, 16, 17
cache 7 dmidecode –type 0 type 13
dmidecode type 0,13
connector 8
dmidecode type bios
slot 9
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
#lshw class processor
# grep count processor /proc/cpuinfo
# ls /sys/devices/system/cpu/
# cat /sys/devices/system/cpu/kernel_max
# cat /sys/devices/system/cpu/offline
# cat /sys/devices/system/cpu/possible
# cat /sys/devices/system/cpu/present
# cat /sys/devices/system/cpu/online
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
Field 1: PCI bus slot number (Device ID)
Field 2: PCI slot name (Device Name)
Field 3: Name of device attached and its manufactured company
name.(Device Desc)
# lspci vmm | more > mm Dump PCI device data in a machine
readable form for easy
parsing by scripts.
#lspci k > Show kernel drivers handling each device and also kernel
modules capable of handling it.
#lspci v > Be verbose and display detailed information about all
devices.
# dmidecode t bios | more
# dmidecode t baseboard | more
# dmidecode t chassis > cabinet info
# lspci tv > your master PCI bus is 00. It is better to use v option with
t to get detailed information
# lspci m
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
# fdisk l | grep i disk
# cd /sys/class/scsi_host/
# ls
#cd host2
#ls
To Add and remove a ethernet card driver
To locate a kernal Modules
Step 1
#ethtool i eth0
or
Step 2
# cd /lib/modules/
# ls
#cd 2.6.32220.el6.x86_64/
#ls
#cd kernel/
#cd drivers/
#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 Descriptions
-h Human Readable Format
-s summary
-a all the files and directories
-k Kilobyte(size in 1024 bytes)
-m Megabytes (MB)
--exclude exclude any file formats.
Ex: du ah exclude="*.txt" /home
–time 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’.
Description Command
Backup entire hard drive to dd if=/dev/sda of=/dev/sdb bs=4096 conv=noerror,sync
another drive.
Creating a disk image dd if=/dev/sda of=/tmp/sdadisk.img
Creating a compressed disk dd if=/dev/sda | gzip >/tmp/sdadisk.img.gz
image
Restoring hard disk image dd if=/tmp/sdadisk.img of=/dev/sda
Restoring compressed image gzip –dc /tmp/sdadisk.img.gz | dd of=/dev/sda
Clone one partition to dd if=/dev/sda1 of=/dev/sdb1 bs=4096 conv=noerror,sync
another
Backing up and Restoring MBR
Master Boot record is the boot sector which houses the GRUB boot loader. If
MBR got corrupted, we will not be able to boot into Linux. MBR 512 byte
data is located at the first sector of the hard disk. It consists of 446 byte
bootstrap, 64 byte partition table and 2 bytes signature.
Description Command
Description Command
Create a fixed size, say 10MB file dd if=/dev/zero of=file1 bs=10485760 count=1