100+ Linux Commands Cheat Sheet (With Practical Examples)

A complete Linux commands cheat sheet with 100+ essential commands and practical examples. Learn file management, system monitoring, networking, permissions, and DevOps-related Linux commands used by administrators, developers, and engineers.

Published

Updated

Read time 11 min read

Reviewed byDeepak Prasad

100+ Linux Commands Cheat Sheet (With Practical Examples)

In this cheat sheet tutorial I have consolidated a list of Linux commands with examples and man page link to give you an overview on Linux day to day usage. We know Linux is one of the preferred choice for most of the IT domains so having basic knowledge of Linux is mandatory for everyone. I have divided the Linux commands into different section so you can choose to only concentrate on the commands which suits your domain.

Use the category cards and search box above to jump straight to a topic or filter by command name. Each row lists when to use the command and the syntax to run — the same two-column layout as our other cheat sheets. Deeper guides are linked from the description column where we have a dedicated article on this site.

I will keep adding and updating this article from time to time to add more commands.

File and directory ownership steps use chown command.

Environment Variables

5 commands

Shell variables are local to the process that creates them. Export a variable when child shells or commands started from this session must inherit it. The table lists the usual commands to display, set, export, or unset environment variables.

When to use Command
Display environment variables printenv
Run a program with a modified environment env
Export a variable to child processes export VAR=value
Display all shell variables and functions set
Remove a shell variable or function unset VAR

File Management

21 commands

The commands under this section are very basic commands and must be known to every system administrator. This is definitely not the complete list of Linux commands for file management but can give you a kickstart and can cover most of the basic to complex scenarios.

For ordering lines in files or pipeline output, see the sort command.

When to use Command
List files (basic, long, hidden, sorted by time) ls, ls -l, ls -la, ls -ltr
Print file content to terminal cat FILENAME
View large files with navigation and scrolling less FILENAME
View file page by page (limited navigation) more FILENAME
Show first lines of file (default 10) head -n 5 FILE
Show last lines or monitor file in real time tail -n 5 FILE, tail -f /var/log/messages
Sort file content (supports -n, -u) sort FILE
Remove adjacent duplicate lines uniq FILE
Identify file type file FILE, file data.txt
Copy files or directories cp SRC DEST, cp /root/file /tmp/
Move or rename files mv old new, mv /root/file /tmp/
Search text in files grep STRING FILE, grep ssh /etc/services
Create directory mkdir DIR
Create empty file touch FILE
Show current directory pwd
Remove files or directories rm FILE, rm -r DIR
Remove an empty directory rmdir DIR
Show disk usage by directory — df and du du -sh PATH
Copy stdin to files and stdout — tee command tee FILE
Create hard or symbolic links — symlink guide ln -s TARGET LINK
Count lines, words, and bytes wc FILE

Finding Files and Directories

7 commands

Most of the time we will end up using find command to find files and directories. But I also like which command as it gives is the path of the binary which is required at multiple events when we are required to execute a binary with complete PATH.

When to use Command
Show full path of executable from $PATH which cmd, which useradd
Locate binary, source, and man pages whereis cmd, whereis sshd
Fast search using indexed database locate file, locate sshd
Search files in real-time with filters — examples find / -name file, find / -type f -name sshd
Show file metadata (size, inode, timestamps) stat FILE
Show whether a name is a builtin, alias, or binary type cmd
Rebuild the locate database (often via cron) updatedb

Check User Information

8 commands

These are some of the commands which we use to check the last logged in user information and some other commands to get more details on existing user.

When to use Command
Show logged-in users with session details who -u
List usernames currently logged in users
Show login/logout history from /var/log/wtmp last -a
Display user information (if installed) finger
Show current logged-in user whoami
Display UID, GID, and groups id
Show logged-in users and their activity w
Look up passwd, group, or hosts entries getent passwd USER

Check System Information

10 commands

As a sytem and Linux administrator you must be familiar with these commands. These will help you determine the type of server you are working on, such as load, cpu model, hardware model, hardware type etc. Some of the commands may be distribution specific such as hwinfo is only available in SuSE Linux while others are expected to be found on almost all distros.

