Operations 13 min read

21 Essential Linux Commands Every Developer Should Master

This comprehensive guide lists the 21 most frequently used Linux commands—from navigating directories and managing files to searching, text processing, compression, system shutdown, and process control—providing a handy cheat‑sheet for developers and system administrators alike.

ITFLY8 Architecture Home
ITFLY8 Architecture Home
ITFLY8 Architecture Home
21 Essential Linux Commands Every Developer Should Master

This article summarizes the 21 most frequently used Linux commands, often asked in interviews, and serves as a quick reference guide.

1. Files and Directories

cd

Change the current directory.

cd /home – go to /home directory

cd .. – go up one level

cd ../.. – go 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

pwd

Display the current working directory.

ls

List files and directories.

ls – list files

ls -l – detailed list

ls -a – include hidden files

ls -R – recursive listing

ls [0-9] – list names containing digits

cp

Copy files.

-a – preserve attributes

-p – preserve properties (useful for backup)

-i – prompt before overwriting

-r – copy directories recursively

-u – copy only when source is newer

mv

Move or rename files/directories.

-f – force overwrite

-i – prompt before overwriting

-u – overwrite only if source is newer

rm

Remove files or directories.

-f – ignore nonexistent files, no warnings

-i – interactive mode, ask before deleting

-r – recursive delete (dangerous for directories)

2. Viewing File Content

cat

Display file contents; often combined with pipelines.

cat file1 – show entire file

tac file1 – reverse order

cat -n file1 – show line numbers

more file1 – paginate long files

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

find

find / -name file1 – search from root

find / -user user1 – files owned by user1

find /usr/bin -type f -atime +100 – files not accessed in 100 days

find /usr/bin -type f -mtime -10 – files modified within 10 days

whereis halt – locate binary, source, or man page

which halt – show full path of executable

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

4. File Permissions

chmod

ls -lh – display permissions

chmod ugo+rwx directory1 – grant read/write/execute to all

chmod go-rwx directory1 – revoke permissions from group and others

chown

chown user1 file1 – change file owner

chown -R user1 directory1 – change owner recursively

chown user1:group1 file1 – change owner and group

chgrp

chgrp group1 file1 – change group ownership

5. Text Processing

grep

Search for patterns in files.

grep Aug /var/log/messages – find "Aug"

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 's/string1/string2/g' example.txt – replace text

sed '/^$/d' example.txt – delete empty lines

paste

paste file1 file2 – merge files column‑wise

paste -d '+' file1 file2 – merge with '+' delimiter

sort

sort file1 file2 – sort contents

sort file1 file2 | uniq – unique lines

sort file1 file2 | uniq -u – lines only in one file

sort file1 file2 | uniq -d – common lines

comm

comm -1 file1 file2 – exclude file1 lines

comm -2 file1 file2 – exclude file2 lines

comm -3 file1 file2 – exclude common lines

6. Archiving and Compression

tar

Create, list, or extract archives; can use compression options.

-c – create archive

-t – list archive contents

-x – extract archive

-j – use bzip2

-z – use gzip

-v – verbose output

-f filename – specify archive file

-C dir – change to directory before operation

Examples:

tar -jcv -f filename.tar.bz2 … – create bzip2 archive

tar -jtv -f filename.tar.bz2 – list contents

tar -jxv -f filename.tar.bz2 -C /dest – extract

Other tools: bunzip2, bzip2, gunzip, gzip, rar, zip, unzip.

7. System Shutdown and Reboot

shutdown -h now – halt now

init 0 – halt

telinit 0 – halt

shutdown -h hh:mm & – schedule shutdown

shutdown -c – cancel scheduled shutdown

shutdown -r now – reboot now

reboot – reboot

logout – log out

time – measure command execution time

8. Process Management

jps

Show Java processes and their IDs.

ps

Display process information.

-A – all processes

-a – all without controlling terminal

-u – processes of a specific user

-x – extended listing

-l – long format

ps aux    # show all processes
ds ax    # show processes without terminal
ds -lA   # detailed list
ds axjf  # show process tree

kill

Send signals to processes by PID or job number.

killall

Send signals to all processes matching a name.

top

Real‑time system monitor, similar to Windows Task Manager.

Ways to kill a process:

Graphical interface

kill -9 pid – force kill

killall -9 program_name

pkill program_name

Check process ports:

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

linuxShellcommand-lineUnixSystem Administration
ITFLY8 Architecture Home
Written by

ITFLY8 Architecture Home

ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.

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.