Linux Cheat Sheet – AlmaLinux 8, CentOS 8, CentOS 7, CentOS 6, CentOS 5

Basic SYSTEM coMMANDS

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Graphical configuration toolssystem-config-*gnome-control-center
Text-based configuration toolssystem-config-*-tui
Configure printersystem-config-printergnome-control-center
Configure networksystem-config-networknmcli
nmtui
nm-connection-editor
nmcli
nmtui
nm-connection-editor
gnome-control-center
Configure system languagesystem-config-languagelocalectllocalectl
gnome-control-center
Configure time and datesystem-config-date
date
timedatectl
date
timedatectl
dategnome-control-center
Synchronize time and datentpdate
/etc/ntp.conf
timedatectl
/etc/chrony.conf
ntpdate
timedatectl
date
/etc/chrony.conf
chronyc
Configure keyboardsystem-config-keyboardlocalectllocalectl
gnome-control-center
Configure SSH/etc/ssh/ssh_config
/etc/ssh/sshd_config
~/.ssh/config
ssh-keygen

Server BASIC INFO

TaskCentOS5CentOS6CentOS7AlamaLinux8/CentOS8
View version information

hostnamectl

rpm -qa centos-release

cat /etc/os-release or cat/etc/centos-release

View system profile

sosreport

dmidecode
hwbrowser

sosreport

dmidecode

lstopo
lscpu

sosreport
dmidecodelstopo
lscpu
cat /proc/cpuinfo
lshw

boot & Kernel

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Single user/rescue modeappend 1 or s or init=/bin/bash to kernel cmdlineappend 1 or s or rd.break or init=/bin/bash to kernel cmdline
Shut down systemshutdown
Power off systempoweroffpoweroff
systemctl poweroff
Halt systemhalthalt
systemctl halt
Reboot systemrebootreboot
systemctl reboot
Configure default run level/target/etc/inittabsystemctl set-default
Configure GRUB bootloader/boot/grub/grub.conf/etc/default/grub
grub2-mkconfig
grub-set-default
Configure kernel modulemodprobe
View hardware configuredhwbrowserlshw (in EPEL)lshw
Configure hardware deviceudev
View kernel parameterssysctl -a
cat /proc/cmdline
Load kernel modulemodprobe
Remove kernel modulemodprobe -r
View kernel versionrpm -q kernel
uname -r

