Linux Cheat Sheets & Command References

Quick, practical Linux cheat sheets for system administrators and DevOps engineers. Bookmarkable command references covering filesystems, LVM, systemctl, storage, networking, and everyday Linux operations.

⬇️ Jump To

File & Directory Management

Command Description
ls List files and directories in the current location
ls -l Display files with permissions, owner, size, and timestamp
ls -a Include hidden files starting with dot
ls -lh Show file sizes in human-readable format
tree Display directory structure in a tree format
cd /path Change current working directory
pwd Print the absolute path of the current directory
mkdir dir Create a new directory
mkdir -p a/b/c Create nested directories in one command
rmdir dir Remove an empty directory
cp src dest Copy file from source to destination
cp -r src dest Copy directories recursively
mv src dest Move or rename files or directories
rm file Delete a file
rm -r dir Delete directory and its contents recursively
rm -f file Force delete file without confirmation
touch file Create an empty file or update timestamp
stat file Show detailed file metadata
ln src link Create a hard link
ln -s src link Create a symbolic (soft) link

File Searching

Command Description
find /path -name file Search files by name in the specified directory path
find /path -iname file Search filenames without considering letter case
find /path -type f Find only regular files, excluding directories and links
find /path -perm /4000 Locate files that have the SUID permission bit set
find /path -size +10M Find files larger than the specified size
find /path -mtime -1 Find files modified within the last 24 hours
find /path -empty Locate empty files and empty directories
find /path -links +1 Find files that have more than one hard link
locate file Quickly find files using the system locate database
locate -i file Perform case-insensitive file search using locate
locate -r regex Search files using regular expression patterns
updatedb Update the database used by the locate command

Viewing & Paging Files

Command Description
cat file Display the entire contents of a file on the terminal
less file View file content page by page with scroll and search support
more file View file content one screen at a time with limited navigation
head file Show the first 10 lines of a file by default
head -n 20 file Display the first 20 lines of the specified file
tail file Show the last 10 lines of a file by default
tail -n 20 file Display the last 20 lines of the specified file
tail -f file Continuously monitor a file as new lines are appended, commonly used for logs

Text Processing

CommandDescription
grep pattern fileSearch for a specific text pattern inside a file
grep -i pattern filePerform case-insensitive text search
grep -r pattern dirSearch recursively through all files in a directory
grep -v pattern fileDisplay lines that do not match the given pattern
grep -A 3 pattern fileShow three lines after each matching line
grep -B 3 pattern fileShow three lines before each matching line
awk '{print $1}' filePrint the first column from each line of a file
awk -F: '{print $1}' fileUse a custom field delimiter to extract columns
sed 's/a/b/' fileReplace the first occurrence of a pattern in each line
sed -i 's/a/b/g' fileReplace all occurrences in a file and save changes
cut -d: -f1 fileExtract a specific column using a delimiter
sort fileSort the contents of a file alphabetically
uniqRemove duplicate adjacent lines from sorted input
wc -l fileCount the number of lines in a file
diff f1 f2Compare two files and show line-by-line differences
tee fileWrite command output to both the terminal and a file

Permissions & Ownership

Command Description
chmod 755 file Set read, write, and execute permissions using numeric mode
chmod -R 755 dir Recursively change permissions for all files and directories
chmod u+x file Add execute permission for the file owner
chown user file Change the owner of a file to the specified user
chown user:group file Change both owner and group of a file
chown -R user:group dir Recursively change ownership for a directory and its contents
chgrp group file Change the group ownership of a file
umask Display the default permission mask for new files and directories

Archiving & Compression

Command Description
tar -cvf a.tar files Create a tar archive containing specified files
tar -xvf a.tar Extract files from a tar archive
tar -czvf a.tar.gz files Create a gzip-compressed tar archive
tar -xzvf a.tar.gz Extract files from a gzip-compressed tar archive
gzip file Compress a file using the gzip compression algorithm
gunzip file.gz Decompress a gzip-compressed file
zip a.zip files Create a zip archive from one or more files
zip -r a.zip dir Compress a directory recursively into a zip archive
unzip a.zip Extract files from a zip archive

