Operations 14 min read

Essential Linux Command Cheat Sheet for Operations Engineers

This article compiles practical Linux command-line techniques—including vi/vim searching, file manipulation, piping, redirection, user management, system monitoring, and network diagnostics—to help operations engineers improve efficiency, troubleshoot issues, and maintain high‑availability services on Unix‑like systems.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Essential Linux Command Cheat Sheet for Operations Engineers

1. Search in vi/vim

Use /keyword to search forward; press Enter to jump to the first match, then n to find the next occurrence.

2. Vim undo and binary view

Press Esc then u to undo the last change. To view a file in binary mode, run vim -b mytest.php.

3. Pipe operator

The pipe symbol | passes the output of one command as input to the next. Example: cat install.log | more displays the log page‑by‑page.

4. Find files or directories

Common patterns: find /home -name "hello*" – find files/dirs named starting with hello under /home. find / -name h?m* – match names beginning with h, any character, m, then any suffix. find / -size +1000000k – locate files larger than 1 GB.

5. String replacement in vim

:s/well/good/

– replace first well on the current line. :s/well/good/g – replace all well on the current line. :n,$s/well/good/ – replace first well from line n to the end. :n,$s/well/good/g – replace all occurrences from line n onward. :%s/well/good/ – replace first well in every line. :%s/well/good/g – replace all well in the file.

Use # as an alternate delimiter to avoid escaping slashes, e.g., :s#well/#good/#.

6. Output redirection

ls -l /etc > /home/myback.txt

– overwrite the file with the command output. ls -l /etc >> /home/myback.txt – append the output.

7. Delete multiple lines in vim

Show line numbers with :set nu, then delete a range, e.g., 190,6233d. To clear an entire file, use > log.txt.

8. Jump to a specific line

Enter G for the last line, 1G for the first, or 17G to go to line 17.

9. Copy and paste lines

yy

– yank (copy) the current line; p – paste. 7yy – copy seven lines starting from the current line; p – paste.

10. Check Python version

Run python -V or python --version.

11. grep usage

grep -A n

– show n lines after a match. grep -B n – show n lines before a match. grep -C n – show n lines of context. grep -i pattern – case‑insensitive search.

12. Detailed ll output

ll -ht

lists files sorted by modification time with human‑readable sizes.

13. Find which process uses a file

Use lsof filename.

14. User management

Create a user: useradd redis then set password with passwd redis.

On Ubuntu: useradd openstack -m -s /bin/bash and delete with userdel -r openstack.

View groups in /etc/group and users in /etc/passwd or /etc/shadow.

15. Monitor memory, disk, and CPU

Memory: free -m (‑m for MB, ‑g for GB).

Disk: df -lh (human‑readable).

CPU info: cat /proc/cpuinfo (shows each core); filter with cat /proc/cpuinfo | grep "model name" | head -1 for a single line.

16. Check OS version

Run cat /etc/issue or cat /etc/redhat-release. For low‑level details, cat /proc/version.

17. Disk usage of a directory

du -h node

(run inside the target directory) or du -sh * from / to list sizes of all entries.

18. Inspect memory usage of Java processes

jstat -gc pid

– garbage‑collection stats. jmap -heap pid – heap layout. jstat -gcutil pid 1000 – GC utilization every second.

19. Change ownership recursively

chown -R solr:solr /home/solr/lib

changes user and group for the directory and its contents.

20. Check port connection counts

netstat -nlap | grep -i est | grep -i 6379 | awk '{print $4}'
netstat -nlap | grep -i est | grep -i 1121 | wc -l

Common netstat flags: -a (all), -t (TCP), -u (UDP), -n (numeric), -l (listening), -p (program name), -r (routing), -e (extra info), -s (statistics), -c (continuous).

21. Synchronize server time

Run ntpdate pool.ntp.org and schedule with a cron entry like 1 */2 * * * ntpdate pool.ntp.org.

22. Restrict SSH login

Edit /etc/sysconfig/sshd_config (or /etc/ssh/sshd_config) to add AllowUsers solr, then reload with service sshd reload.

23. Common JDK environment variables

JAVA_HOME=/usr/java/jdk1.7.0_55
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH

Export them with

export JAVA_HOME CLASSPATH PATH

24. Check Redis and Tomcat versions

Redis: redis-cli info | grep 'redis_version' Tomcat: run ./version.sh or sh version.sh inside the bin directory.

25. Verify if firewall blocks port 80

Execute iptables -vnL | grep ":80 "; output indicates the rule is present.

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.

Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.