Master Essential Linux Commands: A Complete Cheat Sheet for System Operations
This comprehensive guide lists the most commonly used Linux commands—such as cd, ls, cp, mv, rm, grep, tar, and many others—explaining their purpose, key options, and providing practical examples so readers can efficiently manage files, processes, networking, and system tasks from the command line.
Linux Command Cheat Sheet
Table of Contents
Preface
1. cd command
2. pwd command
3. ls command
4. cp command
5. mv command
6. rm command
7. cat command
8. find command
9. chmod command
10. chown command
11. chgrp command
12. grep command
13. paste command
14. sort command
15. comm command
16. tar command
17. jps command
18. kill command
19. killall command
20. System shutdown/reboot
21. top command
22. touch command
23. mkdir command
24. ps command
25. ping command
26. ifconfig command
27. Redirection operators
28. Pipe operator
29. cut command
Other useful commands
Summary
Preface
Linux common commands are tools widely used in the Linux operating system to manage files, directories, processes, network communication, software installation, and more. Mastering these commands improves efficiency when working with Linux.
1. cd command
The cd command changes the current working directory to the specified path.
cd .. # Return to parent directory
cd ../.. # Return two levels up
cd ~ # Go to the home directory
cd - # Return to the previous directory2. pwd command
The pwd command displays the full path of the current working directory.
3. ls command
The ls command lists files and directories in the specified location.
ls # List files in current directory
ls -l (ll) # Detailed list with permissions
ls -a # Include hidden files
ls -R # Recursively list subdirectories
ls [0-9] # Show files containing numbers in their names4. cp command
The cp command copies files or directories.
-a # Preserve attributes
-p # Preserve mode, ownership, timestamps (useful for backup)
-i # Prompt before overwriting
-r # Recursively copy directories
-u # Copy only when source is newer than destination5. mv command
The mv command moves or renames files or directories.
-f # Force overwrite without prompting
-i # Prompt before overwriting
-u # Overwrite only if source is newer6. rm command
The rm command deletes files or directories.
-f # Ignore nonexistent files, never prompt
-i # Prompt before each removal
-r # Recursively delete directories7. cat command
The cat command displays file contents and can concatenate files.
cat file1 # Show file from start
tac file1 # Show file in reverse order
cat -n file1 # Number lines
more file1 # Paginated view
head -n 2 file1 # First two lines
tail -n 2 file1 # Last two lines8. find command
The find command searches for files and directories based on criteria.
find / -name file1 # Search from root
find / -user user1 # Files owned by user1
find /usr/bin -type f -atime +100 # Executables not accessed in 100 days
find /usr/bin -type f -mtime -10 # Files modified within last 10 days9. chmod command
The chmod command changes file or directory permissions.
chmod ugo+rwx directory1 # Grant read/write/execute to all
chmod go-rwx directory1 # Remove permissions from group and others10. chown command
The chown command changes file ownership.
chown user1 file1 # Change owner
chown -R user1 directory1 # Recursively change owner
chown user1:group1 file1 # Change owner and group11. chgrp command
The chgrp command changes the group ownership of a file.
chgrp group1 file112. grep command
The grep command searches for patterns within files.
grep keyword file.txt # Find lines containing keyword
grep ^Aug /var/log/messages # Lines starting with "Aug"
grep [0-9] /var/log/messages # Lines containing numbers13. paste command
The paste command merges lines of files side by side.
paste file1 file2 # Merge two files
paste -d '+' file1 file2 # Use '+' as delimiter14. sort command
The sort command orders lines of text.
sort file1 # Sort file alphabetically
sort -r file1 # Reverse order
sort -n file1 # Numeric sort
sort -u file1 # Unique lines only15. comm command
The comm command compares two sorted files.
comm -1 file1 file2 # Lines only in file1
comm -2 file1 file2 # Lines only in file2
comm -3 file1 file2 # Lines common to both16. tar command
The tar command creates and extracts archive files.
-c # Create archive
-t # List contents
-x # Extract archive
-j # Use bzip2 compression
-z # Use gzip compression
-v # Verbose output
-f filename # Specify archive file
-C dir # Change to directory before operation16-1 Parameter Overview
-c : create archive
-t : list archive contents
-x : extract archive
-j : bzip2 compression
-z : gzip compression
-v : verbose
-f filename : archive name
-C dir : target directory16-2 tar.bz2 format
tar -jcvf archive.tar.bz2 source # Compress with bzip2
tar -jtvf archive.tar.bz2 # List contents
tar -jxvf archive.tar.bz2 -C /dest # Extract16-3 tar.gz format
tar -zcvf archive.tar.gz source # Compress with gzip
tar -zxvf archive.tar.gz -C /dest # Extract16-4 tar (no compression)
tar -cvf archive.tar source # Create plain tar archive
tar -xvf archive.tar -C /dest # Extract16-5 zip format
zip -r archive.zip source # Create zip archive
unzip archive.zip # Extract zip archive16-6 Other related commands
bzip2 file1 # Compress with bzip2
bunzip2 file1.bz2 # Decompress bzip2 file
gzip file1 # Compress with gzip
gunzip file1.gz # Decompress gzip file
rar a file1.rar source # Create rar archive
rar x file1.rar # Extract rar archive17. jps command
The jps tool lists Java processes.
jps -l # Full class name
jps -m # Show main class and arguments18. kill command
The kill command sends signals to processes.
kill [signal] PID # Send signal (default SIGTERM)
SIGKILL # Force termination
SIGTERM # Graceful termination19. killall command
The killall command terminates processes by name.
killall process_name20. System shutdown/reboot
shutdown -h now # Halt now
shutdown -r now # Reboot now
reboot # Reboot
logout # Log out21. top command
The top command displays real‑time system resource usage.
22. touch command
The touch command creates empty files or updates timestamps.
23. mkdir command
The mkdir command creates new directories.
24. ps command
The ps command lists running processes.
25. ping command
The ping command tests network connectivity.
26. ifconfig command
The ifconfig command shows network interface configuration.
27. Redirection operators
Use > to redirect output to a file, >> to append, and < to use a file as input.
28. Pipe operator
The | symbol passes the output of one command as input to another, enabling command chaining.
29. cut command
The cut command extracts sections from each line of input.
cut -c 1,3 file.txt # Characters 1 and 3
cut -d ':' -f 2,4 file.txt # Fields 2 and 4 using ':' as delimiter
cut -c 1,3 --complement file.txt # All but characters 1 and 3Other useful commands
wc -l file # Count lines in a file
more file # View file page by page
sudo -i # Switch to root shell without repeated password prompts
Summary
Common options such as -a (all), -f (force), -i (interactive), and -r (recursive) apply across many commands, providing flexible control over file and process operations.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
