Replace your Existing Unix Utilities with These Modern Alternatives
Tags: linux, bash, shell, cli
Published: 2021-07-30 17:34:34

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`](https://github.com/sharkdp/bat)
`bat` is a modern replacement for cat written in Rust. Unlike `cat`, this tool supports syntax highlighting for many programming languages out of the box.

![bat displaying Markdown file](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_141448.png)

![bat displaying Ruby file](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_141703.png)

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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_141815.png)

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`](https://github.com/ogham/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_142407.png)

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

![exa shows the Git status](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_142614.png)

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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_142909.png)

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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_143046.png)

## [`dust`](https://github.com/bootandy/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_143553.png)

## [`duf`](https://github.com/muesli/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_144022.png)

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

![duf --all output](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_144254.png)

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

## [`fd`](https://github.com/sharkdp/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_144627.png)

You can also use regular expression to refine your search.

![Regex with fd](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_144834.png)

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

![fd with -e flag](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_145043.png)

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

![exa with -X flag](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_145304.png)

## [`ripgrep`](https://github.com/BurntSushi/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_180233.png)

`rg` also supports regular expressions.

![Regex in rg](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_180432.png)

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

![Recursive search with rg](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_180650.png)

`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](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#automatic-filtering).

## [`tldr`](https://github.com/tldr-pages/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_181337.png)

## [`procs`](https://github.com/dalance/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](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_181647.png)

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

![procs can search processes](https://digitalpress.fra1.cdn.digitaloceanspaces.com/l2biwol/2021/06/Screenshot_20210619_181816.png)

`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`](https://github.com/ajeetdsouza/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](https://github.com/ajeetdsouza/zoxide#third-party-integrations).


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 to [my blog](https://blog.abhattacharyea.dev) for more such articles.