Linux Commands Every Developer Must Know

Why Every Developer Needs Linux Skills

Linux runs the internet. Over 96% of the world’s top web servers run Linux. Every Docker container, every Kubernetes cluster, every cloud VM, and every CI/CD pipeline operates on a Linux kernel. Even if you develop on macOS or Windows, your code almost certainly runs on Linux in production. These 50 commands, organized by category, are the ones you’ll use every single day.

File and Directory Operations

These are the foundation. You’ll type these commands hundreds of times per day.

# 1. ls - List directory contents
ls -la              # Long format, show hidden files
ls -lhS             # Sort by size, human-readable
ls -lt              # Sort by modification time

# 2. cd - Change directory
cd /var/log         # Absolute path
cd ../config        # Relative path
cd ~                # Home directory
cd -                # Previous directory

# 3. pwd - Print working directory
pwd                 # Shows /home/anurag/projects

# 4. mkdir - Create directories
mkdir -p app/src/components   # Create nested directories

# 5. cp - Copy files and directories
cp file.txt backup.txt
cp -r src/ src-backup/       # Copy directory recursively

# 6. mv - Move or rename
mv old-name.js new-name.js
mv file.txt /tmp/            # Move to another location

# 7. rm - Remove files
rm file.txt
rm -rf node_modules/         # Remove directory recursively (use with caution!)

# 8. touch - Create empty file or update timestamp
touch newfile.txt
touch -t 202604121600 file.txt  # Set specific timestamp

# 9. ln - Create links
ln -s /usr/bin/python3 /usr/local/bin/python  # Symbolic link

# 10. find - Search for files
find . -name "*.py" -type f                    # Find Python files
find /var/log -mtime -7 -name "*.log"          # Modified in last 7 days
find . -size +100M                             # Files larger than 100MB
find . -name "*.tmp" -exec rm {} \;            # Find and delete

Text Processing and Viewing

Reading, searching, and transforming text is where the command line truly shines.

ADVERTISEMENT
# 11. cat - Display file contents
cat config.yaml
cat file1.txt file2.txt > merged.txt    # Concatenate files

# 12. less - Paginated file viewer
less /var/log/syslog          # Navigate with j/k, search with /

# 13. head / tail - View start or end of files
head -n 20 app.log            # First 20 lines
tail -n 50 app.log            # Last 50 lines
tail -f app.log               # Follow live output (streaming logs)

# 14. grep - Search text with patterns
grep -r "TODO" src/                    # Recursive search in directory
grep -n "error" app.log                # Show line numbers
grep -i "warning" app.log              # Case insensitive
grep -c "404" access.log               # Count matches
grep -v "DEBUG" app.log                # Invert match (exclude DEBUG)

# 15. awk - Column-based text processing
awk '{print $1, $4}' access.log        # Print columns 1 and 4
awk -F: '{print $1}' /etc/passwd       # Custom delimiter
df -h | awk '$5 > "80%" {print $0}'    # Disks over 80% usage

# 16. sed - Stream editor for text transformation
sed 's/old/new/g' file.txt                     # Replace all occurrences
sed -i 's/localhost/0.0.0.0/g' config.yaml     # In-place edit
sed -n '10,20p' file.txt                       # Print lines 10-20

# 17. sort and uniq - Sort and deduplicate
sort access.log | uniq -c | sort -rn | head    # Top repeated lines
cat urls.txt | sort -u                          # Sort and deduplicate

# 18. wc - Word, line, and byte count
wc -l src/**/*.py             # Count lines of Python code
find . -name "*.js" | wc -l   # Count JavaScript files

# 19. cut - Extract columns from text
cut -d',' -f1,3 data.csv      # Extract columns 1 and 3 from CSV
echo $PATH | cut -d: -f1-3    # First 3 PATH entries

# 20. diff - Compare files
diff file1.txt file2.txt
diff -u old.conf new.conf     # Unified format (like git diff)

Process Management

Knowing how to inspect and control running processes is essential for debugging production issues.

# 21. ps - List processes
ps aux                          # All processes with details
ps aux | grep node              # Find Node.js processes

# 22. top / htop - Real-time process monitor
top -o %MEM                     # Sort by memory usage
htop                            # Interactive process viewer (install: apt install htop)

# 23. kill - Terminate processes
kill 12345                      # Graceful termination (SIGTERM)
kill -9 12345                   # Force kill (SIGKILL)
killall node                    # Kill all processes by name

# 24. bg / fg / jobs - Job control
Ctrl+Z                          # Suspend current process
bg                              # Resume in background
fg                              # Bring to foreground
jobs                            # List background jobs

# 25. nohup - Run process that survives logout
nohup python server.py &        # Run in background, persist after logout

