Skip to content
20 Actually Useful Linux One-Liners (2026)

20 Actually Useful Linux One-Liners (2026)

DodaTech Updated Jun 20, 2026 3 min read

Most Linux one-liner lists give you ls -la and grep -r. You already know those. This list covers the commands that solve actual sysadmin and development problems — disk emergencies, process hunting, network debugging, and automation. Every one-liner here has saved me at least once on a Friday afternoon.

Process Management

Find the 10 largest files in a directory treefind . -type f -exec du -sh {} + | sort -rh | head -10

Kill all processes by namepkill -f "node app.js" or kill $(pgrep -f "node app.js")

Show CPU and memory usage per process, sortedps aux --sort=-%cpu | head (replace %cpu with %mem for memory)

Logs & Monitoring

Monitor a log file in real time with timestampstail -f app.log | while read line; do echo "$(date '+%H:%M:%S') $line"; done

Watch a command every N secondswatch -n 2 'netstat -tulpn | grep :3000' — re-runs the command every 2 seconds with a clear screen.

Disk & Storage

Disk usage per directory, human-readable, top 10du -sh */ | sort -rh | head -10

Count files per directory recursivelyfor d in */; do echo "$d: $(find "$d" -type f | wc -l)"; done

Find files modified in the last 24 hoursfind . -type f -mtime -1

Network

Check which ports are listeningss -tulpn (modern replacement for netstat)

Get your external IPcurl -s ifconfig.me or curl -s icanhazip.com

Check SSL certificate expiry dateecho | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

Download an entire website recursivelywget --mirror --page-requisites --convert-links --no-parent -e robots=off -P ./site https://example.com

File Operations

Bulk rename files (replace spaces with underscores)for f in *\ *; do mv "$f" "${f// /_}"; done

Extract tar.gz to a directorytar -xzf archive.tar.gz -C /target/directory

Find text in files, excluding node_modulesgrep -r --exclude-dir=node_modules --exclude-dir=.git "search_term" .

Rsync with progress barrsync -avh --progress /source/ /destination/

System Info & Security

List all users on the systemcut -d: -f1 /etc/passwd

Dump full system informationuname -a && lscpu && free -h && df -h

Check system uptime and loaduptime — shows how long since last reboot, number of users, and 1/5/15 minute load averages.

Generate a random 32-character passwordopenssl rand -base64 24

Which one-liner do you reach for most?
ss -tulpn. Before deploying anything, check what’s already listening on your ports. It prevents the most common deployment failure: port conflicts. Second place is du -sh */ | sort -rh | head for finding what’s eating disk space.
Are these safe to run on production servers?
Most are read-only. The destructive ones (kill, rename, delete) are clearly labeled. Always test pkill, mv loops, and wget --mirror on a non-production system first. The --dry-run flag on rsync prevents accidents.
What about macOS — do these work?
Most do. macOS ships with BSD tools instead of GNU, so du, sort, and find have slightly different flags. Install coreutils (brew install coreutils) for GNU-compatible versions. ss isn’t available on macOS — use lsof -i -P instead.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro