60 Linux Commands You Need to Know
A comprehensive reference guide to 60 essential Linux commands — from file navigation and user management to networking, processes, and system monitoring. Covers syntax, practical examples, and real-world usage patterns.
60 Linux Commands You Need to Know
The Linux command line is one of the most powerful tools in a developer's or sysadmin's toolkit. Whether you're managing a remote server, automating tasks, or just navigating your local machine, fluency with the terminal opens up a level of control that no GUI can match.
This guide covers the 60 essential commands you need — not as a dry reference, but with real examples and the reasoning behind each one.
Navigation
pwd
Print Working Directory. Always know where you are.
pwd
# /home/alice/projectsls
List files and directories. Use flags to reveal more detail.
ls -la # Long format with hidden files
ls -lh # Human-readable file sizescd
Change directory. The most-used command on any system.
cd /var/log # Absolute path
cd .. # Go up one level
cd ~ # Go to home directory
cd - # Go back to previous directoryclear
Clear the terminal screen. Or press Ctrl+L.
clearexit
Log out of the current session or close the terminal.
exithistory
Show all previously entered commands. Pipe with grep to find a specific one.
history
history | grep sshFile and Directory Operations
touch
Create a new empty file. Also updates the timestamp of an existing file.
touch notes.txt
touch index.html style.css app.js # Create multiple at oncemkdir
Make a new directory. Use -p to create nested paths in one command.
mkdir logs
mkdir -p projects/api/src # Creates all parent dirscp
Copy files or directories. Use -r for recursive (directories).
cp file.txt backup.txt
cp -r src/ dist/rm
Remove files or directories. Irreversible — no recycle bin.
rm old_file.txt
rm -rf build/ # Force-remove directory recursively — use with cautionrmdir
Remove an empty directory. Safer than rm -r when you expect it to be empty.
rmdir empty_folderln
Create hard or symbolic (soft) links. Symlinks are like shortcuts; hard links share the same inode.
ln -s /etc/nginx/nginx.conf nginx.conf # Symlink
ln original.txt hardlink.txt # Hard linkfind
Search for files in a directory tree by name, type, size, and more.
find / -name "*.log" -type f
find . -name "config.json"
find /var -mtime -7 # Modified in the last 7 dayszip / unzip
Compress and extract .zip archives.
zip archive.zip file1.txt file2.txt
zip -r project.zip project/ # Recursive
unzip archive.zip
unzip archive.zip -d /tmp/extracted/shred
Securely delete a file by overwriting it before removal. Use when data must not be recoverable.
shred -u -z secret.txt # Overwrite, then removeViewing and Editing Files
cat
Print the full contents of a file to the terminal. Also useful for concatenating files.
cat /etc/hosts
cat file1.txt file2.txt > combined.txtless
View file content one page at a time. Press q to quit, / to search.
less /var/log/sysloghead / tail
View the first or last N lines of a file. tail -f follows live updates — invaluable for log monitoring.
head -n 20 access.log
tail -n 50 error.log
tail -f /var/log/nginx/access.log # Live streamecho
Print text to the terminal or write it to a file.
echo "Hello, World!"
echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrcnano
A beginner-friendly terminal text editor. Keyboard shortcuts are shown at the bottom.
nano config.yamlvim
A powerful modal editor. Steep learning curve, but extremely efficient once learned. Press i to enter insert mode, Esc to return to normal mode, :wq to save and quit.
vim script.shText Processing
grep
Search for patterns in files using regular expressions. One of the most versatile commands available.
grep "error" /var/log/syslog
grep -r "TODO" ./src/ # Recursive search
grep -n "function" app.js # Show line numbers
grep -i "warning" log.txt # Case-insensitiveawk
A full pattern-scanning and text-processing language. Excellent for columnar data.
awk '{print $1}' access.log # Print first column
awk -F: '{print $1}' /etc/passwd # Custom field separator
awk '$3 > 1000 {print $1}' data.txt # Conditional outputsort
Sort lines of text alphabetically or numerically.
sort names.txt
sort -n numbers.txt # Numeric sort
sort -r file.txt # Reverse order
sort -u file.txt # Remove duplicatescmp
Compare two files byte-by-byte. Exits silently if files are identical.
cmp original.bin modified.bindiff
Show line-by-line differences between two text files.
diff old_config.txt new_config.txt
diff -u old.py new.py # Unified format (used in patches)User and Session Management
whoami
Print the current logged-in username.
whoamiuseradd
Low-level command to create a new user account. Does not create a home directory by default.
useradd john
useradd -m -s /bin/bash john # With home dir and shelladduser
Interactive, higher-level alternative to useradd. Prompts for password and details.
adduser alicesu
Switch to another user account within the current terminal.
su alice
su - # Switch to root with its environmentsudo
Run a single command with superuser privileges without fully switching to root.
sudo apt update
sudo systemctl restart nginxpasswd
Change the password for a user account.
passwd # Change your own password
sudo passwd alice # Change another user's passwordfinger
Display information about a user — login name, home directory, shell, and last login.
finger alicePackage Management
apt
The package manager for Debian and Ubuntu-based systems. Handles installation, updates, and removal.
sudo apt update # Refresh package index
sudo apt upgrade # Upgrade all installed packages
sudo apt install nginx # Install a package
sudo apt remove nginx # Remove a package
sudo apt search "text editor" # Search for packagesFile Permissions
chmod
Change file permissions. Use numeric (octal) or symbolic notation.
chmod 755 script.sh # rwxr-xr-x
chmod +x deploy.sh # Add execute permission
chmod -R 644 ./public/ # RecursivePermission quick reference: 4 = read, 2 = write, 1 = execute. Owner / Group / Others.
chown
Change the owner and/or group of a file.
chown alice file.txt
chown alice:developers file.txt
chown -R www-data:www-data /var/www/ # Recursive, common for web serversNetworking
ssh
Securely connect to a remote machine over the network. The backbone of remote server management.
ssh user@192.168.1.10
ssh -p 2222 user@server.com # Custom port
ssh -i ~/.ssh/id_rsa user@server.com # Specific keycurl
Transfer data from a URL. Widely used for testing APIs and downloading files.
curl https://api.example.com/users
curl -X POST -H "Content-Type: application/json" \
-d '{"name":"Alice"}' https://api.example.com/users
curl -O https://example.com/file.tar.gz # Download fileping
Test network connectivity to a host by sending ICMP echo requests.
ping google.com
ping -c 4 192.168.1.1 # Send exactly 4 packetsifconfig
Display or configure network interfaces. Older tool — still widely found on systems.
ifconfig
ifconfig eth0ip address
The modern replacement for ifconfig. Part of the iproute2 suite.
ip address show
ip addr # Short form
ip link showresolvectl status
Query and manage DNS resolution. Shows which DNS servers are in use per interface.
resolvectl statusnetstat
Display network connections, routing tables, and interface statistics.
netstat -tuln # TCP/UDP listening ports
netstat -an | grep ESTABLISHEDss
The modern, faster replacement for netstat. Same flags, better performance.
ss -tuln
ss -s # Summary statisticsiptables
Configure the Linux kernel's packet filtering firewall. Powerful but complex.
sudo iptables -L # List all rules
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPTufw
Uncomplicated Firewall — a user-friendly front-end for iptables.
sudo ufw enable
sudo ufw allow 22
sudo ufw allow 'Nginx HTTPS'
sudo ufw status verboseSystem Information
uname
Print system information — kernel version, OS, architecture.
uname -a # All info
uname -r # Kernel release onlyneofetch
Display system info alongside a stylized ASCII art logo. Popular for screenshots.
neofetchcal
Display a calendar in the terminal.
cal # Current month
cal 2026 # Full year
cal 12 2026 # Specific month and yearfree
Show RAM and swap memory usage.
free -h # Human-readable (GB/MB)
free -s 5 # Refresh every 5 secondsdf
Display disk space usage for all mounted file systems.
df -h # Human-readable
df -h /home # Specific mount pointman
Open the manual page for any command. The most underused command by beginners.
man grep
man ssh
man 5 passwd # Section 5 (file formats)whatis
Print a one-line description of a command — useful when you can't remember what something does.
whatis chmod
whatis grepProcess Management
ps
Show a snapshot of currently running processes.
ps aux # All processes, detailed
ps aux | grep nginx # Find a specific processtop
Real-time, dynamic view of running processes and resource usage. Press q to quit.
tophtop
An interactive, colorful, more user-friendly version of top. Supports mouse input.
htopkill
Send a signal to a process by its PID. SIGKILL (9) forces immediate termination.
kill 1234
kill -9 1234 # Force kill
kill -15 1234 # Graceful termination (SIGTERM, default)pkill
Kill processes by name instead of PID.
pkill nginx
pkill -9 pythonsystemctl
Control systemd services — the init system used by most modern Linux distributions.
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl status nginx
sudo systemctl enable nginx # Start on boot
sudo systemctl disable nginxPower Management
reboot
Restart the system immediately (or scheduled).
sudo rebootshutdown
Shut down or schedule a system shutdown.
sudo shutdown -h now # Halt immediately
sudo shutdown -r +5 # Reboot in 5 minutes
sudo shutdown -c # Cancel a scheduled shutdownQuick Reference Table
| Category | Commands |
|---|---|
| Navigation | pwd, ls, cd, clear, exit, history |
| Files | touch, mkdir, cp, rm, rmdir, ln, find, zip, unzip, shred |
| Viewing / Editing | cat, less, head, tail, echo, nano, vim |
| Text Processing | grep, awk, sort, cmp, diff |
| Users | whoami, useradd, adduser, su, sudo, passwd, finger |
| Packages | apt |
| Permissions | chmod, chown |
| Networking | ssh, curl, ping, ifconfig, ip address, resolvectl, netstat, ss, iptables, ufw |
| System Info | uname, neofetch, cal, free, df, man, whatis |
| Processes | ps, top, htop, kill, pkill, systemctl |
| Power | reboot, shutdown |
Key Takeaways
- Navigation basics (
pwd,ls,cd) are the foundation — know them cold. grep,awk, and pipes are where the terminal becomes genuinely powerful. Combine them freely.manandwhatisare your built-in documentation — reach for them before searching the web.chmodandchownare essential for security. Understand what you're setting before running them.systemctlis how modern Linux manages services — learnstart,stop,enable, andstatus.tail -fon log files is one of the most practical debugging habits you can build.- The best way to retain these commands is to use them daily. Open a terminal, break things, and fix them.