DEV Community

Devang Tomar
Devang Tomar

Posted on • Originally published at on

You should know these Linux commands to improve your terminal game 😎πŸ–₯️

Linux is an operating system (OS) for computers, servers, mainframes, mobile devices, and embedded devices that is Unix-like, open source, and community-developed. It is one of the most widely supported operating systems, with support for almost every major computer platform, including x86, ARM, and SPARC.

Until recently, Linux was primarily used for servers and was not considered suitable for desktop computers. However, its user interface and ease of use have steadily improved in recent years. Linux is now user-friendly enough to replace Windows on desktop computers. It is used by hundreds of thousands of people all over the world.

Today well look at some lesser-known linux commands that will get your terminal game going. If not that, it would undoubtedly improve your terminal knowledge. πŸ’―

Screen πŸ’»

Screen is a full-screen window manager that creates a single window with a running shell and allows multiple screen windows to run within the same session. Its most useful when youre running a long remote task and are concerned about your SSH session terminating and ruining everything. Screen will continue to run your commands even if you disconnect and the window is not visible to you.

# Starting a screen session

# Listing running screen sessions
screen -ls

# Attaching to screen session
screen -r

Enter fullscreen mode Exit fullscreen mode

Wall 🧱

Wall is a command-line utility that displays a message on all logged-in users terminals. Messages can be typed into a terminal or the contents of a file. To send a message to a specific user, use the write command instead of the wall command.

# This option will suppress the banner.  
wall -n

# To broadcase certain message  
wall "Cleanup window currently running!"

Enter fullscreen mode Exit fullscreen mode

Broadcast message from devang@localhost: Cleanup window currently running!

Ncdu πŸ’Ύ

The ncdu command provides a quick, convenient view for disk usage. The ncdu command displays disc usage in a useful and convenient manner. The name is an abbreviation for NCurses disc usage. This means that it is based on ncurses, which is a terminal control library used on Unix/Linux systems like curses. You can use it to see what directories are using the most disk space quickly and easily.

# For opening ncdu help  
ncdu --help


  -h,--help This help message  
  -q Quiet mode, refresh interval 2 seconds  
  -v,-V,--version Print version  
  -x Same filesystem  
  -e Enable extended information  
  -r Read only  
  -o FILE Export scanned directory to FILE  
  -f FILE Import scanned directory from FILE  
  -0,-1,-2 UI to use when scanning (0=none,2=full ncurses)  
  --si Use base 10 (SI) prefixes instead of base 2  
  --exclude PATTERN Exclude files that match PATTERN  
  -X, --exclude-from FILE Exclude files that match any pattern in FILE  
  -L, --follow-symlinks Follow symbolic links (excluding directories)  
  --exclude-caches Exclude directories containing CACHEDIR.TAG  
  --confirm-quit Confirm quitting ncdu  
  --color SCHEME Set color scheme

Enter fullscreen mode Exit fullscreen mode

Netcat 🐈

Netcat, or nc, is primarily used for port scanning, but it is also an excellent utility networking tool for system administrators to have on hand for any task. Netcat can scan for ports, copy files, forward ports, connect to proxy servers, and host websites Its safe to say that its extremely adaptable.

# Scan a single port  
nc -v -w 3 z 22     

# Scan multiple ports  
$ nc -v -w 2 z 22 80  

# Scan range of ports  
$ nc -v -w 2 z 20-25

Enter fullscreen mode Exit fullscreen mode

Shred πŸ“†

When was the last time you deleted a file from your Linux system? How did you manage it? Did you use rm and then abandon it? If there was any sensitive data in that file, you might want to reconsider using rm for that purpose. This is where shred enters the picture. When you delete a file permanently or from the trash, the pointer pointing to it loses its address, and the data of the file is sent to a sector in hard disc and is considered unallocated space, which can be easily recovered.

This small utility will securely erase a file by writing random data over top of it multiple times.

# For shredding a particular file  
shred -u <filename>

Enter fullscreen mode Exit fullscreen mode

Split πŸ––

Simple, effective, and even more adaptable than a command with a similar name in your high-level programming language. Split a file based on any number of criteria, from the number of lines to the length in bytes. Split provides more flexibility than simply splitting strings or line breaks.

Large files are split into smaller files using Linux. It divides files into 1000 lines (by default) and allows users to change the number of lines as needed.

# Spliting file based on n.o of lines  
split -l 6 random.txt split\_file

# Spliting file based on n.o of bytes  
split -b 16 index.txt index