Networking

Command Description
ping host Test network connectivity to a remote host
ip a Display IP addresses and network interface details
ip link Show available network interfaces and their state
ip r Display the system routing table
ip neigh Show ARP or neighbor cache entries
ip route get IP Show the network route used to reach a destination
ss -tuln List all listening TCP and UDP ports
ss -tanp Show active TCP connections with associated processes
netstat -tulnp Display network connections using the legacy netstat tool
ifconfig Display network interface configuration (deprecated)
nmcli device status Show NetworkManager device connection status
curl URL Fetch data from a URL or test HTTP endpoints
wget URL Download files from a URL to the local system
scp src dest Securely copy files between local and remote systems
ssh user@host Log in to a remote system securely using SSH
traceroute host Trace the network path packets take to a destination
nslookup domain Query DNS servers for domain name information
host domain Perform a simple DNS lookup for a domain
nmcli con show List all configured network connections
nmcli con show <name> Show detailed settings of a specific network connection
nmcli con add ... Create a new NetworkManager connection profile
nmcli con mod <name> ... Modify configuration settings of an existing connection
nmcli con up <name> Activate and bring up a network connection
nmcli dev disconnect <device> Disconnect or disable a specific network device
nmcli con del <name> Delete an existing network connection profile
nmcli con reload Reload NetworkManager connection configuration files

Process & System Monitoring

Command Description
ps aux Display all running processes with detailed information
top Show a real-time, continuously updating process list
htop Enhanced interactive process viewer with color and controls
uptime Display system run time and average system load
watch cmd Execute a command repeatedly and display the output
jobs List jobs currently running in the background
bg %job Resume a stopped job and run it in the background
fg %job Bring a background or stopped job to the foreground
kill PID Send a termination signal to gracefully stop a process
kill -9 PID Forcefully terminate a process using SIGKILL
nice -n 10 cmd Start a command with a lower CPU scheduling priority
renice PID Change the priority of an already running process

Performance & Resource Monitoring

Command Description
free Display current system memory usage statistics
free -h Show memory usage in human-readable format
vmstat Report memory, CPU, and I/O performance statistics
vmstat 1 Refresh system statistics every second
iostat Display disk input and output statistics
iostat -xz 1 Show extended disk performance metrics with live updates
mpstat Display CPU usage statistics for each processor core
pidstat Report performance statistics for individual processes
sar View historical system performance data collected over time
nproc Show the number of CPU cores available to the system
nproc --all Display the total number of installed CPU cores

RPM Package Management

Command Description
rpm -qa List all RPM packages currently installed on the system
rpm -q NAME Display the installed version of a specific package
rpm -qi NAME Show detailed information about an installed package
rpm -ql NAME List all files installed by a package
rpm -qc NAME Display configuration files provided by the package
rpm -qd NAME List documentation files included with the package
rpm -q --changelog NAME Show the change history of the specified package
rpm -q --scripts NAME Display scripts executed during package install or removal
rpm -qf FILE Identify which installed package owns a given file
rpm -qlp FILE.rpm List files contained inside an RPM package file

YUM Package Management

Command Description
yum list List all available and installed packages from configured repositories
yum group list Display available package groups for bulk installation
yum search KEYWORD Search repositories for packages matching a keyword
yum info PACKAGENAME Show detailed information about a specific package
yum install PACKAGENAME Install a package along with all required dependencies
yum group install GROUPNAME Install a predefined group of related packages
yum update Update all installed packages to their latest versions
yum remove PACKAGENAME Remove an installed package from the system
yum history Display the transaction history of package operations

Disk & Filesystem

