Welcome to the Linux Commands Cheat Sheet! This handy guide is perfect for anyone who's looking to navigate through Linux's commands more easily.
System Based Commands
Displays system information: kernel version, machine type, and more.
Displays the running Linux kernel's release version.
Shows current time, system uptime, users, and load averages.
Shows the system hostname.
Displays the IP address of the current host.
Shows last reboot times and durations in logs.
Displays the current date and time information.
Displays detailed system clock and time zone information.
Displays a simple calendar of the current month.
Shows who is logged on and their activity.
Displays the username of the current user.
Displays information about a user named 'username'.
Hardware Based Commands
Displays messages from the kernel's ring buffer.
Displays detailed information about the CPU.
Displays detailed system memory usage information.
Lists information about the CPU.
Lists detailed hardware configuration of the system.
Lists information about all available block devices.
Shows system memory usage in megabytes.
Displays PCI devices in tree format, verbosely.
Shows USB devices as a tree, verbosely.
Displays hardware information from system BIOS
hdparm -i /dev/sda
Displays information of disk /dev/sda.
badblocks -s /dev/sda
Checks /dev/sda for bad blocks, showing progress.
User Management Commands
Displays the user's UID, GID, and groups.
Shows list of last logged-in users.
Displays who is currently logged in.
Creates a new user group named admin.
Creates a new user account named Sam.
Deletes the user account named Sam.
Modifies properties of an existing user account.
Lists all files, detailed information, in long format.
Displays the present working directory's path.
Creates a new directory named dir1.
Deletes the file named file1.
rm -f file2
Forcefully deletes the file named file2.
rm -r dir1
Recursively removes directory dir1 and its contents.
rm -rf dir1
Forcefully deletes directory dir1 and its contents.
cp file1 file2
Copies file1, creating or overwriting file2.
cp -r dir1 dir2
Copies dir1 to dir2, including subdirectories.
mv file1 file2
Renames or moves file1 to file2.
ln -s /path/to/file_name link_name
Creates symbolic link named link_name to file_name.
Creates an empty file named file1.
cat > file1
Creates/overwrites file1, awaiting standard input.
Displays file1 content, paginating through output.
Displays the first ten lines of file1. tail file1 Displays the last ten lines of file1.
gpg -c file1
Encrypts file1 with symmetric cipher using passphrase.
Decrypts file2.gpg, prompting for the passphrase.
Counts words, lines, and characters in files.
Executes commands with piped or file-provided arguments.
Process Related Commands
Displays a snapshot of current processes.
ps aux | grep telnet
Displays running telnet processes with details.
Shows memory map of a process.
Displays dynamic real-time view of running tasks.
Terminates the process with PID 1234.
Kills all processes named 'proc'.
Terminates processes with the name.
Resumes suspended jobs in the background
Brings a suspended job to foreground
Brings job number 'n' to foreground.
Lists all open files and processes.
renice 19 PID
Changes priority of process with given PID.
Displays Process ID(s) for firefox processes.
Displays a tree of running processes.
File Permission Commands
chmod 644 /data/test.c
Sets the permissions of the file
/data/test.c to be read/write for the owner, and read-only for the group and others.
chmod 755 /dir1
Assigns read, write, and execute permissions to the owner, and read and execute permissions to the group and others for the directory
chown bob:devops filename
Changes file 'filename' ownership to 'bob' and 'devops'.
chown ownername:groupname directory
Change owner and group of the directory.
ip addr show
Displays all network interfaces and their information.
ip address add 192.168.0.1/24 dev eth0
Assigns IP address 192.168.0.1 to interface eth0.
Shows network interfaces and their configuration.
Sends ICMP packets, measures round-trip time to "host".
Retrieves and displays domain's registration information.
Queries DNS, provides domain's DNS information.
dig -x host
Resolves IP address to hostname, shows DNS information.
Performs an IP lookup for the domain name
Downloads file from specified path.
Displays various network-related information and statistics.
Display information about network sockets.
tar -cf backup.tar /home/ubuntu
Creates a tar archive of /home/ubuntu directory.
tar -xf backup.tar
Extracts files from "backup.tar" archive.
tar -zcvf backup.tar.gz /home/ubuntu
Creates compressed "backup.tar.gz" archive of "/home/ubuntu"
Compresses "file1" into "file1.gz", original is removed.
Install Packages Commands
rpm -i pkg_name.rpm
Installs the package "pkg_name.rpm" using RPM Package Manager.
rpm -e pkg_name
Uninstalls the specified RPM package.
dnf install pkg_name
Installs the specified package using DNF. pacman -S pkg_name Installs the specified package using Pacman.
Install Source (Compilation)
Checks system compatibility and generates makefile for software installation.
Compiles code by following instructions in the Makefile.
Installs compiled code into specified system locations.
grep pattern file
Search for a given pattern within the file.
grep -r pattern dir1
Recursively searches for the specified "pattern" within the "dir1" directory and its subdirectories
Finds files named "file" using prebuilt database.
find /home -name index
Searches "/home" directory for files named "index" recursively.
find /home -size +10000k
Finds files over 10000k size in /home directory.
Initiates SSH connection to specified hostname.
ssh -p port_number user@hostname
Initiates SSH connection using specific port. Connect to the host via telnet default port 23 Securely connect to the system via SSH default port 22
Connect to the host via telnet default port 23.
File Transfer Commands
scp file.txt remoteuser@remote_host:/remote/directory
Copies file.txt to remote host's specified directory.
rsync -a /home/ubuntu /backup/
Synchronizes content from source directory to destination directory,preserving attributes.
rsync -a /var/www/web/ user@remote_host:/backup/web_backup/
Synchronizes local directory to remote, preserving attributes.
Disk Usage Commands
Displays human-readable disk space usage for all mounted filesystems.
Displays inode usage information for all mounted filesystems.
Lists all partitions and their information on all drives.
du -sh /dir1
Displays summary of total disk usage size of /dir1, human-readable.
Displays a list of all mounted filesystems and their properties.
mount device-path mount-point
Mounts the device at the specified filesystem mount point.
Directory Traverse Commands
Navigate to the parent directory.
Changes the current directory to the user's home.
Changes the current directory to "/mnt".
Cheat Sheet PDF
Download your free
Linux commands cheat sheet in pdf format and print on A4 size paper.