Operations 8 min read

Essential Linux Command Cheat Sheet for Ops and Developers

A comprehensive Linux quick‑reference guide that covers everyday file and directory operations, text processing, system monitoring, networking tools, compression, permission management, software installation, command chaining, handy utilities, and common troubleshooting steps for both system administrators and developers.

Ray's Galactic Tech
Ray's Galactic Tech
Ray's Galactic Tech
Essential Linux Command Cheat Sheet for Ops and Developers

1. Files and Directories

ls -lah

– List directory contents with detailed info; use --time-style=long-iso for standardized timestamps. cd - – Return to the previous directory. pwd – Show the current working directory (useful for script location). cp -rv source dest – Copy files/directories recursively while showing progress. mv source dest – Move or rename files; mv file /tmp can act as a quick delete. rm -rf path – Force delete (use with caution; consider trash as a safer alternative). find -name "*.log" – Search for files; combine with -exec rm for batch deletion.

2. Text Viewing and Processing

cat a.txt b.txt > c.txt

– Concatenate and view files. less file – Paginated view with search (e.g., /error). head -n 50 log.txt – Show the first N lines. tail -f /var/log/syslog – Follow the last N lines in real time. grep -ri error /var/log – Recursively search for a keyword. awk '{print $1,$3}' log.txt – Extract specific columns. sed -i 's/old/new/g' file – In‑place text replacement. jq '.key' config.json – Parse JSON data.

3. System Management

ps aux

– List all running processes. kill -9 1234 – Force‑terminate a process by PID. top / htop – Real‑time system resource monitoring (htop offers a more intuitive UI). df -h – Show disk usage; combine with ncdu for detailed analysis. du -sh /var/* – Display directory size summaries. free -h – Display memory usage and check for OOM conditions. uptime – Show system uptime and load average (load > 1 may need investigation). iostat -dx 2 – Monitor disk I/O (requires sysstat package).

4. Networking and Connectivity

ping 8.8.8.8

– Test network reachability. curl -I https://example.com – Perform HTTP request testing. wget https://file.com/app.tar.gz – Download files. ss -lntp – List listening TCP ports. scp file user@host:/path – Securely copy files to a remote host. ssh user@host – Open a remote shell session. telnet host 80 – Test TCP port connectivity.

5. Compression and Archiving

tar -czvf file.tar.gz dir/

– Create a gzipped tar archive. tar -xzvf file.tar.gz – Extract a gzipped tar archive. zip -r file.zip dir/ – Create a zip archive. unzip file.zip – Extract a zip archive. tar --exclude='*.log' -czvf backup.tar.gz data – Archive while excluding log files.

6. Permissions and User Management

chmod 755 file

– Change file permissions. chown user:group file – Change file ownership. sudo command – Execute a command with elevated privileges. su - user – Switch to another user account. useradd -m user – Create a new user with a home directory. passwd user – Change a user's password.

7. Software Management

Debian/Ubuntu: apt install pkg / apt remove pkg CentOS/RHEL: yum install pkg / yum remove pkg Generic RPM: rpm -ivh pkg.rpm /

rpm -e pkg

8. Command Composition and Redirection

# Real‑time log + keyword filter
 tail -f /var/log/syslog | grep --color=always error

# Write both stdout and stderr to a file
 command > out.log 2>&1

# Delete log files older than 30 days
 find /var/log -name "*.log" -type f -mtime +30 -exec rm -f {} \;

9. Lesser‑Known but Powerful Tools

ncdu – Interactive disk usage analyzer.

bat – Cat with syntax highlighting.

ag – Ultra‑fast code/text search.

tmux – Terminal multiplexer for multiple sessions.

htop – Enhanced version of top.

10. Everyday Troubleshooting Quick‑Reference

Permission denied – Fix with sudo chmod 755 file and chown as needed.

Garbage characters (Chinese garbled) – Set locale: export LANG="en_US.UTF-8".

Accidental file deletion – Recover using extundelete (unmount the partition first).

Port already in use – Identify with ss -lntp.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Shellcommand-lineSysadmincheatsheet
Ray's Galactic Tech
Written by

Ray's Galactic Tech

Practice together, never alone. We cover programming languages, development tools, learning methods, and pitfall notes. We simplify complex topics, guiding you from beginner to advanced. Weekly practical content—let's grow together!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.