CommandDescription
df -hShow disk usage per filesystem in human-readable format
df -iDisplay inode usage for each mounted filesystem
du -sh dirShow total disk space used by a directory
du -xDisplay disk usage only on the same filesystem
lsblkList block devices and their hierarchy
lsblk -fShow filesystem type, UUID, and mount points
blkidDisplay block device attributes such as UUID and type
mount dev dirMount a filesystem to a directory
mount | column -tDisplay mounted filesystems in a readable table format
mount | grep ext4Filter and show only ext4 mounted filesystems
mount UUID="<uuid>" /mnt/pointMount a filesystem using its UUID instead of the device name
lsof /mnt/pointIdentify processes that are currently using a mount point
umount dirUnmount a mounted filesystem
findmntDisplay mounted filesystems in a tree view
fdisk -lList disk partitions and partition details
parted printShow partition table information
fsck devCheck and repair a filesystem
resize2fs devResize an ext2/ext3/ext4 filesystem

Swap Management

CommandDescription
mkswap devCreate a swap area on the specified block device
swapon devEnable the specified swap device or partition
swapoff devDisable the specified swap device or partition

LVM (Logical Volume Management)

Command Description
pvs List all physical volumes
pvcreate dev Initialize a block device as a physical volume
pvdisplay Show detailed information about physical volumes
vgs List all volume groups
vgcreate vg pv Create a new volume group using a physical volume
vgextend vg pv Add a physical volume to an existing volume group
vgreduce vg pv Remove a physical volume from a volume group
vgdisplay Display detailed information about volume groups
lvs List all logical volumes
lvcreate -L -n lv vg Create a logical volume with specified size and name
lvextend -l +100%FREE /dev/vg01/lv01 Extend the logical volume using all remaining free space in the volume group
lvextend -L 10G /dev/vg01/lv01 Resize the logical volume to a total size of 10 GiB
lvextend -l +128 /dev/vg01/lv01 Increase the logical volume by 128 physical extents
resize2fs /dev/vg01/lv01 Resize an ext4 filesystem to match the logical volume size
xfs_growfs /mount/point Expand an XFS filesystem after extending the logical volume
lvreduce -L 5G /dev/vg01/lv01 Reduce the logical volume size to 5 GiB (filesystem must be resized first)
lvreduce -L -2G /dev/vg01/lv01 Shrink the logical volume by 2 GiB
lvdisplay Show detailed information about logical volumes
lvremove lv Delete a logical volume

Firewalld

Command Description
firewall-cmd --get-default-zone Display the default firewall zone
firewall-cmd --get-active-zones Show all currently active firewall zones
firewall-cmd --add-service=http Allow an HTTP service temporarily until reboot
firewall-cmd --add-port=80/tcp Open TCP port 80 temporarily in the active zone
firewall-cmd --permanent --add-port=80/tcp Open TCP port 80 permanently across reboots
firewall-cmd --runtime-to-permanent Save current runtime firewall rules permanently
firewall-cmd --reload Reload firewall rules without interrupting connections
firewall-cmd --zone=public --list-all Display full configuration of the public firewall zone

SELinux

Command Description
getenforce Display the current SELinux mode (Enforcing, Permissive, or Disabled)
setenforce 0 Switch SELinux to permissive mode temporarily
setenforce 1 Enable SELinux enforcing mode immediately
semanage port -l List all ports and their associated SELinux types
semanage fcontext -l Display SELinux file context rules
restorecon -Rv /path Restore default SELinux security labels recursively

systemd, Logs & Boot

Command Description
systemctl status svc Check the current status of a system service
systemctl start svc Start a system service immediately
systemctl stop svc Stop a running system service
systemctl restart svc Restart a system service
systemctl enable svc Enable a service to start automatically at boot
systemctl disable svc Disable a service from starting at boot
systemctl is-enabled svc Check whether a service is enabled at boot
systemctl list-units --type=service List all active system services
systemctl get-default Show the default system boot target
systemctl set-default target Set the default boot target
loginctl list-users List users currently logged into the system
loginctl session-status Display detailed information about user sessions

systemd Journal (journalctl)

