Replace your Existing Unix Utilities with These Modern Alternatives

Replace your Existing Unix Utilities with These Modern Alternatives

In your day-to-day Unix or Linux usage you use different tools like cd, ls, grep, or find. These are ubiquitous utilities found in every Nix system. However, they were created a long time ago, when computers lacked computational power and speed. These tools were tailored towards systems with very little resources. Nowadays, our systems are far better and our requirements are far bigger. In this article, I will show you some utilities aimed towards providing modern replacements for these useful Unix utilities.

bat

bat is a modern replacement for cat written in Rust. Unlike cat, this toll supports syntax highlighting for many programming languages out of the box.

bat displaying Markdown file
bat displaying Ruby file

Another interesting feature of bat is native Git integration. If you run bat from a git repository, you will get a "git gutter" indicating modification with respect to the index.

Git gutter with bat

By default, bat automatically pipes its own output into a pager (e. g. less) when the output is bigger than one page. Which means you don't have to manually pipe the output into less

If you wish to replace cat with bat, you can use the following alias -

alias cat='bat --style header --style rules --style snip --style changes --style header'

exa

exa is a modern alternative for ls, also written in Rust. Apart from some minor differences, exa has all the features of ls, along with Git integration and colors.

exa uses colors to distinguish files and folders

Using the --git option, you can quickly see the Git status of files inside a Git repo.

exa shows the Git status

You can use the --tree option to get a tree view of the files. Using the --level option, you can specify the depth of the tree.

exa tree view

You can use the --icons option to display little icons next to the filenames, provided your font contains those icons. You can install any Nerd Font and you should be good to go.

exa displaying icons

dust

dust is an alternative for du, and it should not be surprising that it is written in Rust! When you run dust, it shows a nice tree structure of files and folders along with a visualization of sizes.

Output of dust

duf

duf is a replacement for the df utility. Guess which language it is written in? Nope, not Rust. It's written in Go.

duf makes the output easy to understand and visualize. It has color highlights and percentage bars so that you can easily understand your disk usage. Also, it separates local devices, network devices, and special devices in separate regions.

duf output

You can use duf --all to list all devices including pseudo, duplicate and inaccessible devices.

duf --all output

You can also use duf --json to output a convenient JSON file.

fd

fd is an alternative for the find utility. And we're back again to the Rust world!

When you run fd command with a search pattern, it will search the current directory for the pattern and show you the file list.

fd output

You can also use regular expression to refine your search.

Regex with fd

You can search for a specific extension by using the -e flag. You can combine this with the search pattern.

fd with -e flag

Just like find, you can run a command on every found file using the -X flag.

exa with -X flag

ripgrep

ripgrep is a super fast grep alternative written in Rust. Apart from being super fast, it also respects your .gitignore.

ripgrep is invoked through the rg command. The basic usage is similar to grep. You provide a pattern and a file to find the pattern in. rg by default also shows the line numbers and highlights the search term.

rg searching for a pattern

rg also supports regular expressions.

Regex in rg

If you do not specify a file name, rg will perform a recursive search. Similar to grep -r.

Recursive search with rg

rg respects your .gitignore. Which means if a file is matched in .gitignore, it will not be searched. You can read more about how to use this feature in the manual.

tldr

How many times have you forgot how a command works, and opened the man pages only to get buried under tons and tons of documentation, when you only wanted some examples? tldr is not an exact replacement for man pages, but it is a community effort to simplify the manual pages. Rather than throwing an ocean of information about you, tldr lists examples and small details, enough to get you started.

tldr tar output

procs

Yet another tool written in Rust. procs is a modern alternative for ps. When you run procs, it shows you a list of running processes in a nicely themed output. The output is automatically paged.

procs output

If you run procs followed by the name of a process, and procs will search for that process, similar to running ps aux | grep process

procs can search processes

procs can also show other information which are not available to ps, like TCP/UDP port, Read/Write throughput, or Docker container name. You can read more about them in the procs manual.

zoxide

zoxide is a fast replacement for the cd command. It keeps track of the directories you visit and can quickly take you to the directory you want to go.

You can use zoxide just like the regular cd command. For example,

z foo/bar/baz

zoxide keeps a track of the directories you visit, and you can use fuzzy finding to quickly visit a directory you have visited before.

z baz # Takes you the highest ranking directory matching baz

zoxide also comes with various integrations with many different tools. Check them out from their manual.


I hope you could find your next favourite command line utility from this post :). If you liked this article, do not forget to share and subscribe for more such articles.