My Favorite Command Line Tools
Over the course of years using the command line, I've found some handy tools. This list is to remember everything I've collected thus far.
A cat(1) clone with syntax highlighting and Git integration.
cat is one of the most useful tools of the command line and
bat just brings it into the modern era with syntax higlighting and some other neat tidbits. Just alias
bat and don't look back. My only recommendation would be to make line numbers not present by default!
dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max out your SSD, providing relevant information as fast as possible. Optionally delete superfluous data, and do so more quickly than
With limited hard drive space one often wants to take stock of what currently is taking up all the space and remove the things you no longer want.
dua is great in that it allows you easily see what is taking up space in a filesystem directory and then create a temporary list of things to remove them. It's the first thing I reach for when disk space becomes a problem.
ncdu is a close and more well-known second here, but
dua is definitely more forgiving in the deletion process and allows you to build a list before committing to deletion.
du + rust = dust. Like du but more intuitive.
du is a classic CLI tool but
dust definitely hits the 'more intuitive' mark for me especially because I always need to remember the flags for
du to get at the output that I actually want which is a sizing of directories with different depths.
A command-line benchmarking tool.
time is a pretty good tool that most people are familiar with but I came across
hyperfine while looking for ways to compare API requests to Stripe's API and couldn't be happier. It's written in Rust and has some very convenient output formats.
mtr combines the functionality of the 'traceroute' and 'ping' programs in a single network diagnostic tool.
An amazing tool to do some network diagnostics and see where things might be going wrong. Has been effective in the past for identifying where exactly in the chain of nodes things might be going wrong. Has allowed me to answer the question, "is my current predicament due to something I have done to my home network?" time after time.
ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don't have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.
Very useful tool for drilling into what is taking up space. I used DaisyDisk for an annoyingly long time longing for the same experience as WinDirStat on Mac.
ncdu has become my main tool for figuring out space issues or unexpected directory growth on any of my machines.
restic is a backup program that is fast, efficient and secure.
I have two datasets that would be horrible to lose:
- A lifelong repository of pictures
- A lifelong repository of documents of all varieties.
I realized that for both of these repos, they were stored in exactly one place and one place alone which does not follow the very helpful 3-2-1 backup strategy. I was also putting all my faith in Google which probably never cause me any issues, but with files so important, is that enough? Certainly not.
So, in a weekend I was able to set up
restic and automate the process of backing up all these files to both Backblaze B2 storage and an offsite & off-continent Raspberry Pi with an external SSD. Now I have a few layers of resilience when it comes to my storage failing and/or losing access to my Google account.
xsv is a command line program for indexing, slicing, analyzing, splitting and joining CSV files. Commands should be simple, fast and composable:
- Simple tasks should be easy.
- Performance trade offs should be exposed in the CLI interface.
- Composition should not come at the expense of performance.
I recently needed to scrape a website and output different values on a page into a CSV for easier consumption by other people at work. The biggest hassle is of course taking multiline strings and putting them into a csv file. On every iteration of my script, I started by opening up Numbers (😵) and examining the result but that became very onerous. With
xsv's nicely formatted command line output I could rerun my extraction script and then verify the csv output without leaving the command line.
10/10 would use this to csv again.