Software installation

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Install softwareyum install
yum groupinstall
yum install
yum group install
View software infoyum info
yum groupinfo
yum info
yum group info
Update softwareyum update
Upgrade softwareyum upgrade
Configure software repositorysubscription-manager repos
/etc/yum.repos.d/*.repo
Find package owning filerpm -qf filename
yum provides filename-glob
View software versionrpm -q packagenameyum list installed packagename
rpm -q packagename
View installed softwarerpm -qa
yum list installed
Install a moduleyum module install module_name
View info on a moduleyum module info module_name
View a module’s streamsyum module info module_name
Change module streamsyum module remove module_name:stream
yum module reset module:stream
yum module install module:new_stream
List available modulesyum module list

SERVER services

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
List all services

chkconfig –list

ls /etc/init.d/

systemctl -at service
ls /etc/systemd/system/*.service
ls /usr/lib/systemd/system/*.service
systemctl list-units -at service
find /etc/systemd/ /usr/lib/systemd/ /run/systemd/ -name *.service”
List running servicesservice –status-allsystemctl -t service –state=active
Start/stop serviceservice name start
service name stop
systemctl start name.service
systemctl stop name.service
Enable/disable servicechkconfig name on
chkconfig name off
systemctl enable name.service
systemctl disable name.service
View service statusservice name statussystemctl status name.service
Check if service is enabledchkconfig name –listsystemctl is-enabled name
Create new service file or modify configurationchkconfig –addsystemctl daemon-reload
/etc/systemd/system/*.service
View run level/targetrunlevel
who -r
systemctl get-default
who -r
Change run level/target/etc/inittab
init run_level

systemctl isolate name.target

systemctl set-default

Configure logging/etc/syslog.conf/etc/rsyslog.conf/etc/rsyslog.conf
/etc/rsyslog.d/*.conf
/var/log/journal
systemd-journald.service
View logs/var/log/var/log
journalctl
Configure system auditadd audit=1 to kernel cmdline
auditctl
/etc/audit/auditd.conf
/etc/audit/audit.rules
authconfig
/etc/pam.d/system-auth
pam_tty_audit kernel module

add audit=1 to kernel cmdline

auditctl
/etc/audit/auditd.conf
/etc/audit/audit.rules
authconfig
/etc/pam.d/system-auth
tlog

View audit outputaureport
/var/log/faillog
Schedule/batch taskscron
at
batch
cron
at
batch
systemd-run –on-calendar
Find file by namelocate
Find file by characteristicfind
Create archivetar
cpio
zip
xz

User operations

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Graphical user managementsystem-config-usersgnome-control-center
Create user accountuseradd
Delete user accountuserdel
View/change user account detailsusermod
/etc/passwd
vipw
id
Create user groupgroupadd
Delete user groupgroupdel
Change group detailsgroupmod
/etc/group
Change user passwordpasswd
Change user permissionsusermod
visudo
Change group permissionsgroupmod
visudo
Change password policychage
View user sessionsw

Volumes, File systems, Storage

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Default file systemext3ext4xfs
Create/modify disk partitions

fdisk

parted

fdisk
gdiskparted
ssm create
parted
fdisk
gdisk
ssm_create
Format disk partitionmkfs.filesystem_type (ext4, xfs)
mkswap
mkfs.filesystem_type (ext4, xfs)
mkswap
ssm create
Defragment disk spacecopy data to new file system
fsck (look for ‘non-contiguous inodes’)
copy data to new file system
fsck (look for ‘non-contiguous inodes’)
xfs_fsr
Mount storage

mount

/etc/fstab

mount

/etc/fstab
ssm mount

Mount and activate swap

/etc/fstab

swapon -a

Configure static mounts/etc/fstab
View free disk spacedf
View logical volume infolvdisplay
lvs
vgdisplay
vgs
pvdisplay
pvs
Create physical volumepvcreatepvcreate
ssm create (if backend is lvm)
Create volume groupvgcreatevgcreate
ssm create (if backend is lvm)
Create logical volumelvcreatelvcreate
ssm create (if backend is lvm)
Enlarge volumes formatted with default file systemvgextend
lvextend
resize2fs
vgextend
lvextend
xfs_growfs
ssm resize
Shrink volumes formatted with default file systemresize2fs
lvreduce
vgreduce
XFS cannot currently be shrunk; copy desired data to a smaller file system.
Check/repair file systemfsckfsck
ssm check
View NFS shareshowmount -e
mount
Configure NFS share/etc/exports
service nfs reload
/etc/exports
systemctl reload nfs.service
Configure on-demand auto-mounts/etc/auto.master.d/*.autofs
/etc/auto.*
Change file permissionschmod
chown
chgrp
umask (future file creation)
Change file attributeschattr
Change access control listsetfacl

Networking & routing

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Configure name resolution/etc/hosts
/etc/resolv.conf
/etc/hosts
/etc/resolv.conf
nmcli con mod
Configure hostname/etc/sysconfig/networkhostnamectl
/etc/hostname
nmtui
View network interface info

ip addr

ifconfig
brctl

ip addr
nmcli dev show
teamdctl
brctl
bridge
Configure network interface/etc/sysconfig/network-scripts/ifcfg-*/etc/sysconfig/network-scripts/ifcfg-*
nmcli con [add|mod|edit]
nmtui
nm-connection-editor
View routesip route
Configure routesip route add
system-config-network
/etc/sysconfig/route-iface
ip route add
nmcli
nmtui
nm-connection-editor
/etc/sysconfig/route-iface
Configure firewalliptables and ip6tables
/etc/sysconfig/ip*tables
iptables and ip6tables
/etc/sysconfig/ip*tables
system-config-firewall
firewall-cmd
firewall-config
firewall-cmd
firewall-config
nftables
View ports/socketsss
lsof
netstat
ss
lsof
netstat
ss
lsof
netstat
pcp-dstat –socket

Security management

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Configure system security/etc/selinux/config
chcon
restorecon
semanage
setsebool
system-config-selinux
Report on system securitysealert
LDAP, SSSD, Kerberosauthconfig
authconfig-tui
authconfig-gtk
authselect
Network usersgetent

process management

TaskCentOS5CentOS6CentOS7AlmaLinux8/CentOS8
Trace system callsstrace
Trace library callsltrace
Change process prioritynice
renice
Change process run locationtaskset
Kill a process

kill

pkill

killall

View system usagetop
ps
sar
iostat
netstat
vmstat
mpstat
numastat
top
ps
sar
iostat
netstat
ss
vmstat
mpstat
numastat
tuna
top
ps
sar
iostat
ss
vmstat
mpstat
numastat
tuna
pcp atop
top
ps
sar
iostat
ss
vmstat
mpstat
numastat
tuna
View disk usagedfdf
iostat
pcp-dstat
pmiostat
df
iostat

Leave a Reply

Your email address will not be published. Required fields are marked *