When you get started out with learning Linux, you are introduced to the command-line interface and a set of standard Linux commands that have been there since the Linux kernel was written.
While the good old Linux commands work as intended, developers have come up with modern alternative CLI tools that extend the functionality of these standard Linux commands. They are more effective and ship with added functionalities.
In this guide, we learn some of the modern alternatives to Linux commands that you might consider trying out.
The ripgrep tool is a handy command-line tool that combines the functionalities of the silver searcher, grep, and ack tools.
Ripgrep is a search tool that recursively searches the current directory for a regex pattern. By default, ripgrep skips hidden files and directories, and binary files.
The ripgrep tool is supported on Windows, Linux, and macOS with binary downloads for each computing environment. ripgrep executable is called rg. The basic search syntax looks like this.
rg keyword filename
For example, to search for the keyword ‘Panama’ in the /usr/share/zoneinfo file, execute the command:
rg Panama /usr/share/zoneinfo/
2. Lsd ( LSDeluxe )
The ls command provides only a small sub-set of options when listing files. If you want extended functionality, then try out the Lsd tool which is a revamp and a perfect alternative to the ls command.
The lsd command-line tool provides added functionality such as colorized output, tree-format view, sort feature, and so on.
The tool is available for Linux, Windows, macOS, Android, and BSD releases.
To give it a try, run the lsd command with the long format option ( -l )
Exa is a fast and modern replacement for the ls command. It is an improved file lister than provides additional tools and better defaults when compared to the ls command.
Exa is portable, blazing-fast, and comes with a comprehensive feature set. It applies different colors to its output in order to distinguish different file types and metadata. Different file types are colored differently, and so are the file permissions. The user and group columns are highlighted for the current user.
In addition, exa also displays a file’s extended attributes as well as standard filesystem information including inodes, the number of blocks, and a file’s various dates and times.
Exa takes the following basic syntax in which it lists all the contents of the current directory
To realize the full potential of the exa CLI tool, use the long listing format as shown
4. Fzf ( Fuzzy Finder )
Fzf, also known as Fuzzy Finder, is a general-purpose, cross-platform command-line tool that is more like the grep utility.
The executable component is fzf. When invoked, it reads lines from stdin, then launches an interactive finder dialogue, and finally writes selected items to stdout.
What sets it apart from other tools such as find is its interactive finder dialogue that filters out items as you type. This eliminates the execution of too many commands when searching for items. You can type multiple characters and the utility will match the lines bearing the characters.
To launch the interactive finder, run the following command:
find * -type f | fzf > selected
Then start searching by typing the search term.
Skim is a search tool that is an alternative to the previously-mentioned Fuzzy Finder tool. It matches all the strings that contain the search term including hidden files.
Skim provides an executable known as sk which allows you to interactively search for files as you type on the terminal.
You can invoke skim directly by running the command sk. In addition, you can integrate it with other commands such as grep, ack, and rg for searching content in a directory.
To start searching interactively in the current directory, simply run:
Bat is an excellent alternative for the cat command. What makes it different is that it supports syntax highlighting for a wide range of programming & markup languages.
Additionally, Bat provides seamless integration with Git. It communicates with the Git version control tool to show instances where a file has been modified.
When used with the -A or --show-all option, you can display and highlight non-printable characters.
And just like the cat command, you can pipe the output to a pager-like less or more to enable smooth scrolling when dealing with long text files.
Written in Rust language, Procs is a perfect alternative for the ps command. Key features of the procs utility include colored and human-readable output, multi-column keyword search, pager support, and watch mode, like the top utility.
Procs utility is fully supported in the Linux environment and experimentally supported on Windows and macOS.
There are two major ways of installing Procs on your Linux system. You can install it from snapcraft as a snap package which will work on most major Linux distributions such as Debian, Ubuntu, Fedora, Mint, OpenSUSE, and RHEL. Alternatively, you can use a distribution package manager to install Procs.
To list all the running processes, run the command:
With the --tree option, you can display the processes sorted by dependency order.
Sd is an intuitive search and replace command-line tool that is an alternative to the sed command.
Sd uses regex expressions in a simpler and more intuitive manner in comparison to sed or awk command which is complex in nature.
Sd also provides support for non-regex find and replace functionality. Here, no backslashes are required and neither is there a need to remember special characters that need to be escaped.
Find and replace expressions exist separately which makes them easy and convenient to read and write.
Let’s take a simple example.
Let us compare replacing all occurrences of 'Unix' with 'Linux'.
sd Unix Linux filename
When using sed, the syntax would appear as follows.
sed s/Unix/Linux/g filename
From the above syntax, you can see that sd provides a simpler syntax compared to sed.
The fd program is a fast, simple, and user-friendly alternative to find command. While it does not support all the powerful functionalities of the find command, it provides simplified defaults for a majority of the use cases.
- Quite fast thanks to parallelized directory traversal.
- Shorter and easier syntax which is 50% shorter than find.
- Intuitive and user-friendly syntax which takes the form: fd PATTERN instead of find -iname '*PATTERN*'
- The program uses colorized output to distinguish different file types (same as ls).
- Smart case: By default, the search is case insensitive. However, it switches to case-sensitive if the pattern contains an uppercase character*.
- Support for parallel command execution.
- Ignores hidden directories and files, by default.
- Ignores patterns from your .gitignore, by default.
To perform a single search, simply run the fd command with a single argument which is the search pattern:
When executed like this, the fd utility displays all the files in the current directory that contain the search pattern.
To search a specific directory, provide the directory as the second argument:
fd cron /etc
In the above example, the fd program searches for files with the ‘cron’ search pattern in the /etc directory.
Duf, short for Disk Usage Free utility, is a modern replacement for the df command. The duf utility displays disk usage statistics on the terminal in a colorized style and in a more presentable, and organized format.
Duf is supported on all computing platforms including Linux, BSD, Android, Windows, and macOS.
- Colorized output
- Ability to scale up and down in order to fit your terminal's dimensions
- Ability to sort the results according to your preferences.
- Can easily save the output in JSON format.
- Groups & filters devices
There are two main ways of installing Duf. You can install it from source by cloning Duf from the git repository, or you can install it using your distribution’s package manager.
You can run the duf utility without any command arguments as follows.
This lists all the devices and mount points. You can specify a specific directory by mentioning it as an argument. For example, in the example below, we are listing disk usage statistics for the /home mount point.
Tldr-pages ( TLDR is an acronym for "Too Long; Didn't Read" ) is a collection of community-maintained help pages that contain example usages of various command-line tools.
These help pages aim to be simpler and easy to go through compared to the traditional man pages. In summary, they simplify the man pages by offering practical examples of the usage of the command-line tools.
Now, you can run the following command to check the tldr page for mkdir, in the same way, that you would display its man pages.
Similar projects to TLDR include Cheat, kb, and Navi.
12. Ncdu ( NCurses Disk Usage )
Ncdu is a user-friendly disk usage analyzer with a ncurses interface. It was built to help find space hogs on a remote headless server that does not have a graphical setup available, although it can still be used on regular desktop environments.
Ncdu aims to be a simple yet fast and easy-to-use utility that can be deployed on any minimal POSIX-like environment where ncurses has been installed.
Ncdu is packaged for a number of computing environments including macOS, OpenBSD, FreeBSD, and Linux ( Alpine, Ubuntu, Debian, Fedora, Slackware, Void Linux, Gentoo, RHEL & OpenSUSE).
Once installed, simply run the following command to show disk usage statistics.
HTTPie is a user-friendly and open-source CLI HTTP Client that is designed to make API calls from the terminal as human-friendly as possible.
HTTPie is designed for testing, debugging, and interacting with APIs and web servers. It uses http and https commands to send arbitrary HTTP requests to web servers. They make use of simple and natural syntax and also display the output in a colorized output.
- Built-in JSON support
- Forms and file uploads
- Formatted and colorized terminal output
- HTTPS, proxies, and authentication
- Expressive and intuitive syntax
- Persistent sessions
HTTPie is supported on Linux, macOS, Windows, and FreeBSD. On Linux, you can install it from snap as follows:
sudo snap install httpie
Please note that the tools we have just covered are not drop-in replacements for the standard Linux commands. In fact, some of them - such as ripgrep - do not conform to POSIX standards and hence the good old commands are preferred. These are tools that you can explore out of adventure and curiosity, especially while working on your Linux PC.
Do you think we missed out on some? Kindly fill us in.