Mastering the Linux command line starts with a handful of essential commands. This guide covers 25 must-know commands, each with a clear, practical example. By the end, you'll feel comfortable navigating, managing files, and controlling your system from the terminal.
1. pwd – Print Working Directory
Shows you the full path of the directory you’re currently in. Never get lost again.
pwd/home/john/Documents2. ls – List Directory Contents
Lists files and folders in the current (or specified) directory. Use flags for details.
ls -latotal 32drwxr-xr-x 2 john john 4096 Mar 15 10:23 .
drwxr-xr-x 18 john john 4096 Mar 15 10:22 ..
-rw-r--r-- 1 john john 220 Mar 15 10:23 notes.txt
-l shows detailed info (permissions, size, date), -a includes hidden files.3. cd – Change Directory
Navigates between folders.
cd /var/log(no output – changes directory)cd .. goes up one level, cd ~ or just cd takes you home.4. mkdir – Make Directory
Creates a new folder. Add -p to create parent directories automatically.
mkdir -p projects/linux-basics(creates both "projects" and "linux-basics" if they don't exist)5. rmdir & rm – Remove Directory & Files
rmdir removes empty directories; rm removes files (or directories with -r).
rm -rf old-project/(deletes folder and everything inside – be careful!)-r flag is recursive, -f forces deletion without asking. Always double-check before using -rf.6. cp – Copy Files & Directories
Duplicates files. Use -r for folders.
cp -r source/ destination/(copies all contents from source to destination folder)7. mv – Move or Rename Files
Relocates files or renames them.
mv oldname.txt newname.txt(renames the file)mv file.txt /target/folder/8. touch – Create Empty File or Update Timestamps
Quickly creates a blank file or updates the modification time of an existing file.
touch newfile.txt(creates newfile.txt if it doesn't exist)9. cat – Concatenate & Display File Content
Displays the entire contents of a file on the screen.
cat /etc/os-releaseNAME="Ubuntu"VERSION="22.04 LTS"
10. less & more – View Large Files Page by Page
Both let you scroll through big files, but less is more powerful (scroll up, search).
less /var/log/syslog(opens the log file; press q to quit, / to search)11. head & tail – View Beginning or End of Files
head shows the first 10 lines (default), tail the last 10. Essential for logs.
tail -n 20 /var/log/syslog(last 20 lines of syslog)tail -f to follow a log file in real time (very handy).12. grep – Search Text Patterns
Searches inside files for a pattern and prints matching lines.
grep "error" /var/log/syslogMar 15 10:45:43 server kernel: [UFW BLOCK] error ...-i for case-insensitive search, -r to search recursively in folders.13. find – Search for Files & Directories
Locates files based on name, type, size, and more.
find . -name "*.jpg" -type f./images/photo.jpg./backup/pic.jpg
-type f restricts results to files only.14. man – Manual Pages
Displays the built‑in manual for any command. Your best teacher.
man ls(opens the manual for 'ls'; press q to quit)15. --help – Quick Command Help
Most commands support the --help flag for a fast summary of options.
ls --helpUsage: ls [OPTION]... [FILE]...List information about the FILEs...
16. sudo – Super User Do
Run commands with administrative (root) privileges.
sudo apt update(asks for your password, then updates package lists)sudo, especially with destructive commands.17. chmod – Change File Permissions
Adjusts who can read, write, or execute a file.
chmod +x script.sh(makes script.sh executable)chmod 755 file gives rwx to owner, rx to group and others.18. chown – Change File Owner & Group
Transfers ownership of a file to another user/group.
sudo chown john:devs report.txt(john becomes owner, group set to devs)19. ps – Process Status
Lists running processes. The most common flags: aux (BSD style) or -ef (Unix style).
ps aux | grep nginxroot 1234 0.0 0.1 55248 6789 ? Ss 10:12 0:00 nginx: master process20. kill – Terminate Processes
Sends a signal to a process (usually to stop it).
kill -9 1234(forcefully kills process with PID 1234)kill -l to list signal names. -15 (SIGTERM) asks nicely; -9 (SIGKILL) is immediate.21. top & htop – Real‑time System Monitor
top is built‑in; htop is a more user‑friendly version (install with sudo apt install htop).
top(live view of CPU, memory, and process list; q to quit)22. df & du – Disk Space Usage
df reports filesystem disk usage; du shows directory sizes.
df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 100G 45G 55G 45% /
-h makes output human‑readable. To check a folder size: du -sh /home/user/23. free – Memory Usage
Displays total, used, and free RAM plus swap.
free -htotal used free shared buff/cache availableMem: 7.7Gi 2.1Gi 3.2Gi 234Mi 2.3Gi 5.0Gi
24. ping – Test Network Connectivity
Sends ICMP packets to check if a host is reachable. Press Ctrl+C to stop.
ping -c 4 google.comPING google.com (142.250.190.46) 56(84) bytes of data.64 bytes from ... time=12.3 ms
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss
-c 4 sends exactly 4 packets and stops.25. ssh – Secure Shell Remote Connection
Connects to a remote Linux server securely.
ssh user@192.168.1.100(prompts for password, then opens a remote shell)-p to specify a port (default is 22). For key‑based auth: ssh -i mykey.pem user@hostFound this helpful? Share it with a friend who's starting their Linux journey. And stay tuned for our next deep dive into shell scripting basics.
