Operations 20 min read

Master Essential Linux Commands: From cd to tar and Beyond

This comprehensive guide introduces the most frequently used Linux commands—including navigation, file manipulation, searching, permission handling, compression, process management, and redirection—explaining their purpose, common options, and practical examples to help users work efficiently in a Linux environment.

Linux Cloud Computing Practice
Linux Cloud Computing Practice
Linux Cloud Computing Practice
Master Essential Linux Commands: From cd to tar and Beyond

Linux common commands are widely used tools that allow users to manage files, processes, networking, software installation, and more within the Linux operating system.

cd command

cd : Change the current working directory to the specified path.

cd ..        # return to parent directory
cd ../..    # return to grandparent directory
cd ~        # go to home directory
cd -        # return to previous directory

pwd command

pwd : Display the full path of the current working directory.

ls command

ls : List files and directories in the specified directory.

ls               # list files in current directory
ls -l            # detailed list with permissions
ls -a            # include hidden files
ls -R            # recursive list of subdirectories
ls [0-9]         # list files with numeric names

cp command

cp : Copy files or directories.

-a  # copy attributes and preserve structure
-p  # preserve file attributes (useful for backups)
-i  # prompt before overwriting
-r  # copy directories recursively
-u  # copy only when source is newer

mv command

mv : Move or rename files or directories.

-f  # force overwrite without prompting
-i  # prompt before overwriting
-u  # overwrite only if source is newer

rm command

rm : Delete files or directories.

-f  # ignore nonexistent files, no warnings
-i  # prompt before each removal
-r  # recursive delete (commonly for directories)

cat command

cat : Display file contents and concatenate files.

cat file1               # show file from start
tac file1               # show file in reverse order
cat -n file1           # display with 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

find command

find : Search for files in a directory hierarchy.

find / -name file1          # search from root for name
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 last 10 days

chmod command

chmod : Change file or directory permissions.

chmod ugo+rwx directory1   # give read/write/execute to all
chmod go-rwx directory1   # remove permissions from group and others

chown command

chown : Change file owner.

chown user1 file1               # set owner to user1
chown -R user1 directory1      # recursively change owner

chgrp command

chgrp : Change group ownership of a file.

chgrp group1 file1

grep command

grep : Search for patterns in files.

grep keyword file.txt
grep ^Aug /var/log/messages   # lines starting with Aug

paste command

paste : Merge lines of files side by side.

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

sort command

sort : Sort lines of text.

sort file1               # default sort
sort -r file1            # reverse order
sort -n file1            # numeric sort
sort -u file1            # unique lines only

comm command

comm : Compare two sorted files.

comm -1 file1 file2   # lines only in file1
comm -2 file1 file2   # lines only in file2
comm -3 file1 file2   # lines common to both

tar command

tar : Archive and optionally compress files.

# Create archive
tar -cvf archive.tar directory
# Create gzip compressed archive
tar -zcvf archive.tar.gz directory
# Create bzip2 compressed archive
tar -jcvf archive.tar.bz2 directory
# List contents
tar -tvf archive.tar
# Extract
tar -xvf archive.tar -C /target/dir

jps command

jps : List Java processes.

jps -l   # full package name
jps -m   # show main class arguments

kill command

kill : Send signals to processes.

kill PID               # default SIGTERM
kill -9 PID            # force kill (SIGKILL)

killall command

killall : Terminate processes by name.

System shutdown and reboot

shutdown -h now      # halt now
shutdown -r now      # reboot now
reboot               # reboot

top command

top : Real‑time view of system resource usage.

touch command

touch : Create an empty file or update timestamps.

mkdir command

mkdir : Create a new directory.

ps command

ps : Display currently running processes.

ping command

ping : Test network connectivity to a host.

ifconfig command

ifconfig : Show network interface configuration.

Redirection operators

> : Redirect output to a file. ls > file.txt >> : Append output to a file. date >> file.txt < : Use a file as input. sort < file.txt | : Pipe output of one command to another.

ls | grep file

cut command

cut : Extract sections from each line of files.

cut -c 1,3 file.txt          # characters 1 and 3
cut -d ':' -f 2,4 file.txt   # fields 2 and 4 using ':'
cut -c 1,3 --complement file.txt  # all but characters 1 and 3

Other useful commands

wc -l file # count lines more file # view file page by page sudo -i # obtain a root shell

shellCommand LineUnixterminal
Linux Cloud Computing Practice
Written by

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!

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.