Linux commands are fundamental for system administration, cloud computing, DevOps, cybersecurity, networking and IT troubleshooting.
Learn 50 commands covering files, permissions, processes, networking, SSH, archives, packages, services and logs.
Practice commands in a safe Linux environment and learn how to combine them using pipes and redirection.
pwd — Print Working Directory
The pwd command displays the directory you are
currently working in.
pwd
Example output:
/home/user/projects
ls — List Files and Directories
Use ls to view files and directories.
ls
ls -l
ls -la
ls -lah
The -l option displays detailed information,
while -a includes hidden files and
-h displays sizes in a human-readable format.
cd — Change Directory
The cd command moves you between directories.
cd /var/log
cd ~
cd ..
cd -
mkdir — Create a Directory
mkdir projects
mkdir -p projects/linux/scripts
The -p option creates parent directories when
they don't already exist.
touch — Create a File
touch notes.txt
touch file1.txt file2.txt file3.txt
cp — Copy Files and Directories
cp notes.txt backup.txt
cp -r projects projects-backup
mv — Move or Rename Files
mv report.txt /home/user/documents/
mv oldname.txt newname.txt
The same command can be used to move a file or rename it.
rm — Remove Files
rm oldfile.txt
rm -r old-directory
rm. Files removed from
the command line may not be recoverable through the normal
desktop trash.
rmdir — Remove Empty Directories
rmdir old-folder
cat — Display File Contents
cat notes.txt
For large files, use less instead.
less — Read Files Page by Page
less logfile.txt
Press q to exit.
head — Display the Beginning of a File
head file.txt
head -n 20 file.txt
tail — Display the End of a File
tail file.txt
tail -f /var/log/syslog
The -f option is useful for monitoring logs as
new entries are written.
grep — Search Text
grep "error" application.log
grep -i "error" application.log
grep -r "database" /var/www/
grep is one of the most useful Linux commands
for searching logs and configuration files.
find — Find Files
find /home/user -name "report.txt"
find /var/log -name "*.log"
find /home -type f -size +100M
locate — Quickly Locate Files
locate report.txt
locate searches an indexed database of filenames.
wc — Count Lines, Words and Characters
wc -l file.txt
wc -w file.txt
wc -c file.txt
sort — Sort Text
sort names.txt
sort -n numbers.txt
uniq — Handle Duplicate Lines
sort names.txt | uniq
sort names.txt | uniq -c
cut — Extract Text
cut -d: -f1 /etc/passwd
echo — Display Text
echo "Hello Linux"
echo $HOME
echo "Linux is powerful" > notes.txt
echo "Another line" >> notes.txt
nano — Edit Text Files
nano notes.txt
man — Read Command Documentation
man ls
man chmod
man systemctl
history — View Previous Commands
history
history | grep docker
clear — Clear the Terminal
clear
You can also commonly use Ctrl + L.
whoami — Show Current User
whoami
id — Display User and Group Information
id
sudo — Run Commands With Elevated Privileges
sudo apt update
Use elevated privileges only when they are required.
chmod — Change File Permissions
chmod 755 script.sh
chmod +x script.sh
chown — Change File Ownership
sudo chown user:user file.txt
sudo chown -R user:user project/
ps — View Running Processes
ps
ps aux
ps aux | grep nginx
top — Monitor Processes
top
Useful for investigating CPU and memory consumption.
kill — Terminate a Process
kill 1234
kill -9 1234
Use forceful termination carefully because it doesn't allow the process to perform normal cleanup.
df — Check Disk Usage
df -h
du — Check File and Directory Size
du -sh /var/log
du -sh *
df shows filesystem capacity, while
du helps identify what is consuming space.
free — Check Memory Usage
free -h
uname — Display System Information
uname -a
uname -r
hostname — Display the Hostname
hostname
uptime — Check System Uptime
uptime
ip — Manage Network Information
ip addr
ip route
ip link
ping — Test Network Connectivity
ping example.com
ping 8.8.8.8
A failed ping doesn't necessarily mean the destination is completely unreachable because ICMP may be blocked.
ss — Inspect Network Connections
ss -tuln
sudo ss -tulpn
curl — Transfer Data From a URL
curl https://example.com
curl -I https://example.com
curl https://api.example.com/data
wget — Download Files
wget https://example.com/file.zip
ssh — Connect to a Remote System
ssh username@192.168.1.100
ssh -i ~/.ssh/my-key username@server
SSH is fundamental for remote Linux administration and cloud-server management.
tar — Create and Extract Archives
tar -czf backup.tar.gz project/
tar -xzf backup.tar.gz
zip — Create ZIP Archives
zip -r project.zip project/
unzip — Extract ZIP Archives
unzip project.zip
unzip project.zip -d project/
apt — Manage Packages
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo apt remove nginx
The apt package manager is commonly used on
Debian-based distributions such as Ubuntu and Debian.
systemctl and journalctl — Services and Logs
Modern Linux systems using systemd commonly use
systemctl to manage services.
systemctl status nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo journalctl -u nginx
sudo journalctl -u nginx -f
These commands are particularly useful for Linux administration and troubleshooting.
Using Linux Commands for Troubleshooting
The real power of Linux commands comes from combining them to investigate problems.
Find a high-CPU process
top
ps aux --sort=-%cpu | head
Find large files
find / -type f -size +1G 2>/dev/null
Search logs for errors
grep -i "error" application.log
tail -f application.log
Check listening ports
sudo ss -tulpn
Test HTTP connectivity
curl -I https://example.com
Combine Linux Commands With Pipes
A pipe sends the output of one command to another command. This is one of the most important concepts to understand when learning the Linux command line.
ps aux | grep nginx
ss -tuln | grep 443
history | grep docker
cat access.log | grep 404
Once you understand pipes, individual commands become building blocks for more powerful troubleshooting workflows.
Linux Output Redirection
Linux allows command output to be redirected to files.
ls -la > files.txt
echo "New entry" >> notes.txt
The > operator writes output to a file and can
overwrite existing content. The >> operator
appends output to the file.
How to Learn Linux Commands
Don't try to memorize all 50 commands at once. Practice them while completing real tasks.
- Learn navigation and file-management commands.
- Practice permissions and users.
- Learn process-management commands.
- Practice networking commands.
- Learn SSH and remote administration.
- Practice package and service management.
- Use commands together with pipes and redirection.
Learn → Practice → Break something safely → Troubleshoot → Document → Repeat
References
Use official documentation when validating command syntax and distribution-specific behavior.