Mastering Linux: 10 Unique and Useful Commands Every User Should Know

Ayushmaan Srivastav
4 min readApr 3, 2024

--

Welcome to the world of Linux, where the command line is your playground and the possibilities are endless. Whether you're a seasoned sysadmin or just dipping your toes into the Linux waters, mastering a few essential commands can drastically improve your efficiency and productivity. In this blog post, we'll explore 10 unique and useful Linux commands that every user should know, along with explanations of how and when to use them.

1. find:
The find command is a powerful tool for searching files and directories based on various criteria such as name, type, size, and more. For example, to find all text files in the current directory and its subdirectories, you can use:

find . -type f -name "*.txt"
This command searches recursively from the current directory (.) for files (-type f) with names ending in .txt.

2. grep:
grep is a versatile command-line utility for searching plain-text data using regular expressions. It's especially handy for parsing logs or filtering output. For instance, to search for lines containing a specific word in a file, you can use:

grep "keyword" filename

This will display all lines in filename that contain the word "keyword".

3. awk:
awk is a powerful programming language for processing and analyzing text data. It's particularly useful for data manipulation tasks such as extracting columns or performing calculations. For example, to print the second column of a CSV file, you can use:

awk -F’,' '{print $2}' filename.csv
Here, -F',' sets the field separator to a comma, and {print $2} instructs awk to print the second column.

4. sed:
sed is a stream editor for filtering and transforming text. It's commonly used for performing search-and-replace operations or applying edits to multiple files. For instance, to replace all occurrences of "old" with "new" in a file, you can use:

sed -i 's/old/new/g' filename
The -i flag edits the file in place, while the s/old/new/g command performs the substitution globally.

5. rsync:
rsync is a powerful utility for efficiently synchronizing files and directories between two locations, either locally or over a network. It's ideal for tasks like backups or mirroring. For example, to sync files from a local directory to a remote server, you can use:

rsync -avz /path/to/local/directory username@remotehost:/path/to/remote/directory
This command transfers data recursively (-a), preserves permissions and timestamps (-v), and compresses data during transfer (-z).

6. tmux:
tmux is a terminal multiplexer that allows you to create and manage multiple terminal sessions within a single window. It's perfect for multitasking and organizing your workflow. To start a new tmux session, simply type:

tmux new -s session_name
This command creates a new session named session_name.

7. htop:
htop is an interactive process viewer and system monitor that provides a more user-friendly alternative to the traditional top command. It displays a hierarchical view of processes and allows for easy sorting and management. Simply run htop in the terminal to launch the interface.

8. du: du (disk usage) is a command-line utility for estimating file and directory sizes. It’s useful for identifying large files or directories that may be consuming disk space. For example, to display the sizes of all directories in the current directory, sorted by size, you can use:

du -h --max-depth=1 | sort -hr
This command displays the disk usage in human-readable format (-h) and sorts the output in reverse (-r) numerical order.

9. scp:
scp (secure copy) is a command-line tool for securely transferring files between hosts over a network. It uses SSH for encryption and authentication, making it a secure alternative to cp or rsync. For example, to copy a file from a remote server to your local machine, you can use:

scp username@remotehost:/path/to/file /local/path
Replace username, remotehost, /path/to/file, and /local/path with the appropriate values.

10. lsof:
lsof (list open files) is a command-line utility for displaying information about files opened by processes. It's useful for troubleshooting issues related to file access or identifying processes holding onto deleted files. For example, to list all open files and the processes that opened them, you can use:

lsof
This command displays a detailed list of open files, including their file descriptors, associated processes, and more.

Mastering these 10 unique and useful Linux commands will empower you to become a more efficient and proficient Linux user. Whether you're managing servers, analyzing data, or simply navigating your file system, these commands will serve as invaluable tools in your arsenal. So dive in, experiment, and unlock the full potential of the Linux command line!

--

--

No responses yet