The essential Linux commands every developer needs — file navigation, permissions, grep, awk, sed, process management, cron jobs, and shell scripting basics.
Fluency in the Linux terminal multiplies your productivity as a developer. Whether you're SSH'd into a server, working in CI/CD, or debugging a container, these are the commands you'll use daily.
# Navigation
pwd # print working directory
cd /var/log # absolute path
cd ../.. # two levels up
cd - # go back to previous directory
ls -lah # list all files with human-readable sizes
tree -L 2 # directory tree, 2 levels deep
# File operations
cp -r src/ dst/ # copy directory recursively
mv old.txt new.txt # move/rename
rm -rf dist/ # delete directory (careful!)
mkdir -p a/b/c # create nested directories
touch file.txt # create empty file or update timestamp
# Links
ln -s /actual/path /symlink # create symlink
ls -la | grep "^l" # list symlinks
# Find files
find . -name "*.log" -type f
find . -name "*.ts" -newer package.json
find /var/log -mtime -1 # modified in last 24 hours
find . -size +10M # larger than 10MB
find . -name "node_modules" -prune -o -name "*.ts" -print # exclude dir
# grep — search for patterns
grep "error" app.log
grep -r "TODO" src/ # recursive
grep -rn "deprecated" src/ # with line numbers
grep -v "DEBUG" app.log # invert — lines NOT matching
grep -E "error|warning" app.log # extended regex
grep -c "404" access.log # count matching lines
grep -l "TODO" src/**/*.ts # only print filenames
# Find process using a port
grep -r "localhost:3000" ./
# awk — field processing
awk '{print $1, $3}' access.log # print columns 1 and 3
awk -F',' '{print $2}' data.csv # CSV — use comma delimiter
awk '{sum += $5} END {print sum}' log # sum column 5
awk 'NR>1 && $3 > 100 {print $0}' f # filter: skip header, col3 > 100
# sed — stream editor
sed 's/foo/bar/g' file.txt # replace foo with bar
sed 's/foo/bar/g' file.txt > new.txt # save to new file
sed -i 's/foo/bar/g' file.txt # in-place edit
sed -i.bak 's/foo/bar/g' file.txt # in-place with backup
sed '/^#/d' config.txt # delete comment lines
sed -n '10,20p' file.txt # print lines 10-20
# View files
cat file.txt # print entire file
less file.txt # paginated (q to quit, / to search)
head -20 file.txt # first 20 lines
tail -50 file.txt # last 50 lines
tail -f app.log # follow (live updates)
tail -f app.log | grep ERROR # follow + filter
# Count
wc -l file.txt # count lines
wc -w file.txt # count words
# Sort and deduplicate
sort file.txt
sort -r file.txt # reverse
sort -n numbers.txt # numeric sort
sort file.txt | uniq # remove duplicate lines
sort file.txt | uniq -c # count occurrences
# Pipe combinations
cat access.log | grep "404" | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
# → top 20 404 URLs
# Permission format: -rwxr-xr-x
# [type][owner][group][others]
# r=4, w=2, x=1
chmod 755 script.sh # rwxr-xr-x
chmod 644 config.txt # rw-r--r--
chmod +x script.sh # add execute for all
chmod -R 755 public/ # recursive
chown user:group file.txt # change owner and group
chown -R www-data:www-data /var/www/
# Common permissions
# 777 → everyone can do everything (dangerous)
# 755 → owner: all; others: read+execute (directories, scripts)
# 644 → owner: read+write; others: read only (config files)
# 600 → owner only (private keys: ~/.ssh/id_rsa)
# Secure SSH key (required by SSH)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
# List processes
ps aux # all processes
ps aux | grep node # filter
top # interactive process monitor
htop # better top (install separately)
# Find and kill
kill 12345 # SIGTERM (graceful)
kill -9 12345 # SIGKILL (force)
pkill node # kill by name
killall node
# Find what's using a port
lsof -i :3000
ss -tulpn | grep :3000
fuser 3000/tcp
# Background jobs
command & # run in background
nohup command & # run after terminal closes
jobs # list background jobs
fg %1 # bring job 1 to foreground
bg %1 # send to background
# Run command and keep after disconnect
screen -S mysession # start named session
tmux new -s mysession # tmux alternative (recommended)
# Disk usage
df -h # disk space by filesystem
du -sh * # size of each item in current dir
du -sh /* 2>/dev/null | sort -rh | head -10 # top 10 largest dirs
# Memory
free -h # RAM usage
vmstat 1 5 # VM stats every 1s, 5 times
#!/bin/bash
set -euo pipefail # exit on error, undefined var, pipe failure
# Variables
NAME="Alice"
echo "Hello, $NAME"
echo "Files: $(ls | wc -l)" # command substitution
# Conditionals
if [[ -f "package.json" ]]; then
echo "Node project"
elif [[ -f "requirements.txt" ]]; then
echo "Python project"
else
echo "Unknown"
fi
# Loops
for file in *.log; do
echo "Processing $file"
gzip "$file"
done
# Functions
log() {
echo "[$(date +%H:%M:%S)] $1"
}
log "Starting deployment"
# Read .env file
export $(grep -v '^#' .env | xargs)
crontab -e # edit cron jobs
crontab -l # list cron jobs
# Format: minute hour day month weekday command
# ┌─ minute (0-59)
# │ ┌─ hour (0-23)
# │ │ ┌─ day of month (1-31)
# │ │ │ ┌─ month (1-12)
# │ │ │ │ ┌─ day of week (0-7, 0=Sun)
0 2 * * * /usr/bin/backup.sh # daily at 2 AM
*/15 * * * * /usr/bin/check_health.sh # every 15 minutes
0 0 1 * * /usr/bin/monthly_report.sh # 1st of month at midnight
0 9 * * 1-5 /usr/bin/work_reminder.sh # weekdays at 9 AM
# Redirect output to log file
0 2 * * * /usr/bin/backup.sh >> /var/log/backup.log 2>&1