Enter fullscreen mode Exit fullscreen mode

tc 🚦

Tc is used in the Linux kernel to configure Traffic Control. The following are the components of traffic control: Shaping. The rate of transmission of traffic is controlled when it is shaped. Shaping is used for more than just reducing available bandwidth; it is also used to smooth out traffic bursts for better network behaviour.

Traffic control (tc) is an extremely useful Linux utility that allows you to configure the kernel packet scheduler. If youre looking for reasons to fiddle with the kernel scheduler, here are a few: First, its fun to experiment with the various options and become acquainted with all of Linuxs features. Furthermore, you can use Linuxs useful tools to simulate packet delay and loss for UDP or TCP applications, or limit the bandwidth usage of a specific service to simulate Internet connections (DSL, Cable, T1, etc).

# Set a delay of 100ms and random +-10ms uniform distribution  
`tc qdisc change dev eth0 root netem delay 100ms 10ms  


# limit the egress bandwidth we can use the following command  
`tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms`

Enter fullscreen mode Exit fullscreen mode

Tcpdump πŸ—‘

Used to record and analyse traffic to and from your system. It is a powerful and versatile tool that specialises in network debugging and troubleshooting but can also be used as a security tool.

# To capture specific number of packets  
sudo tcpdump -c 4 -i eth0

# To display all available interfaces  
sudo tcpdump -D

# To capture packets with ip address  
sudo tcpdump -n -i wlo1

Enter fullscreen mode Exit fullscreen mode

Xargs 🀌

The xargs command constructs and executes commands entered via standard input. It converts the input into a command argument for another command.

This feature is especially useful in file management, where xargs is used in conjunction with rm, cp, mkdir, and other commands of a similar nature.

# To generate a compact list of all Linux user accounts  
cut -d: -f1 < /etc/passwd | sort | xargs

# To find file(s) in a directory and delete them as well  
find /Users/yourusername -name "random" -type d -print0 | xargs -0 -t /bin/rm -rf "{}"

Enter fullscreen mode Exit fullscreen mode

lsof πŸ“‚

As we all know, Linux/Unix treats everything as if it were a file (pipes, sockets, directories, devices, etc). When a disc cannot be unmounted because the files are in use, one of the reasons to use the lsof command. We can easily identify the files that are in use with the help of this command.

lsof is a single command that serves a single purpose: listing open files. This is especially useful when dealing with mounting issues that indicate that files are being used. This command quickly determines which files are currently being used by which processes.

# Yup that's it.. πŸ˜‡  

Enter fullscreen mode Exit fullscreen mode


In a Linux system, the htop command is a command-line utility that allows the user to interactively monitor the systems vital resources or the servers processes in real time. htop is a newer programme than top command, and it offers many advantages over top command.

htop supports mouse operation, outputs in colour, and provides visual indications of processor, memory, and swap usage. htop also prints full command lines for processes and allows for vertical and horizontal scrolling for processes and command lines.

# **\-d delay :** Used to show the delay between updates, in tenths of seconds.  
# **\-C no-color no-colour** : Start htop in monochrome mode.  
# **\-h help :** Used to display the help message and exit.  
# **\-u user=USERNAME :** Used to show only the processes of a given user.

htop -u yourUsername

Enter fullscreen mode Exit fullscreen mode

That concludes some of the useful options of common Linux commands you should have been aware of earlier. Im always amazed by Linux commands when I come across these hidden gems.

If you believe you are aware of a command option that is not widely used but is extremely useful, please share it with us in the comments.

I have also compiled this as a readme over my GitHub. Fancy checking it out? here it is.

Github URL for this article πŸ’»

GitHub - devangtomar/medium-linux-commands

_Linux is an operating system (OS) for computers, servers, mainframes, mobile devices, and embedded devices that

Lets connect and chat! Open to anything under the sun πŸ–πŸΉ

🐦 Twitter : devangtomar7

πŸ”— LinkedIn : devangtomar

πŸ“š Stackoverflow : devangtomar

πŸ–Ό Instagram : be_ayushmann

Medium : Devang Tomar

Hashnode : devangtomar

πŸ§‘πŸ’» : devangtomar

Top comments (2)

arunran30008245 profile image
arun rana

yes all these utils and ricing on top of it; waiting for them to get at par with windows in gaming world; i promise i will uninstall the my 2nd os immediately πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚

devangtomar profile image
Devang Tomar

Haha true! WSL over windows is what I use personally and love it! πŸ™Œ