When to use Command
Show current time, uptime, logged-in users, and load averages uptime
Show RAM and swap usage — Linux memory management free -m
Display hardware/BIOS details — dmidecode command dmidecode -t system
Extract detailed hardware configuration (memory, CPU, firmware) lshw
Probe system hardware (common on SUSE) hwinfo
Show CPU architecture from sysfs and /proc/cpuinfo lscpu
List PCI buses and connected devices lspci
Print kernel name, version, and architecture uname [OPTIONS]
Set or show system hostname — hostnamectl hostnamectl
Set timezone and NTP sync — timedatectl timedatectl

Manage System Processes

13 commands

These Linux commands will help you manage the Linux processes, and will help you troubleshoot any server resource related issues. You can use these commands to monitor your server's resource such as Memory, CPU, disk IO etc.

Process snapshots start with ps aux or ps -ef; see the ps command for column selection and sorting. To send SIGTERM or SIGKILL by PID or process name, see kill and pkill.

When to use Command
Display running processes — ps command ps, ps aux
Start process with adjusted priority — examples nice -n 10 command
Change priority of a running process — nice and renice renice -n 15 PID
Real-time system and process monitoring — examples top
Find process IDs by name pgrep process
Send signal to a process by PID kill PID
Kill processes by name — kill and pkill pkill process
Monitor system performance over time sar -u 1 5
Show memory, CPU, and process stats vmstat 1
Monitor disk I/O performance — iostat command iostat -x
Monitor per-process disk I/O — iotop iotop
List open files and sockets by process — lsof lsof -p PID
Schedule jobs with cron — examples crontab -e

Managing Users and Groups

9 commands

These are some of the basic Linux commands to perform user management such as create, modify, delete user or groups.

When to use Command
Create a new user account — useradd command useradd USER
Modify user account (e.g. add to group) usermod OPTIONS USER, usermod -G admin deepak
Delete a user account userdel USER
Set or update password, lock/unlock account — examples passwd USER
Create a new group — groupadd command groupadd GROUP
Delete a group — group examples groupdel GROUP
Rename or modify a group — group examples groupmod -n NEW OLD
Switch user context — su command su - USER
Run commands with elevated privileges — sudo cheat sheet sudo COMMAND

Managing Permissions

10 commands

Linux permission is a very vast topic and here I have only covered the basic commands which we use to assign/modify/remove permissions to files and directories.

When to use Command
Change file owner and group chown USER:GROUP FILE, chown deepak:admin /tmp/file
Change file permissions (symbolic or octal) chmod PERM PATH, chmod 755 /tmp/dir1
Change group ownership chgrp GROUP FILE, chgrp admin /tmp/file
Show groups of a user groups USER, groups deepak
Change current primary group newgrp GROUP, id
Set ACL permissions — Linux ACL examples setfacl -m u:user:perm FILE, setfacl -m u:deepak:rx /tmp/file
View ACL permissions — Linux ACL examples getfacl FILE
Change file attributes (e.g. immutable) — chattr command chattr +i FILE
View file attributes set by chattrchattr command lsattr FILE
Show or set default permission mask for new files umask

Configure and Troubleshoot Network

13 commands

This section will help Network engineers who are new to Linux environment. I have tried to place the most used commands for network troubleshooting, we also have tcpdump, iperf, netperf and many other networking tools which are used for troubleshooting network related issues but they can get complicated hence those are not mentioned in this list.

ICMP reachability checks use ping; see the ping command for -c, deadlines, and reading packet loss.

When to use Command
Legacy tool to display network interfaces (prefer ip) ifconfig
Manage interfaces, routes, and neighbors — ip command ip
Legacy routing table (prefer ip route) route
Display or set system hostname hostname
Display and modify NIC settings ethtool DEVICE, ethtool -i eth0
Test network connectivity — ping command ping HOST, ping 192.168.0.100
Trace route to destination host traceroute HOST, traceroute 192.168.0.100
DNS lookup and zone transfer tests — dig and host dig example.com
Scan open ports and services nmap HOST
Show network connections and ports (legacy; prefer ss) — netstat netstat, netstat -tunlp
Manage NetworkManager from CLI — nmcli examples nmcli
Text UI for NetworkManager — bridge setup nmtui
Display socket statistics (modern netstat replacement) — ss command ss, ss -tunlp