# 26. systemctl - Manage systemd services
sudo systemctl start nginx
sudo systemctl enable nginx     # Start on boot
sudo systemctl status nginx
sudo systemctl restart nginx
journalctl -u nginx -f          # Stream service logs

Networking

Debugging network issues from the command line is a critical skill for any developer working with APIs, microservices, or deployments.

# 27. curl - Transfer data from URLs
curl https://api.example.com/users               # GET request
curl -X POST -H "Content-Type: application/json" \
  -d '{"name":"Anurag"}' https://api.example.com/users
curl -o file.zip https://example.com/file.zip     # Download file
curl -I https://example.com                        # Headers only

# 28. wget - Download files
wget https://example.com/dataset.csv
wget -r -np https://example.com/docs/             # Recursive download

# 29. ssh - Secure shell
ssh user@192.168.1.100
ssh -i ~/.ssh/mykey.pem ubuntu@ec2-instance
ssh -L 8080:localhost:3000 user@server             # Port forwarding

# 30. scp - Secure copy over SSH
scp file.txt user@server:/home/user/
scp -r ./dist/ user@server:/var/www/html/

# 31. netstat / ss - Network statistics
ss -tulnp                       # Show listening ports with process info
ss -s                           # Summary statistics

# 32. ping - Test connectivity
ping -c 4 google.com            # Send 4 packets

# 33. dig / nslookup - DNS lookup
dig byteyogi.com
dig +short byteyogi.com A       # Just the IP address

# 34. ip - Network interface configuration
ip addr show                    # Show all interfaces and IPs
ip route show                   # Show routing table

Disk and Storage

# 35. df - Disk space usage
df -h                           # Human-readable format

# 36. du - Directory size
du -sh /var/log                 # Total size of directory
du -sh * | sort -rh | head -10  # Top 10 largest items in current dir

# 37. mount - Mount filesystems
mount | grep sda                # Show mounted partitions
sudo mount /dev/sdb1 /mnt/data

# 38. lsblk - List block devices
lsblk                          # Show disk layout and partitions

Permissions and Users

# 39. chmod - Change file permissions
chmod 755 script.sh             # rwxr-xr-x
chmod +x deploy.sh              # Add execute permission
chmod -R 644 public/            # Recursive permission change

# 40. chown - Change file ownership
sudo chown www-data:www-data /var/www/html -R

# 41. whoami / id - Current user info
whoami                          # anurag
id                              # uid, gid, groups

# 42. sudo - Execute as superuser
sudo apt update
sudo -u postgres psql           # Run as a different user

Compression and Archives

# 43. tar - Archive files
tar -czf backup.tar.gz ./project/            # Create gzipped archive
tar -xzf backup.tar.gz                       # Extract gzipped archive
tar -xzf backup.tar.gz -C /opt/              # Extract to specific directory

# 44. zip / unzip
zip -r project.zip ./project/
unzip project.zip -d ./extracted/

System Information and Utilities

# 45. uname - System information
uname -a                        # Full system info
cat /etc/os-release             # OS version details

# 46. uptime - System uptime and load
uptime                          # 16:00 up 45 days, load average: 0.52, 0.48, 0.43

# 47. free - Memory usage
free -h                         # Human-readable memory info

# 48. env / export - Environment variables
env                             # Show all environment variables
export NODE_ENV=production
echo $PATH

# 49. crontab - Schedule recurring tasks
crontab -e                      # Edit cron jobs
# Run backup every day at 2 AM:
# 0 2 * * * /home/anurag/scripts/backup.sh >> /var/log/backup.log 2>&1

# 50. xargs - Build and execute commands from stdin
find . -name "*.log" | xargs rm                    # Delete all .log files
cat urls.txt | xargs -I {} curl -s -o /dev/null -w "%{http_code} {}\n" {}
echo "file1 file2 file3" | xargs -n 1 gzip        # Compress each file

Piping It All Together

The real power of Linux commands comes from combining them with pipes (|). Here are some practical one-liners:

# Find the 10 largest files in a directory tree
find /var -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10

# Monitor a log file for errors in real time
tail -f /var/log/app.log | grep --line-buffered "ERROR"

# Count unique IP addresses in an access log
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

# Kill all zombie processes
ps aux | awk '$8 ~ /Z/ {print $2}' | xargs -r kill -9

# Disk usage breakdown of current directory, sorted
du -sh */ 2>/dev/null | sort -rh

Conclusion

These 50 commands cover the vast majority of what you’ll do on a Linux system: navigating files, processing text, managing processes, debugging networks, and administering servers. The key to mastery is not memorizing flags but building muscle memory through daily use. Start a terminal-first workflow, SSH into servers instead of using web consoles, and pipe commands together to solve real problems. Once these become second nature, you’ll be dramatically faster at debugging, deploying, and managing any software system.

ADVERTISEMENT

Leave a Comment

Your email address will not be published. Required fields are marked with an asterisk.