11 Overlooked Linux Commands You Really Should Be Using
Beneath the surface of the well-known Linux commands lies a treasure trove of lesser-known utilities that can make your life easier, enhance your productivity, and even impress your fellow Linux users. Let’s explore some of the most powerful but overlooked commands that deserve more attention.
1
rsync – The Smarter Alternative to cp and scp
Most people rely on cp to copy files, but rsync does the same job better. It’s faster, supports resume functionality, and can synchronize files across systems efficiently. It can also preserve file and directory attributes such as timestamps, permissions, and symlinks. It works great for everything from copying one file to backing up an entire file system.
rsync is installed on virtually all Linux systems by default. If it happens that it is not on your system, install with the following command:
sudo apt install rsync #Debian / Ubuntu
sudo dnf install rsync #Red Hat / Fedora
Basic usage:
#Copy a file or directory
rsync -av source/ destination/
#Copy over SSH with transfer compression
rsync -avz source/ user@remote:/destination
#Preview without moving anything
rsync --dry-run -av source/ destination/
Related
How to Transfer Files Between Systems Using scp and rsync
Either of these commands let you securely transfer files between computers, but there are good reasons to know them both.
2
bat – A Better cat
One of the first Linux command line tools most users learn about is cat. It’s often used to print text files to the screen in a terminal. It is effective, but provides only very basic and mostly WYSIWYG output. bat is a powerful alternative that, among other things, provides syntax coloring for code, paging functionality, forward and backward scrolling, and much more.
Install with:
sudo apt install bat
sudo dnf install bat
Basic usage:
bat FileToRead.txt
With bat open, you can maneuver easily using the arrow or page keys. Press H to see the full help and Q to quit back to a command prompt.
3
fd – A Faster, Smarter find
The find command is powerful but can quickly become overly-complicated if you want to go beyond fairly basic searches. The fd command is both faster and more intuitive, making it a great alternative.
Install with:
sudo apt install fd-find
sudo dnf install fd-find
Basic usage:
#Search using regular expression pattern match
#Matches pattern anywhere in name or path
fd "pattern" /search/path
fd ".log" /var/log
#Search using glob pattern matching
#Matches using traditional wildcard notation
fd -- glob "*.log"
fd --glob "specific.file.txt"
fd does a good job of combining powerful features and ease of use. If you’re not very tech savvy, the –glob switch is most likely what you’ll be looking for. For more advanced users, the ability to use regular expressions will allow you to find just about anything.
4
ncdu – A Better Disk Usage Analyzer
Most users go to the du command to check the condition of the overall disk usage on their system. It works fine if you just want to see how much space you have available but if you want to get into exactly what is using up that space, things become more difficult. That’s where ncdu really shines.
Install with:
sudo apt install ncdu
sudo dnf install ncdu
Basic usage:
ncdu
ncdu --help
It will take a few moments for ncdu to scan your directory tree and set itself up the first time you run it. Subsequent runs will load significantly faster. You can hit the question mark key for help if you need it, but the interface is very intuitive. You’ll quickly see what directories and files are taking up the most space on your system and can drill down as far as the tree goes.
Related
How to Use ncdu to Find Disk-Hogging Directories in Linux
Tame your disk space from the terminal!
5
htop – A Better top
Most Linux users are quite familiar with the process viewer command top and there’s a reason for that—it does what it does very well. There is, however, an alternative that improves on top both cosmetically and functionally. Let me introduce you to htop.
Install with:
sudo apt install htop
sudo dnf install htop
Basic usage:
htop
htop --help
As you can see, htop adds color to its output, making it a bit easier to pick out the elements that interest you quickly. It also shows a bit more detail about your hardware by default. CPU, memory, and swap conditions are displayed by default. You can get a great idea of what’s happening on your system with just a quick glance. Use the function keys to change settings, kill processes, and more.
Related
How to Use the htop Command on Linux
More than just a pretty face.
6
column – Print Data in Neat, Aligned Columns
Have you ever found yourself looking at a file of comma, space, or semicolon-separated values, wishing there was a quick and easy way to organize it on the screen and make it easier to read? This is where column comes in. When you just need to get some quick information out of a file and don’t want to actually process the data, column transforms your file into organized, easy-to-read tables right in the terminal.
This command should be available on virtually all Linux distributions with no need to install anything.
Here is an example of viewing a CSV file in the terminal with no extra formatting:
And here is how it looks when run through column:
Basic usage:
# Format data.txt into a table
cat data.txt | column -t
#Format data into a table and run through more
cat data.txt | column -t | more
#Specify comma separator and make a table
column -s, -t < file.csv
#Specify semicolon separator and make a table
column -s; -t < file.csv
#Truncate data in column 1 if needed
column -s, -t --table-truncate 1 < file.csv
#See help for full explanation of switches
Column --help
You can get more out of column by piping its output into other tools or files. You can save the output as a new file or pipe it into more for the ability to move backward and forward through the data.
7
watch – Monitor Any Command in Real Time
The watch command will let you run any other command at specific time intervals (default of two seconds) and keep an eye on the output. It’s perfect when you need to monitor some part of your system for changes.
The watch command should be available on all Linux distributions by default.
Basic usage:
#Watch disk usage
watch df -h
#Monitor directory for file changes
watch ls -l
#Watch memory and highlight changes
watch -d free -m
#Full help
watch --help
man watch
Whether you’re looking for a runaway process or trying to verify that desired changes are happening, the watch utility can give you insights into things you might now be able to see otherwise.
8
pv – A Progress Bar For Long-Running Commands
There are many Linux commands, such as cp and mv, that don’t give any kind of useful output about their progress. If you’re trying to manipulate large files or need to run other commands that can take some time to complete, you’ve undoubtedly found yourself in the “Is it actually doing anything?” situation. This is where pv comes in.
Install with:
sudo apt install pv
sudo dnf install pv
Basic usage:
#Monitor file copy progress
pv source_file > destination_file
#Monitor file compression progress
pv file_to_compress | gzip > compressed_file.gz
#Full help and usage
pv --help
man pv
The pv command provides a progress bar complete with percentage and time estimates of job completion. You no longer have to scratch your head wondering if you should let the process go or kill it and try something else.
Related
How to Monitor the Progress of Linux Commands (With pv and progress)
No more flying blind.
9
tldr – Simplified Manual Pages For Common Commands
The man pages built into Linux are a great resource when you need a detailed description of how something works and can be used. Sometimes, however, the information gets so detailed and complex that you end up more confused than when you started reading. That’s where tldr comes in.
Install with:
sudo apt install tldr
sudo dnf install tldr
Basic usage:
tldr tar
tldr cp
tldr <any command here>
The tldr command works similar to man but it will give you simplified and more straightforward explanations. For most commands it also provides easy-to-understand command line examples to help you get through the most common tasks quickly.
10
eza – A Modernized ls Replacement
The directory listing command ls is probably the single most used command on any Linux system—and the oldest. eza gives the same basic functionality but adds many extras that enhance the experience of today’s hyper productive power users.
Install with:
sudo apt install eza
sudo dnf install eza
Basic usage:
#List all including hidden
eza --all
#List tree structure
eza --long --tree --level=3
#List headers, icons, and Git statuses
eza --long --header --icons --git
#Help
eza --help
For developers, analysts, and other power users, eza can quickly become an indispensable tool. It provides more meaningful information than its older counterpart and the color-coded output makes it easy to focus on exactly what you are looking for.
11
tree – View the Tree Structure of File Systems
The tree command will let you view the contents of any directory in a tree-like structure, allowing you to visualize the hierarchy of folders and files. It can be an effective tool to help keep things organized and in the right place.
Install with:
sudo apt install tree
sudo dnf install tree
Basic usage:
#Tree of current directory
tree
#Tree of specific directory
tree /etc/
#Help and usage:
tree --help
man tree
The tree command is a great tool to help you get a visual idea of the layout of any part of your file system. You can look at anything from the entire root directory down to collections of small personal files. It makes it easy to spot duplicated items, small directories that could be consolidated, and more.
One of the most appealing things about Linux is the abundance of alternatives and choices it makes available to everyone. It’s normal to grow accustomed to the way you do things over time, but it never hurts to check out the alternatives once in a while. You just might find a hidden gem that will make a positive difference in your daily workflow.