Managing Partitions and Logical Volumes

29 commands

One of the primary roles of system administrator would be to configure partitions, storage layouts in the Linux server. Here you can get the list of most used Linux commands for managing partitions and file systems.

When to use Command
Show disk space usage of mounted filesystems df
Manage disk partitions (MBR/GPT) — example fdisk DEVICE
Interactive partition table editor cfdisk DEVICE
Advanced partition management (GPT/MS-DOS) — parted command parted
Create LVM physical volume — LVM recovery pvcreate DEVICE
Create a volume group — vgcreate command vgcreate VG PV
Activate or deactivate volume groups — LVM recovery vgchange -ay
Create a logical volume — lvcreate command lvcreate -L 1G -n lv vg
Show physical volume details pvdisplay DEVICE
Display summary of physical volumes pvs
Show volume group details vgdisplay
Display summary of volume groups vgs
Show logical volume details lvdisplay
Display summary of logical volumes lvs
Scan and detect physical volumes — fix unknown PV pvscan
Scan and detect volume groups vgscan
Scan and detect logical volumes lvscan
Check and repair ext filesystems — rescue mode e2fsck DEVICE
Modify ext filesystem parameters — force fsck on boot tune2fs DEVICE
Show ext filesystem metadata and superblock dumpe2fs DEVICE
Create filesystem on device — LVM example mkfs.ext4, mkfs.xfs
Extend logical volume size — resize root LVM lvextend OPTIONS
Resize ext filesystem after LV grow — extend partition resize2fs DEVICE
Add physical volume to volume group — move directory vgextend VG PV
Mount a filesystem — mount command mount DEVICE MOUNTPOINT
Attach a file as a loop device — losetup losetup -f FILE
List SCSI devices lsscsi
Show block devices and hierarchy lsblk
Display UUID of block devices blkid

Managing RPM and Software Repositories

14 commands

With package manager such as yum, dnf, apt-get, the life of a system administrator becomes very easy. You can easily install, update, remove packages, upgrade server operating system and much more using these commands.

Low-level .rpm work uses rpm -ivh and rpm -qa; see the rpm command before reaching for dnf or yum.

When to use Command
Install, query, and manage RPM packages — rpm command rpm -ivh pkg.rpm, rpm -qa
Legacy RPM package manager (replaced by dnf) — examples yum install pkg
Modern package manager for RPM systems — dnf command dnf install pkg
Download RPM packages without installing — examples yumdownloader pkg
Package manager for SUSE-based systems zypper install pkg
Package manager for Debian/Ubuntu systems — apt command apt-get install pkg
Search packages from local APT cache apt-cache search pkg
Install and manage Debian packages — dpkg command dpkg -i pkg.deb
Create repository metadata from .deb files dpkg-scanpackages dir
Create YUM/DNF repository metadata — examples createrepo /repo
Query package metadata from enabled repos — examples repoquery pkg
Download a package and dependencies — examples repotrack pkg
Sync remote repository locally — offline mirror reposync
Manage RHEL subscriptions and repos — offline mirror subscription-manager status

Manage Logging

3 commands

Now you know about most of the Linux commands to manager different areas of Linux server but you must be familiar of how logging works in Linux? This may vary based on different distribution, with old distros we used syslog-ng for logging but now almost all major distros have moved to rsyslog solution.

When to use Command
Write messages to system logs — journald on RHEL 7 logger "message"
Rotate and compress log files — journald on RHEL 7 logrotate -f /etc/logrotate.conf
View and filter systemd journal logs — journalctl examples journalctl, journalctl -xe

Conclusion

In this cheat sheet tutorial I have tried to consolidate most used Linux commands by different types of experts across IT domains. I am yet to add commands for many other scenarios such as Managing Linux services, archiving, firewall etc but that would just make this tutorial infinite long. I may write another article based on the response I get on this one, even writers need motivation. So that I know people are reading and loving this cheat sheet then I may decide to spend some more time to write about the remaining Linux commands in another tutorial.

Looking forward for your feedback in the comment section.

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …