Essential Linux Commands Every Ops Engineer Should Master
This guide compiles the most frequently used Linux commands—covering file navigation, inspection, searching, permission handling, text processing, archiving, system control, and process management—to help operations professionals work more efficiently and confidently on the command line.
1. Files and Directories
cd – change the current directory. Examples: <code>cd /home # go to /home cd .. # up one level cd ../../ # up two levels cd # go to the user’s home directory cd ~user1 # go to user1’s home directory cd - # return to the previous directory</code>
pwd – print the current working directory. <code># pwd /root</code>
ls – list files and directories. <code>ls # simple list ls -l # long format with details ls -a # include hidden files ls -R # recursive listing ls [0-9] # show entries containing digits</code>
cp – copy files or directories. <code>-a preserve attributes -p preserve mode, ownership, timestamps (useful for backups) -i interactive, ask before overwriting -r copy directories recursively -u copy only when source is newer</code>
mv – move or rename files/directories. <code>-f force overwrite without prompting -i ask before overwriting -u overwrite only if the destination is older</code>
rm – remove files or directories. <code>-f force, ignore nonexistent files -i interactive, ask before each removal -r recursive removal of directories (dangerous)</code>
2. Viewing File Content
cat – display file contents; can be combined with more or less . <code>cat file1 # show entire file cat -n file1 # number lines more file1 # paginate long file head -n 2 file1 # first two lines tail -n 2 file1 # last two lines tail -n +1000 file1 # from line 1000 onward cat file1 | head -n 3000 | tail -n +1000 # lines 1000‑2999 cat file1 | tail -n +3000 | head -n 1000 # lines 3000‑3999</code>
tac – display a file in reverse order (last line first).
3. File Search
find – locate files and directories. <code>find / -name file1 # search from root find / -user user1 # files owned by user1 find /usr/bin -type f -atime +100 # executable not accessed in 100 days find /usr/bin -type f -mtime -10 # modified within last 10 days</code>
whereis and which – locate binaries, sources, or manuals. <code>whereis halt # show binary, source, man page which halt # show full path of executable</code>
Delete files larger than 50 MiB: <code>find /var/mail/ -size +50M -exec rm {} \;</code>
4. Permissions Management
chmod – change file/directory permissions. <code>ls -lh # view permissions chmod ugo+rwx directory1 # grant read/write/execute to user, group, others chmod go-rwx directory1 # remove all permissions for group and others</code>
chown – change ownership. <code>chown user1 file1 # set owner chown -R user1 directory1 # recursive ownership change chown user1:group1 file1 # set owner and group</code>
chgrp – change group ownership. <code>chgrp group1 file1</code>
5. Text Processing
grep – filter lines matching patterns. <code>grep Aug /var/log/messages # find "Aug" in log grep ^Aug /var/log/messages # lines starting with "Aug" grep [0-9] /var/log/messages # lines containing digits grep Aug -R /var/log/* # recursive search</code>
sed – stream editor for substitutions and deletions. <code>sed 's/string1/string2/g' example.txt # replace all occurrences sed '/^$/d' example.txt # delete empty lines</code>
paste – merge files column‑wise. <code>paste file1 file2 # default tab delimiter paste -d '+' file1 file2 # use '+' as delimiter</code>
sort – sort file contents; can be combined with uniq . <code>sort file1 file2 | uniq # unique lines (union) sort file1 file2 | uniq -u # lines only in one file (difference) sort file1 file2 | uniq -d # common lines (intersection)</code>
comm – compare two sorted files. <code>comm -1 file1 file2 # suppress column 1 (unique to file1) comm -2 file1 file2 # suppress column 2 (unique to file2) comm -3 file1 file2 # suppress column 3 (common lines)</code>
6. Archiving and Compression
tar – create and manipulate archive files. <code>-c create archive -t list archive contents -x extract archive (optionally with -C to specify directory) -j use bzip2 compression -z use gzip compression -v verbose output -f filename # archive name -C dir # change to directory before extracting</code>
Common usage examples: <code>tar -jcvf filename.tar.bz2 /path/to/dir # create bzip2 archive tar -jtvf filename.tar.bz2 # list contents tar -jxvf filename.tar.bz2 -C /dest # extract</code>
Other tools: <code>bunzip2 file1.bz2 # decompress bzip2 bzip2 file1 # compress with bzip2 gunzip file1.gz # decompress gzip gzip file1 # compress with gzip ("-9" for maximum compression) rar a file1.rar file1 # create RAR archive zip file1.zip file1 # create ZIP archive unzip file1.zip # extract ZIP archive zip -r file1.zip file1 file2 dir1 # recursive ZIP</code>
7. System Control and Shutdown
shutdown – power off or reboot. <code>shutdown -h now # immediate halt shutdown -h 22:30 # schedule halt at 22:30 shutdown -c # cancel scheduled shutdown shutdown -r now # immediate reboot</code>
reboot – immediate reboot. <code>reboot</code>
logout – end the current session. <code>logout</code>
time – measure execution time of a command. <code>time ls -R /</code>
8. Process Management
jps – list Java processes. <code># Example output shows PID and class name of each Java process</code>
ps – snapshot of current processes. <code>-A show all processes -a show processes not attached to a terminal -u show processes for a specific user -x include processes without a controlling terminal -l long format with detailed info ps aux # all processes with user/CPU/memory info ps axjf # process tree</code>
kill – send signals to processes. <code>kill -l # list all signal names kill -9 3268 # force kill PID 3268 kill -l KILL # show numeric value of SIGKILL</code>
killall – kill processes by name. <code>killall nginx # terminate all nginx processes killall -9 bash # force kill all bash instances killall -TERM nginx # send SIGTERM to nginx</code>
top – interactive real‑time process monitor (similar to Windows Task Manager).
Check which port a process is listening on: <code>netstat -tunlp | grep 8080</code>
Linux Cloud Computing Practice
Welcome to Linux Cloud Computing Practice. We offer high-quality articles on Linux, cloud computing, DevOps, networking and related topics. Dive in and start your Linux cloud computing journey!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
