Operations 16 min read

Essential Linux Commands Every Sysadmin Should Master

This guide compiles the most frequently used Linux commands for file navigation, content viewing, searching, permission handling, text processing, compression, system shutdown, and process management, providing clear syntax examples and practical tips to boost operational efficiency for system administrators.

Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
Essential Linux Commands Every Sysadmin Should Master

File and Directory Operations

Basic navigation and manipulation of the filesystem are performed with the following commands:

cd – change the current directory.

cd /home            # absolute path
cd ..               # parent directory
cd ../..            # two levels up
cd                  # $HOME
cd ~user1           # another user's home
cd -                # previous directory

pwd – print the absolute pathname of the current working directory. pwd ls – list directory contents.

ls                     # simple list
ls -l                  # long format with permissions, size, etc.
ls -a                  # include hidden entries
ls -R                  # recursive listing
ls [0-9]               # entries containing digits

cp – copy files or directories.

# Common options
-a   Preserve attributes and copy recursively
-p   Preserve mode, ownership, timestamps
-i   Prompt before overwriting
-r   Copy directories recursively
-u   Copy only when the source is newer

mv – move or rename files/directories.

# Common options
-f   Force overwrite without prompting
-i   Prompt before overwriting
-u   Overwrite only if the source is newer

rm – remove files or directories.

# Common options
-f   Ignore nonexistent files, never prompt
-i   Interactive mode, ask before each removal
-r   Recursive removal (dangerous for directories)

Viewing File Content

These utilities display or paginate the contents of text files.

cat – concatenate and print files.

cat file1                     # whole file
cat -n file1                 # with line numbers
tac file1                     # reverse order
more file1                   # paginated view
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‑3000
cat file1 | tail -n +3000 | head -n 1000   # lines 3000‑3999

File Search

The find utility searches the filesystem based on criteria such as name, owner, timestamps, etc.

find / -name file1                     # start at root
find / -user user1                     # owned by user1
find /usr/bin -type f -atime +100     # not accessed in 100 days
find /usr/bin -type f -mtime -10      # modified within last 10 days
whereis halt                           # binary, source, man page
which halt                             # full path of executable

Delete files larger than 50 MiB:

find /var/mail/ -size +50M -exec rm {} \;

Permissions Management

chmod – change file or directory mode.

# Show permissions
ls -lh
# Grant read/write/execute to everyone
chmod ugo+rwx directory1
# Revoke all permissions from group and others
chmod go-rwx directory1

chown – change ownership.

chown user1 file1                # change owner
chown -R user1 directory1        # recursive
chown user1:group1 file1         # change owner and group

chgrp – change group ownership.

chgrp group1 file1

Text Processing

grep – filter lines matching a pattern.

grep Aug /var/log/messages               # simple search
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

sed – stream editor for in‑place substitutions.

sed 's/string1/string2/g' example.txt   # replace all occurrences
sed '/^$/d' example.txt                # delete empty lines

paste – merge columns from multiple files.

paste file1 file2               # default tab delimiter
paste -d '+' file1 file2       # use '+' as delimiter

sort and uniq – ordering and deduplication.

sort file1 file2               # sort combined input
sort file1 file2 | uniq        # unique lines (union)
sort file1 file2 | uniq -u     # lines appearing only once (difference)
sort file1 file2 | uniq -d     # duplicate lines (intersection)

comm – compare two sorted files.

comm -1 file1 file2   # suppress lines unique to file1
comm -2 file1 file2   # suppress lines unique to file2
comm -3 file1 file2   # suppress common lines

Archiving and Compression

The tar command creates archives; optional flags invoke compression utilities.

# Core tar flags
-c   create archive
-t   list archive contents
-x   extract archive (use -C to specify destination)
-j   bzip2 compression
-z   gzip compression
-v   verbose output
-f   specify archive file name
-C   change to directory before extracting

Examples:

tar -jcvf archive.tar.bz2 file1 file2          # bzip2 archive
tar -jtvf archive.tar.bz2                       # list contents
tar -jxvf archive.tar.bz2 -C /dest               # extract to /dest

Other compression utilities:

bzip2 file1               # compress with bzip2
bunzip2 file1.bz2         # decompress bzip2
gzip file1                # compress with gzip (use -9 for maximum)
gunzip file1.gz           # decompress gzip
rar a archive.rar file1 file2 dir1   # create RAR archive
rar x archive.rar        # extract RAR
zip -r archive.zip file1 file2 dir1 # recursive zip
unzip archive.zip        # extract ZIP

System Shutdown and Reboot

shutdown -h now            # immediate power‑off
init 0                     # alternative shutdown
telinit 0                  # another shutdown method
shutdown -h HH:MM          # schedule shutdown
shutdown -c                # cancel scheduled shutdown
shutdown -r now            # immediate reboot
reboot                     # reboot
logout                     # end current session
time command               # measure execution time of a command

Process Management

jps – list Java processes with their PID and class name.

ps – snapshot of current processes.

# Common options
-A   all processes
-a   processes not attached to a terminal
-u   processes owned by a specific user
-x   processes without a controlling terminal
-l   long format with detailed info

ps aux          # all processes, detailed
ps ax           # all processes, no terminal
ps -lA          # long format for all
ps axjf         # process tree

kill – send signals to a process.

kill -l                 # list all signal names
kill -9 3268           # force kill PID 3268
kill -TERM 1234        # graceful termination
kill -l KILL           # numeric value of SIGKILL
kill -l SIGTERM        # numeric value of SIGTERM

killall – kill processes by name.

killall nginx               # terminate all nginx processes
killall -9 bash            # force kill all bash instances
killall -TERM nginx        # send SIGTERM to nginx

top – real‑time system monitor (similar to Windows Task Manager).

Identify the port a process is listening on:

netstat -tunlp | grep PORT
Linux commands illustration
Linux commands illustration
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.

OperationsLinuxShellSysadmincommands
Full-Stack DevOps & Kubernetes
Written by

Full-Stack DevOps & Kubernetes

Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.

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.