This is a quick and dirty cheatsheet on basic commands for RHEL 6, 7 and 8.
The commands where checked with the following releases
System Information | |||
Task | RHEL6 | RHEL7 | RHEL8 |
---|---|---|---|
Server release info | cat /etc/redhat-release lsb_release -a cat /proc/version |
cat /etc/redhat-release cat /proc/version |
cat /etc/redhat-release cat /proc/version |
Server type | dmidecode |
dmidecode |
dmidecode |
Hardware info | lspci lsusb lshal Note: hal = hardware abstraction layer |
lspci lsusb |
lspci lsusb |
Operating system | uname -a |
uname -a |
uname -a |
Memory | cat /proc/meminfo (detailed) free -om cat /proc/slabinfo |
cat /proc/meminfo (detailed) free -m cat /proc/slabinfo |
cat /proc/meminfo (detailed) free -m cat /proc/slabinfo |
CPU (type, number, etc) | cat /proc/cpuinfo |
cat /proc/cpuinfo |
cat /proc/cpuinfo |
Disk Drives | fdisk -l sfdisk -l (advanced server) parted <device> print partprobe -s <device> smartctl -a <device> |
fdisk -l sfdisk -l (advanced server) parted <device> print partprobe -s <device> smartctl -a <device> |
fdisk -l sfdisk -l (advanced server) parted <device> print partprobe -s <device> smartctl -a <device> |
Kernel File and associated directories | ls -l /boot/initrd* ls -l /boot/vmlinuz* |
ls -l /boot/initramfs* ls -l /boot/vmlinuz* |
ls -l /boot/initramfs* ls -l /boot/vmlinuz* |
Kernel 32 or 64 | uname -a uname -m getconf -a |grep -i 'long_bit' cat /proc/version |
uname -a uname -m getconf -a |grep -i 'long_bit' cat /proc/version |
uname -a uname -m getconf -a |grep -i 'long_bit' cat /proc/version |
Display IRQ, IO Ports and DMA | cat /proc/interrupts cat /proc/ioports cat /proc/dma |
cat /proc/interrupts cat /proc/ioports cat /proc/dma |
cat /proc/interrupts cat /proc/ioports cat /proc/dma |
Memory and Swap | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Memory | cat /proc/meminfo (detailed) free -om |
cat /proc/meminfo (detailed) free -m |
cat /proc/meminfo (detailed) free -m |
Page size | /usr/bin/getconf -a|egrep -i 'pagesize|page_size' |
/usr/bin/getconf -a|egrep -i 'pagesize|page_size' |
/usr/bin/getconf -a|egrep -i 'pagesize|page_size' |
Display swap | cat /proc/swaps (detailed) swapon -s |
cat /proc/swaps (detailed) swapon -s |
cat /proc/swaps (detailed) swapon -s |
Adding swap | device: create partition with fdisk (type 82) file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile bs=1024 count=50000 mkswap <device>|<file> swapon <device>|<file> update /etc/fstab |
device: create partition with fdisk (type 82) file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile bs=1024 count=50000 mkswap <device>|<file> swapon <device>|<file> update /etc/fstab |
device: create partition with fdisk (type 82) file(create 50MB swap file): dd if=/dev/zero of=/var/swapfile bs=1024 count=50000 mkswap <device>|<file> swapon <device>|<file> update /etc/fstab |
Removing swap | swapoff <device>|<file> Remove device or file as normal |
swapoff <device>|<file> Remove device or file as normal |
swapoff <device>|<file> Remove device or file as normal |
Devices, Disks and Filesystems | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Disk Drives | fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device> udevadm info -q all -n /dev/sda1 blkid dmsetup [ls|info] |
fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device> blkid dmsetup [ls|info] |
fdisk -l sfdisk -l (advanced server) parted <device> print partprobe <device> blkid dmsetup [ls|info] |
Disk serial Number, type, etc | hdparm -i /dev/hda hdparm -I /dev/hda (detailed) hdparm -Tt /dev/hda (speed test) sdparm -i /dev/sdb cat /proc/ide/ide0/hda/model cat /proc/scsi/scsi |
cat /proc/ide/ide0/hda/model cat /proc/scsi/scsi |
hdparm -i /dev/hda hdparm -I /dev/hda (detailed) hdparm -Tt /dev/hda (speed test) cat /proc/ide/ide0/hda/model cat /proc/scsi/scsi |
Disk disk partitions | fdisk -l sfdisk -l (advanced server) cat /proc/partitions (very high level) cat /etc/fstab |
fdisk -l sfdisk -l (advanced server) cat /proc/partitions (very high level) cat /etc/fstab |
fdisk -l sfdisk -l (advanced server) cat /proc/partitions (very high level) cat /etc/fstab |
List Raw Partitions | /etc/udev/rules.d/60-raw.rules udevinfo -d or udevadm info raw -qa |
/etc/udev/rules.d/60-raw.rules raw -qa |
/etc/udev/rules.d/60-raw.rules raw -qa |
Bad Blocks | badblocks |
badblocks |
badblocks |
Filesystem commands | df -k df -h |
df -k df -h |
df -k df -h |
Filesystem (create|remove) | mkfs -t ext3 /dev/sdb1 mke2fs -t ext4 /dev/sdb1 # all point to mke2fs mkfs.ext2 mkfs.ext3 mkfs.ext4 cat /etc/mke2fs.conf |
mkfs -t ext3 /dev/sdb1 mke2fs -t ext4 /dev/sdb1 # all point to mke2fs mkfs.ext2 mkfs.ext3 mkfs.ext4 cat /etc/mke2fs.conf |
mkfs -t ext3 /dev/sdb1 mke2fs -t ext4 /dev/sdb1 # all point to mke2fs mkfs.ext2 mkfs.ext3 mkfs.ext4 cat /etc/mke2fs.conf |
Tune filessytem | tune2fs tune2fs -l /dev/sda1 # change reserved blocks percentage to 1% tune2fs -m 1 /dev/sda1 |
tune2fs tune2fs -l /dev/sda1 # change reserved blocks percentage to 1% tune2fs -m 1 /dev/sda1 |
tune2fs tune2fs -l /dev/sda1 # change reserved blocks percentage to 1% tune2fs -m 1 /dev/sda1 |
Force fsck | touch /forcefsck tune2fs -l /dev/sdb<?> |grep -i 'filesystem state' |
touch /forcefsck tune2fs -l /dev/sdb<?> |grep -i 'filesystem state' |
touch /forcefsck tune2fs -l /dev/sdb<?> |grep -i 'filesystem state' |
Backup filesystem | tar dd cpio |
tar dd cpio |
tar dd cpio |
Display or set the boot device | cat /boot/grub/grub.conf |
cat /boot/grub2/grub.cfg |
cat /boot/grub2/grub.cfg |
Create boot device (MBR) | grub-install <raw-device> |
grub-install <raw-device> grub2-install <raw-device> |
grub2-install <raw-device> |
Mount/Unmount | mount umount |
mount umount |
mount umount |
Remount filesystem | mount -o remount,rw / |
mount -o remount,rw / |
mount -o remount,rw / |
Boot into maintenance mode | Enter maintenance mode add below to end of kernel line single |
Enter maintenance mode add below to end of linux16 line rd.break |
Enter maintenance mode add below to end of linux line rd.break |
List device drivers | cat /proc/devices |
cat /proc/devices |
cat /proc/devices |
Networking | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Bsic network info | /etc/sysconfig/network /etc/sysconfig/network-scripts |
/etc/sysconfig/network /etc/sysconfig/network-scripts |
/etc/sysconfig/network /etc/sysconfig/network-scripts |
Display/Configure network interfaces | RHEL Networking | RHEL Networking | RHEL Networking |
Default router | edit /etc/sysconfig/network |
edit /etc/sysconfig/network |
edit /etc/sysconfig/network |
Routing table | netstat -rn route -n |
netstat -rn route -n |
netstat -rn route -n |
Change hostname | /etc/sysconfig/network /etc/hosts sysctl -a |grep hostname |
/etc/sysconfig/network /etc/hosts sysctl -a |grep hostname |
/etc/sysconfig/network /etc/hosts sysctl -a |grep hostname |
DNS setup | /etc/resolv.conf |
/etc/resolv.conf |
/etc/resolv.conf |
Name service switch file | /etc/nsswitch.conf /etc/host.conf /etc/resolv.conf |
/etc/nsswitch.conf /etc/host.conf /etc/resolv.conf |
/etc/nsswitch.conf /etc/host.conf /etc/resolv.conf |
Domain Name | /etc/sysconfig/network (HOSTNAME option) /etc/resolv.conf |
/etc/sysconfig/network (HOSTNAME option) /etc/resolv.conf |
/etc/sysconfig/network (HOSTNAME option) /etc/resolv.conf |
Obtain IP address routing | ip route get <IP address> traceroute |
ip route get <IP address> traceroute |
ip route get <IP address> traceroute |
Find Services on the network | Boot (jumpstart) servers: rpcinfo -b bootparam 1 NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv |
Boot (jumpstart) servers: rpcinfo -b bootparam 1 NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv |
Boot (jumpstart) servers: rpcinfo -b bootparam 1 NFS servers: rpcinfo -b mountd 1 NIS servers/slaves: rpcinfo -u <yp server> ypserv |
Crash Dump | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Check installed | rpm -qa kexec-tools yum install kexec-tools /etc/kdump.conf # dump location |
rpm -qa kexec-tools yum install kexec-tools /etc/kdump.conf # dump location |
rpm -qa kexec-tools yum install kexec-tools /etc/kdump.conf # dump location |
Grub configuration | cat /etc/default/grub crashkernel=128M |
cat /etc/default/grub crashkernel=128M |
|
Enable/Disable/Start/Stop | service kdump start service kdump stop service kdump status |
systemctl enable kdump.service systemctl disable kdump.service systemctl start kdump.service systemctl stop kdump.service |
systemctl enable kdump.service systemctl disable kdump.service systemctl start kdump.service systemctl stop kdump.service |
Introduction | kdump (part of kexec rpm) /etc/kdump.conf (select where you want the dump to go) service kdump start chkconfig kdump on ## to crash the system echo "c" > /proc/sysrq-trigger crash (used to analyse crash dumps) |
kdump (part of kexec rpm) /etc/kdump.conf (select where you want the dump to go) ## to crash the system echo "c" > /proc/sysrq-trigger sosreport coredumpctl eu-unstrip, eu-readelf gdb |
kdump (part of kexec rpm) /etc/kdump.conf (select where you want the dump to go) ## to crash the system echo "c" > /proc/sysrq-trigger sosreport coredumpctl eu-unstrip, eu-readelf gdb |
Performance, Monitoring and Diagnostics | |||
Task | RHEL6 | RHEL7 | RHEL8 |
CPU | top sar mpstat w (load average) uptime (load average) ps vmstat procinfo oprofile cat /proc/cpuinfo |
top sar mpstat | iostate, etc (sysstat package) w (load average) uptime (load average) ps vmstat procinfo oprofile cat /proc/cpuinfo |
top sar mpstat | iostate, etc (sysstat package) w (load average) uptime (load average) ps vmstat procinfo oprofile cat /proc/cpuinfo |
Memory | free vmstat top procinfo slabtop sar cat /proc/meminfo |
free vmstat top procinfo slabtop sar cat /proc/meminfo |
free vmstat top procinfo slabtop sar cat /proc/meminfo |
Network | ethtool mii-tool netstat lsof tcpdump ip |
ethtool mii-tool netstat lsof tcpdump ip |
ethtool mii-tool netstat lsof tcpdump ip |
Disk | sar -d iostat vmstat lsof |
sar -d iostat vmstat lsof |
sar -d iostat vmstat lsof |
Application | strace -p <pid> |
strace -p <pid> |
strace -p <pid> |
NFS | nfsstat [-c|-s] |
nfsstat [-c|-s] |
nfsstat [-c|-s] |
Process | |||
Kernel Modules and Parameters | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Display loaded modules | cat /proc/modules (more detailed) lsmod modinfo <module> Location: /lib/modules/`uname -r`/kernel/drivers Config: /etc/modprobe.conf /etc/modprobe.d |
cat /proc/modules (more detailed) lsmod modinfo <module> Location: /lib/modules/`uname -r`/kernel/drivers Config: /etc/modprobe.d |
cat /proc/modules (more detailed) lsmod modinfo <module> Location: /lib/modules/`uname -r`/kernel/drivers Config: /etc/modprobe.d |
Load modules | modprobe |
modprobe |
modprobe |
Unload modules | modprobe |
modprobe |
modprobe |
Set kernel parameters (tuning) | /etc/sysctl.conf (edit and update then reboot) sysctl -p <filename> sysctl -w param=value No reboot (dynamically): echo "250 32000 100 28" > /proc/sys/kernel/sem echo "536870912" > /proc/sys/kernel/shmmax echo "4096" > /proc/sys/kernel/shmmni echo "2097152" > /proc/sys/kernel/shmall etc............................................. |
/etc/sysctl.conf (edit and update then reboot) sysctl -p <filename> sysctl -w param=value No reboot (dynamically): echo "250 32000 100 28" > /proc/sys/kernel/sem echo "536870912" > /proc/sys/kernel/shmmax echo "4096" > /proc/sys/kernel/shmmni echo "2097152" > /proc/sys/kernel/shmall etc............................................. |
/etc/sysctl.conf (edit and update then reboot) sysctl -p <filename> sysctl -w param=value No reboot (dynamically): echo "250 32000 100 28" > /proc/sys/kernel/sem echo "536870912" > /proc/sys/kernel/shmmax echo "4096" > /proc/sys/kernel/shmmni echo "2097152" > /proc/sys/kernel/shmall etc............................................. |
Display kernel parameters | sysctl -a cat /etc/sysctl.conf cat /proc/sys/kernel/sem cat /proc/sys/kernel/shmmax etc................................... |
sysctl -a cat /etc/sysctl.conf cat /proc/sys/kernel/sem cat /proc/sys/kernel/shmmax etc................................... |
sysctl -a cat /etc/sysctl.conf cat /proc/sys/kernel/sem cat /proc/sys/kernel/shmmax etc................................... |
Interprocess communication | ipcs -a |
ipcs -a |
ipcs -a |
Services | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Display/Start/Stop, etc services | RHEL Services | RHEL Services | RHEL Services |
Patching and Packages | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Packages | RHEL Packages | RHEL Packages | RHEL Packages |
List libraries required for binary program | ldd <file> |
ldd <file> |
ldd <file> |
Users and Groups | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Display users | cat /etc/passwd cat /etc/shadow |
cat /etc/passwd cat /etc/shadow |
cat /etc/passwd cat /etc/shadow |
Create/Remove/Modify user | useradd userdel usermod |
useradd userdel usermod |
useradd userdel usermod |
Change user password | passwd |
passwd |
passwd |
Create/Remoe/Modify group | groupadd groupdel groupmod |
groupadd groupdel groupmod |
groupadd groupdel groupmod |
Password files | /etc/passwd /etc/shadow |
/etc/passwd /etc/shadow |
/etc/passwd /etc/shadow |
Useful user commands | id -a whoami who w finger |
id -a whoami who w finger |
id -a whoami who w finger |
Useful group commands | groups |
groups |
groups |
Password policy | /etc/login.defs |
/etc/login.defs |
/etc/login.defs |
Password aging | chage -l |
chage -l |
chage -l |
NFS | |||
Task | RHEL6 | RHEL7 | RHEL8 |
NFS daemons | server: rpc.mountd,nfsd client: rpc.statd, lockd |
server: rpc.mountd,nfsd client: rpc.statd, lockd |
server: rpc.mountd,nfsd client: rpc.statd, lockd |
NFS files | /etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab |
/etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab |
/etc/exports /var/lib/nfs/etab /var/lib/nfs/xtab |
List nfs clients that have a remote mount | /var/lib/nfs/rmtab |
/var/lib/nfs/rmtab |
/var/lib/nfs/rmtab |
Display NFS shares | showmount -e localhost |
showmount -e localhost |
showmount -e localhost |
Create NFS share | /etc/exports (edit and add share) /sbin/service nfs reload ## /etc/exports example /export *(rw,fsid=0,insecure,no_root_squash,sync) |
/etc/exports (edit and add share) /sbin/service nfs reload ## /etc/exports example /export *(rw,fsid=0,insecure,no_root_squash,sync) |
/etc/exports (edit and add share) /sbin/service nfs reload ## /etc/exports example /export *(rw,fsid=0,insecure,no_root_squash,sync) |
Uncreate NFS share | /etc/exports (edit and remove share) /sbin/service nfs reload |
/etc/exports (edit and remove share) /sbin/service nfs reload |
/etc/exports (edit and remove share) /sbin/service nfs reload |
Start/Stop/Status/Reload NFS daemons | /sbin/service nfs start /sbin/service nfs stop /sbin/service nfs status /sbin/service nfs reload |
/sbin/service nfs start /sbin/service nfs stop /sbin/service nfs status /sbin/service nfs reload |
/sbin/service nfs start /sbin/service nfs stop /sbin/service nfs status /sbin/service nfs reload |
NFS performance | nfsstat [-c|-s] |
nfsstat [-c|-s] |
nfsstat [-c|-s] |
NTP | |||
Task | RHEL6 | RHEL7 | RHEL8 |
NTP, Chrony | RHEL Time Protocols | RHEL Time Protocols | RHEL Time Protocols |
Log Files | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Messages | /var/log/messages |
/var/log/messages |
/var/log/messages |
Syslog | /var/log/syslog |
/var/log/syslog |
/var/log/syslog |
/var/log/mail |
/var/log/mail |
/var/log/mail |
|
Cron | /var/log/cron |
/var/log/cron |
/var/log/cron |
Boot | dmesg |
dmesg |
dmesg |
Security, Firewalls and SELinux | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Checking the passwd/group file | pwck grpck |
pwck grpck |
pwck grpck |
Firewall commands | RHEL Firewall | RHEL Firewall | RHEL Firewall |
SELinux commands | RHEL SELinux | RHEL SELinux | RHEL SELinux |
Miscellaneous | |||
Task | RHEL6 | RHEL7 | RHEL8 |
Shutdown | shutdown -h (halt) shutdown -r (reboot) |
shutdown -h (halt) shutdown -r (reboot) |
shutdown -h (halt) shutdown -r (reboot) |
Init Status | see Target and RunLevels | see Target and RunLevels | see Target and RunLevels |
Startup options | single - use grub to edit kernel line emergency - use grub to edit kernel line linux rescue - use at the boot prompt single: runlevel1, local fs mounted, no network emergency: root fs read-only, no init files run rescue: use cd-rom/network, root mounted as /mnt/sysimage |
single - use grub to edit kernel line emergency - use grub to edit kernel line linux rescue - use at the boot prompt single: runlevel1, local fs mounted, no network emergency: root fs read-only, no init files run rescue: use cd-rom/network, root mounted as /mnt/sysimage |
single - use grub to edit kernel line emergency - use grub to edit kernel line linux rescue - use at the boot prompt single: runlevel1, local fs mounted, no network emergency: root fs read-only, no init files run rescue: use cd-rom/network, root mounted as /mnt/sysimage |
Boot process | Boot sequence 1. BIOS 2. POST 3. Master Boot Record (MBR) - point to the bootloader GRUB or LILO 4. GRUB (stage 1) - point to GRUB stage 1_5 5. GRUB (stage 1_5) - deals with specific filesystem types look at /boot/grub/*1_5 files 6. GRUB (stage 2) – reads /etc/grub.conf and displays the grub menu, it specifies the kernel and the initrd files 7. KERNEL - control given to the kernel 8. INIT - reads /etc/inittab and runs /etc/rc.d/rc.sysinit script |
||
Determine the run level | runlevel who -r |
runlevel who -r |
runlevel who -r |
Obtain default run level | /etc/inittab |
/etc/inittab |
/etc/inittab |
List locale | locale -a |
locale -a |
locale -a |
Timezone | /etc/sysconfig/clock /usr/share/zoneinfo/zone.tab |
/usr/share/zoneinfo/zone.tab |
/usr/share/zoneinfo/zone.tab |