10 interesting Linux commands

1. Screen

“screen”  allows you to create and manage multiple terminal sessions within a single console window.

Create a new screen session: screen, and then use screen -r to resume a detached session.

Example

2. Tac

“tac” is similar to the “cat” command, but it displays the contents of a file in reverse order.

tac file.txt

Example

3. Watch

“watch” repeatedly executes a command at a specified interval and is  useful for monitoring the output of a command over time.

Monitor the output of the ‘df’ command every 2 seconds: watch -n 2 df -h

Example

4. Nc (or Netcat)

“netcat” is a simple utility for creating TCP/UDP connections and performing network communication.

Connect to a remote server on port 80: nc server.com 80

Example

5. ln

“ln” creates a link to a file or directory, useful for creating shortcuts to frequently accessed files.

Create a symbolic link to a file: ln -s /path/to/original /path/to/link

Example

6. Find

“find” searches for files and directories based on specified criteria, such as name, size, or date modified.

Find all files with the .txt extension in the current directory: find . -name “*.txt”

Example

7. sed

“sed” is a powerful text editor that can be used to perform complex text transformations on a file or stream of text.

Replace all occurrences of “old” with “new” in a file: 
sed ‘s/old/new/g’ file.txt

Example

8. Dig

“dig” command performs DNS lookups and can be used to troubleshoot DNS-related issues.

Perform a DNS lookup for example.com: 
dig example.com

Example

9. awk

“awk” is a text processing tool that can be used to perform complex operations on text, such as searching and replacing.

Print the second column of a file:
awk ‘{print $2}’ file.txt

Example

10. xrgs

“xargs” – a command-line utility that can be used to build and execute command lines from standard input.

Find all files with the .txt extension in the current directory and pass them as arguments to the ‘grep’ command: 
find . -name “*.txt” | xargs grep “search phrase”

Example