Operations 15 min read

Essential Linux Commands Every Sysadmin Should Know

This guide compiles the most frequently used Linux commands for system administrators, covering navigation, file manipulation, searching, permission handling, text processing, archiving, system control, and process management, complete with practical examples and option details to boost daily operational efficiency.

Linux Tech Enthusiast
Linux Tech Enthusiast
Linux Tech Enthusiast
Essential Linux Commands Every Sysadmin Should Know

1. Files and Directories

The cd command changes the current directory.

cd /home          # enter '/home' directory
cd ..             # go up one level
cd ../..          # go up two levels
cd                # go to the current user's home directory
cd ~user1         # switch to user1's home directory
cd -              # return to the previous directory

The pwd command prints the absolute path of the current working directory.

# pwd
/root

The ls command lists files and directories.

ls                # list names
ls -l             # long format with details
ls -a             # include hidden files
ls -R             # recursive listing
ls [0-9]          # show entries containing digits

Copying files uses cp with options:

-a : archive (preserve attributes, recursive)
-p : preserve mode, ownership and timestamps
-i : interactive (prompt before overwrite)
-r : recursive copy (for directories)
-u : copy only when source is newer than destination

Moving or renaming uses mv with options:

-f : force overwrite without prompting
-i : interactive (prompt before overwrite)
-u : overwrite only if source is newer

Deletion uses rm with options:

-f : ignore nonexistent files, never prompt
-i : interactive (prompt before each removal)
-r : recursive removal of directories (dangerous)

2. Viewing File Content

The cat command outputs file contents; it can be combined with more or less. Variants include:

cat file1                     # view from start
tac file1                     # view from end (reverse)
cat -n file1                  # show line numbers
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 filename | head -n 3000 | tail -n +1000   # lines 1000‑3000
cat filename | tail -n +3000 | head -n 1000   # lines 3000‑3999

3. File Search

The find command locates files and directories.

find / -name file1                     # search from root
find / -user user1                    # files owned by user1
find /usr/bin -type f -atime +100    # files not accessed in the last 100 days
find /usr/bin -type f -mtime -10     # files created/modified within the last 10 days

Additional utilities:

whereis halt          # locate binary, source, and man page
which halt            # show full path of the executable

Delete files larger than 50 MiB:

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

4. Permissions

Change mode with chmod:

chmod ugo+rwx directory1          # grant read/write/execute to user, group, others
chmod go-rwx directory1           # revoke read/write/execute from group and others

Change ownership with chown:

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

Change group with chgrp:

chgrp group1 file1               # set group ownership

5. Text Processing

Search text with grep (often piped with other commands):

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 in /var/log

Replace text with sed:

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

Combine files side‑by‑side with paste:

paste file1 file2                         # merge columns
paste -d '+' file1 file2                  # use '+' as delimiter

Sort and deduplicate with sort and uniq:

sort file1 file2 | uniq                 # union (unique lines)
sort file1 file2 | uniq -u              # lines only in one file (difference)
sort file1 file2 | uniq -d              # common lines (intersection)

Compare files with comm:

comm -1 file1 file2   # suppress column 1 (lines only in file2)
comm -2 file1 file2   # suppress column 2 (lines only in file1)
comm -3 file1 file2   # suppress column 3 (common lines)

6. Archiving and Compression

The tar command creates and extracts archives. Common options:

-c : create archive
-t : list archive contents
-x : extract archive (optionally with -C to set destination)
-j : use bzip2 compression
-z : use gzip compression
-v : verbose output
-f filename : specify archive name
-C dir : change to directory before operation

Examples:

tar -jcv -f filename.tar.bz2 directory   # create bzip2 archive
tar -jtv -f filename.tar.bz2               # list contents
tar -jxv -f filename.tar.bz2 -C /dest      # extract to /dest

Other compression utilities:

bunzip2 file1.bz2
bzip2 file1
gunzip file1.gz
gzip file1
gzip -9 file1          # maximum compression
rar a file1.rar test_file
rar a file1.rar file1 file2 dir1
rar x file1.rar
zip file1.zip file1
unzip file1.zip
zip -r file1.zip file1 file2 dir1

7. System Shutdown and Reboot

shutdown -h now          # halt immediately
init 0                   # alternative halt
telinit 0                # alternative halt
shutdown -h 22:30        # schedule shutdown at 22:30
shutdown -c              # cancel scheduled shutdown
shutdown -r now          # reboot now
reboot                   # reboot
logout                   # log out of session
time command             # measure execution time of a command

8. Process Management

Java processes:

jps                     # list Java processes with PIDs

General process listing with ps:

ps aux                  # all processes with detailed info
ps ax                   # all processes not attached to a terminal
ps -lA                  # long format, all processes
ps axjf                 # show process tree

Terminate processes with kill (signal numbers optional):

kill -l                 # list all signal names
kill -9 3268            # force kill PID 3268
kill -l KILL            # get numeric value of SIGKILL

Kill by name with killall:

killall nginx           # kill all nginx processes
killall -9 bash        # force kill all bash processes
killall -TERM nginx    # send TERM signal to nginx

Monitor resources with top (Linux equivalent of Windows Task Manager).

Check listening ports:

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

process managementLinuxShellcommand-lineNetworkingSysadmincompressionfile management
Linux Tech Enthusiast
Written by

Linux Tech Enthusiast

Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.

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.