Command Description
journalctl Display the complete systemd journal containing all available logs
journalctl -n Show the most recent log entries using the default count
journalctl -n 5 Display only the last five log entries
journalctl -f Follow journal logs in real time, similar to tail -f
journalctl -p err Show log messages with error priority and higher
journalctl -xe View recent critical logs with detailed explanations
journalctl -u svc View logs related to a specific service
journalctl --since today Show logs generated since the beginning of today
journalctl --since "YYYY-MM-DD HH:MM:SS" Display logs starting from a specific date and time
journalctl --until "YYYY-MM-DD HH:MM:SS" Display logs up to a specific date and time
journalctl --since "-1 hour" Show logs generated within the last one hour
journalctl -o verbose Display logs with detailed metadata and fields
journalctl _COMM=sshd Filter logs by command or process name
journalctl _EXE=/usr/sbin/sshd Filter logs by full executable path
journalctl _PID=1182 Show logs generated by a specific process ID
journalctl _UID=0 Show logs generated by a specific user ID
journalctl _SYSTEMD_UNIT=sshd.service Display logs for a specific systemd service
journalctl _SYSTEMD_UNIT=sshd.service _PID=1182 Combine multiple filters for precise log searching
journalctl -p debug Show debug-level log messages and above
journalctl -p info Show informational log messages and above
journalctl -p notice Show normal but significant log messages
journalctl -p warning Show warning-level log messages
journalctl -p crit Show critical condition log messages
journalctl -p alert Show alert-level logs requiring immediate attention
journalctl -p emerg Show emergency-level logs when the system is unusable
/run/log/journal Default volatile journal storage location on RHEL 8 (cleared on reboot)

Debugging & Tracing

CommandDescription
strace cmdTrace system calls made by a command
strace -p PIDAttach strace to an already running process
strace -f cmdTrace system calls of child processes as well
strace -c cmdDisplay a summary of system call usage
strace -o file cmdSave system call trace output to a file
lsofList all open files and associated processes
lsof -iShow open network connections
lsof -i :80Display processes using TCP or UDP port 80
lsof -u userList files opened by a specific user
lsof +D /pathShow open files under a given directory
time cmdMeasure the execution time of a command
/usr/bin/time -v cmdDisplay detailed resource usage statistics
perf stat cmdShow performance counter statistics for a command
perf topDisplay real-time CPU performance profiling
perf record cmdRecord performance data for later analysis
perf reportAnalyze and display recorded performance data

Containers (Podman)

CommandDescription
podman pull imageDownload a container image from a registry
podman imagesList all container images stored locally
podman runCreate and run a new container from an image
podman ps -aList all containers, including stopped ones
podman stop ctrStop a running container gracefully
podman rm ctrRemove a stopped container
podman logs ctrView logs generated by a container
podman exec -it ctr bashOpen an interactive shell inside a running container
podman inspect ctrDisplay detailed configuration and status information
podman generate systemdGenerate a systemd service unit for a container

Shell, Bash & Environment

Command Description
echo text Print text or variables to standard output
env Display all current environment variables
export VAR=value Set and export an environment variable
unset VAR Remove an environment variable
alias ll='ls -l' Create a shell alias for a command
source file Execute a script in the current shell session
bash script.sh Run a Bash script in a new shell process
read var Read user input and store it in a variable
history Display previously executed commands
history | grep cmd Search command history for a specific command
!! Repeat the most recently executed command
!$ Reuse the last argument from the previous command
set -x Enable shell debug mode to trace command execution
set +x Disable shell debug mode
exit Exit the current shell session

I/O Redirection

CommandDescription
cmd > fileRedirect standard output to a file, overwriting existing content
cmd >> fileAppend standard output to the end of a file
cmd 2> fileRedirect standard error output to a file
cmd &> fileRedirect both standard output and standard error to a file

Linux (Bash) Keyboard Shortcuts

