In the first article, we covered some lesser-known but powerful Linux commands. Here, we continue the journey by introducing more CLI tools that can further streamline and automate your DevOps tasks. These utilities can improve your workflows, making tasks like file management, networking, and system monitoring more efficient.
1. nc
nc
(or netcat
) is a versatile tool for network-related tasks. It can be used for port scanning, transferring files, and even setting up a quick server or client for testing purposes.
Example:
# Simple file transfer
nc -l 1234 > received_file.txt
# On another system:
cat file.txt | nc <destination_ip> 1234
2. pv
pv
(Pipe Viewer) allows you to monitor the progress of data through a pipeline. It’s useful when you want to see the speed and completion status of data transfers or file copying.
Installation:
sudo apt install pv
Example:
pv largefile.iso | dd of=/dev/sdX
This command displays the progress of writing largefile.iso
to a device.
3. watch
watch
repeatedly executes a command at specified intervals and displays the output. It’s great for monitoring the status of a system or the output of a script.
Example:
watch -n 5 df -h
This will run df -h
every 5 seconds, showing updates on disk space usage.
4. ss
ss
is a powerful command to investigate sockets and connections on your system. It serves as a modern replacement for netstat
, offering faster and more detailed output.
Example:
ss -tuln
Displays all listening ports, including TCP and UDP, along with their status.
5. ncdu
While we mentioned ncdu
earlier, it deserves another highlight as an alternative to the classic du
. It offers a cleaner interface and more useful interactive navigation.
Example:
ncdu -x /
Scans the root directory but restricts the scan to the same filesystem, which helps avoid traversing mounted drives.
6. dstat
dstat
combines the functionalities of various tools like vmstat
, iostat
, netstat
, and ifstat
. It can be particularly helpful when you need an overall system resource usage view.
Installation:
sudo apt install dstat
Example:
dstat --cpu --mem --disk --net
This command will give a combined view of CPU, memory, disk, and network statistics.
7. iftop
iftop
is a real-time console-based network bandwidth monitoring tool. It shows a list of network connections and how much bandwidth each connection is consuming.
Installation:
sudo apt install iftop
Example:
sudo iftop -i eth0
This command will monitor the network bandwidth usage on the eth0
interface.
8. ag
(The Silver Searcher)
ag
is a code-searching tool similar to grep
, but optimized for speed and designed for searching within codebases. It’s faster than grep
and comes with sensible defaults for code search.
Installation:
sudo apt install silversearcher-ag
Example:
ag "search_term" /path/to/codebase
This will search for “search_term” across the specified codebase.
9. tmux
tmux
is a terminal multiplexer that allows you to run multiple terminal sessions in a single window. It’s perfect for managing multiple tasks on remote servers.
Example:
tmux new -s mysession
Starts a new tmux
session named mysession
. You can detach and reattach to this session as needed.
10. rsync
Though not entirely lesser-known, rsync
is still underutilized by many. It’s a fast and versatile tool for syncing files and directories between systems, supporting incremental transfers, compression, and deletion.
Example:
rsync -avz /local/dir/ user@remote:/remote/dir/
Synchronizes the contents of /local/dir/
to /remote/dir/
on a remote server using SSH.
Conclusion
Mastering these lesser-known Linux commands can make a significant difference in how efficiently you handle daily tasks. Whether you’re debugging network issues, monitoring system performance, or transferring files, these tools can save you time and effort, helping you get the job done more effectively.