Modernize Linux

New tools for a modern day

Using old tools

I have been using Linux ever since the late 1990’s. I switched between Linux, Windows and macOS over the years, but since 2015 I have been a full time user. I currently use POP!_os on my daily machine and I have a Dell XPS13 Developer Edition laptop that runs Ubuntu.

The tools I use daily in the terminal are part of something called coreutils, Wikipedia has a nice listing of them, and they include commands like ls, cat, cp, mv and the list goes on. These tools are familiar to anyone using Linux as they help you manage your file system.

These tools are very old; ls has been part of the X/Open Portability Guide set of commands since 1987, and transitioned into coreutils when that was formed in 2002. These tools work incredibly well at giving the basic information and functionality that is needed to manage the system.

The age of Rust

As the C programming language has found a more modern version of itself in the Rust programming language many C programmers have started transitioning to Rust. Rust is more of a safe language then C as it rigorously tries to prevent any form of memory management mistakes.

As this group has been transitioning it has also marked a new wave of re-envisioned old tools. System programmers have to work on something to learn a new language and many choose to re-implement an old tool from the coreutils library. These tools come with new insights and modern ideas. They are not limited to working on some archaic system that is still supported by Linux and its distributions.

Several of these tools have replaced the old ones on my daily workstation.

The tools I replaced

Note: On POP!_os these tools are all install-able using apt-get.

cat

The single biggest improvement has come from replacing cat with bat. The tool has a complete new take on listing file contents. By default it will show line numbers, syntax highlight known file types and provide a scrolling area in case the file it too large for the current terminal.

bat.png
Figure 1: Presenting a file with bat

Obviously the default also has downsides, selecting more then 1 line to copy will now also include line numbers. A quick command line flag will switch to plain mode. In this mode only the text is syntax highlighted and all the other niceties are gone. This still is infinitely better then the monotone color of the standard cat tool.

ls

It might sound strange to replace the ls tool, but compare the below screenshot with the regular ls output.

ls.png
Figure 2: Listing a directory with exa

The command to gain the above screenshot is exa -alg --group-directories-first. The g is added as the tool, by default, does not show the group. All the files are color coded and a tree command is built in using --tree, things I like to use a lot.

ls-tree.png
Figure 3: Showing a tree listing using exa

These additions have made exa replace ls for me.

grep

When working with large code-bases the grep command is invaluable. During the AWAE course by Offensive Security the student is required to learn how to effectively search large targets. This is where I found rg to be superior to grep for any form of extended use.

In the screenshot below a search is done for the expect word in a Rust project. By providing a file-type flag to only search in Rust files 4 results are returned. Using a regular grep command like grep -r expect * would yield more then 5000 results.

rg.png
Figure 4: Presenting the results of a rg search

The output format, as seen above, is also greatly superior to that of the standard tool.

Replacing the old with the new

In order to use these tools on a daily basis the old ones can be masked by providing a shell alias in the initialization file. For the zsh shell this would be in .zshrc, for bash in .bashrc, etc.

alias grep='rg'
alias ls='exa -alg --group-directories-first'
alias cat='bat'

Although these are 3 tools that have replaced the standard ones, many defaults are still incredibly useful and irreplaceable. There are projects working on replacing ps and other tools. There even is a website dedicated to coreutils-alternatives.

A word of warning

Do not replace any tools in your workflow unless you know they are better then the original for your use-case. If you are not fully familiar with the tools you might get strange, unexpected results. As with any new tools some time is required to be invested in getting to know the new tools as you have done in the past with the old tools when starting to use Linux.

Go back to the homepage.