ShortcutDescription
Ctrl + AMove cursor to beginning of the line
Ctrl + EMove cursor to end of the line
Ctrl + BMove cursor back one character
Ctrl + FMove cursor forward one character
Alt + BMove cursor back one word
Alt + FMove cursor forward one word
Ctrl + UDelete from cursor to start of the line
Ctrl + KDelete from cursor to end of the line
Ctrl + WDelete the word before the cursor
Ctrl + YPaste the last deleted text
Ctrl + LClear the terminal screen
Ctrl + CTerminate the currently running command
Ctrl + RSearch command history in reverse
Ctrl + GExit history search mode
Ctrl + PShow the previous command
Ctrl + NShow the next command

VI / VIM – Essential Command

CommandDescription
iInsert text before the cursor
aInsert text after the cursor
AInsert text at the end of the line
oInsert a new line below the current line
EscReturn to normal mode
REnter replace mode (overwrite text)
r<char>Replace a single character
[N]r<char>Replace N characters
sReplace character and enter insert mode
[N]sReplace N characters and enter insert mode
/patternSearch forward for pattern
xDelete the character under the cursor
[N]xDelete N characters
ddDelete the current line
[N]ddDelete N lines
DDelete from cursor to end of the line
dwDelete the next word
[N]dwDelete the next N words
cwChange (replace) the current word
[N]cwChange the next N words
SDelete the current line and enter insert mode
[N]SDelete N lines and enter insert mode
CChange text from cursor to end of the line
yyYank (copy) the current line
[N]yyYank N lines
pPaste text below the cursor
PPaste text above the cursor
uUndo the last change
[N]uUndo the last N changes
Ctrl + RRedo the last undone change
[N]Ctrl + RRedo N changes
URestore the current line to its original state
vEnter visual mode to select text
yYank (copy) selected text
dDelete selected text
~Toggle case of the character
[N]~Toggle case for N characters
:wSave the file
:qQuit Vim
:q!Quit without saving changes
:wqSave the file and quit
:xSave and quit (same as :wq)
:set nuShow line numbers
:set nonuHide line numbers
:%s/old/new/gReplace all occurrences of a word in the file
:NGo to line number N

Stratis Storage Management

Command Description
yum install stratis-cli stratisd Install Stratis management tools and the Stratis daemon
systemctl enable --now stratisd Enable and start the Stratis daemon immediately and at boot
stratis pool create pool1 /dev/vdb Create a new Stratis storage pool using a block device
stratis pool add-data pool1 /dev/vdc Add an additional block device to an existing Stratis pool
stratis pool list Display all configured Stratis storage pools
stratis filesystem create pool1 fs1 Create a filesystem inside a Stratis storage pool
stratis filesystem list List all Stratis filesystems
stratis filesystem snapshot pool1 fs1 snap1 Create a snapshot of an existing Stratis filesystem
lsblk --output=UUID /stratis/pool1/fs1 Display the UUID of a Stratis filesystem

VDO (Virtual Data Optimizer)

Command Description
yum install vdo kmod-kvdo Install VDO software and the required kernel module
vdo create --name=vdo1 --device=/dev/vdd --vdoLogicalSize=50G Create a VDO volume with a logical size larger than the physical device
vdo status --name=vdo1 Display the current status of a VDO volume
vdo list List all configured VDO volumes
vdo start --name=vdo1 Start a VDO volume
vdo stop --name=vdo1 Stop a VDO volume
vdostats --verbose Show detailed VDO space usage, compression, and deduplication savings

autofs (Automatic Mounting)

Command / Configuration Description
/shares /etc/auto.demo Indirect map that dynamically creates directories under /shares
/- /etc/auto.direct Direct map defining absolute mount points
* -rw server:/path/& Wildcard map for dynamically mounting multiple directories

Power & System Control

CommandDescription
shutdown -h nowShut down the system immediately and power it off
rebootReboot the system immediately
poweroffPower off the machine safely
0 0 votes
Article Rating
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Thanks for your interest!

Content for this is getting ready and will be published soon.

0
Would love your thoughts, please comment.x
()
x