20 Linux Commands Every Beginner Must Know

Introduction

If you are just starting your journey with Linux, one of the most important skills you need to build is comfort with the command line. The terminal might look scary at first, but once you learn a handful of essential commands, everything starts to make sense.

In this guide, I will walk you through 20 Linux commands every beginner must know — with simple explanations and real examples you can try right now.


1. pwd — Print Working Directory

This command tells you exactly where you are in the file system.

pwd

Output: /home/jahangeer

Always use pwd when you feel lost in the terminal.

2. ls — List Files and Directories

Use ls to see what files and folders are inside your current directory.

ls
ls -l        # detailed list with permissions and size
ls -la       # includes hidden files

3. cd — Change Directory

Navigate between folders using cd.

cd /home/jahangeer       # go to a specific path
cd ..                    # go one level up
cd ~                     # go to home directory
cd -                     # go back to previous directory

4. mkdir — Make Directory

Create a new folder.

mkdir my-folder
mkdir -p parent/child/grandchild    # create nested folders at once

5. rm — Remove Files or Directories

Delete files or folders. Be careful — there is no recycle bin in Linux!

rm filename.txt              # delete a file
rm -r folder-name            # delete a folder and everything inside it
rm -rf folder-name           # force delete without confirmation (use carefully)

6. cp — Copy Files

Copy a file from one location to another.

cp file.txt /home/backup/           # copy file to a folder
cp -r folder/ /home/backup/         # copy entire folder

7. mv — Move or Rename Files

mv is used both to move files and to rename them.

mv file.txt /home/documents/        # move file
mv oldname.txt newname.txt          # rename file

8. cat — View File Contents

Quickly display the contents of a file in the terminal.

cat filename.txt
cat file1.txt file2.txt             # display multiple files

9. less — View Large Files

When a file is too large to display at once, use less to scroll through it.

less /var/log/syslog

Press q to quit.

10. grep — Search Inside Files

grep is one of the most powerful commands. It searches for a specific word or pattern inside files.

grep "error" logfile.txt            # find lines containing "error"
grep -i "error" logfile.txt         # case-insensitive search
grep -r "error" /var/log/           # search recursively in a folder

11. chmod — Change File Permissions

Control who can read, write, or execute a file.

chmod 755 script.sh                 # owner can read/write/execute; others can read/execute
chmod +x script.sh                  # make a file executable

12. chown — Change File Owner

Change who owns a file or directory.

chown jahangeer file.txt            # change owner
chown jahangeer:group file.txt      # change owner and group

13. sudo — Run as Administrator

sudo lets you run commands with administrator (root) privileges.

sudo apt update                     # update package list (Ubuntu/Debian)
sudo systemctl restart nginx        # restart a service

14. apt / yum — Install Software

Install packages depending on your Linux distribution.

# Ubuntu / Debian
sudo apt update
sudo apt install nginx

# CentOS / Amazon Linux
sudo yum install nginx

15. top — Monitor Running Processes

See all running processes and how much CPU and memory they are using in real time.

top

Press q to exit. For a better version, try htop if installed.

16. df — Check Disk Space

Check how much disk space is available on your system.

df -h                               # human-readable format (GB, MB)

17. du — Check Folder Size

Find out how much space a specific folder is using.

du -sh /var/log/                    # size of a specific folder
du -sh *                            # size of all items in current directory

18. ps — View Running Processes

See a snapshot of currently running processes.

ps aux                              # show all running processes
ps aux | grep nginx                 # find a specific process

19. kill — Stop a Process

Stop a running process using its process ID (PID).

kill 1234                           # gracefully stop process with PID 1234
kill -9 1234                        # force kill the process

Find the PID using ps aux | grep processname.

20. ssh — Connect to Remote Server

Connect to a remote Linux server securely.

ssh username@server-ip
ssh -i my-key.pem ec2-user@54.123.45.67     # connect to AWS EC2 instance

Quick Reference Table

CommandWhat It Does
pwdShow current directory
lsList files and folders
cdChange directory
mkdirCreate a new folder
rmDelete files or folders
cpCopy files
mvMove or rename files
catView file contents
lessScroll through large files
grepSearch inside files
chmodChange file permissions
chownChange file owner
sudoRun as administrator
apt/yumInstall software
topMonitor live processes
dfCheck disk space
duCheck folder size
psView running processes
killStop a process
sshConnect to remote server

Conclusion

These 20 commands form the foundation of working with Linux. Whether you are managing a server, working in the cloud, or learning DevOps, you will use these commands every single day.

The best way to learn them is to practice in a real terminal. If you do not have a Linux machine, you can use AWS EC2 (free tier), WSL on Windows, or any online Linux terminal.

Bookmark this page and refer back to it whenever you need a quick reminder. Happy learning!

Leave a Comment

Your email address will not be published. Required fields are marked *