Top 20 Linux Commands Cheat Sheet

2nd August 2026

🐧 Top 20 Linux Commands

Practical Syntax, Examples & Expected Output

1. pwd – Print Working Directory

Purpose: Displays the full path of your current directory.

Syntax
pwd
Example
pwd
Output
/home/ram
Use Case

Verify your current location before creating, deleting, or moving files.

2. ls – List Files and Directories

Purpose: Shows the contents of a directory.

Syntax
ls [options]
Common Options
Option Description
-l Long listing format
-a Show hidden files
-h Human-readable file sizes
-t Sort by modification time
Example
ls -lah
Output
drwxr-xr-x Documents
-rw-r--r-- notes.txt
-rwxr-xr-x script.sh

3. cd – Change Directory

Purpose: Move from one directory to another.

Action Command
Go to Home cd
Specific Directory cd /var/log
One Level Up cd ..
Previous Directory cd -

4. mkdir – Create Directory

Purpose: Creates new directories.

mkdir project
                                    
                                    mkdir -p project/src/images
Result
project/
                                    └── src/
                                        └── images/

5. rm – Remove Files

rm file.txt
                                    rm -r project
                                    rm -rf project
Warning: rm -rf permanently deletes files and directories.

6. cp – Copy Files

mv report.pdf backup.pdf
                                    
                                    cp -r website backup/

7. mv – Move or Rename Files

mv old.txt new.txt
                                    
                                    mv report.pdf /home/ram/Documents/

8. cat – Display File Contents

cat notes.txt
                                    
                                    cat > hello.txt
                                    Hello Linux
                                    Ctrl + D

9. grep – Search Text

grep "error" logfile.log
                                    
                                    grep -i "warning" logfile.log
                                    
                                    grep -r "password" /etc

10. find – Find Files

find /home -name "*.pdf"
                                    
                                    find . -empty
                                    
                                    find . -mtime -7

11. chmod – Change Permissions

chmod +x install.sh
                                    
                                    chmod 755 script.sh
Permission Meaning
7 rwx
5 r-x
4 r--

12. chown – Change Ownership

sudo chown ram file.txt
                                    
                                    sudo chown ram:developers project/
                                    
                                    sudo chown -R apache:apache /var/www/html

13. df – Disk Space

df -h
Filesystem Size Used Avail Use%
/dev/sda1 100G 62G 38G 62%

14. du – Directory Size

du -sh Downloads
                                    
                                    du -sh * | sort -h

15. ps – Running Processes

ps -ef
                                    
                                    ps -ef | grep httpd
root 1523 httpd
apache 1534 httpd

16. top – Process Monitor

top
Shows
  • CPU Usage
  • RAM Usage
  • Running Processes
  • Load Average
  • Uptime
Useful Keys
Key Action
P Sort by CPU
M Sort by Memory
k Kill Process
q Quit

17. kill – Stop Process

kill 2345
                                    
                                    kill -9 2345
                                    
                                    pkill firefox

18. systemctl – Manage Services

sudo systemctl start nginx
                                    
                                    sudo systemctl stop nginx
                                    
                                    sudo systemctl restart nginx
                                    
                                    systemctl status nginx
                                    
                                    sudo systemctl enable nginx

19. tar – Archive Files

tar -cvf backup.tar project/
                                    
                                    tar -czvf backup.tar.gz project/
                                    
                                    tar -xzvf backup.tar.gz

20. ssh – Remote Login

ssh user@192.168.1.20
                                    
                                    ssh -p 2222 user@example.com
                                    
                                    ssh -i ~/.ssh/id_rsa user@example.com