07-17-2023 01:46 PM - edited 07-17-2023 01:47 PM
This is Part 2 of the Extremely Cool Command Line Tools - Supercharged with Rust series. For Part 1, see Extremely Cool Command Line Tools - Supercharged with Rust - {Part 1}
Skilled network engineers, developers, system admins, etc. use Unix/Linux commands line tools/utilities such as …. cat, ls, man, ps, etc..
Most of these were originally written for Unix or Unix-like operating systems, have been around for decades and, while they are still very useful, we can now take them to the next level with their equivalents in the Rust language. Some are upgrades to existing tools and some are brand new and much needed.
Rust is a newer language (2010) that has become extremely popular. It is a powerful, fast, multi-platform, multi-paradigm, high-level, general-purpose programming language, which was recently added to the Linux kernel. According to the Stack Overflow Developer Surveys, Rust has been the "most loved programming language" every year from 2016 to 2022 (inclusive).
Just install Rust and each tool you want to try out. Most of these tools can be installed with the standard operating system package managers, or you can use the Rust package manager, known as Cargo, which should work on most platforms. If you need help installing and setting up Rust, just scroll to the bottom of this article.
Here are the command line tools I’ll be talking about in this article:
dtg - Date/time CLI utility
Follow install instructions:
Get current date/time in UTC and RFC 3339 format:
$ dtg
2023-07-06T08:11:10Z
Get current date/time in the local timezone and default format:
$ dtg -l
Thu 06 Jul 2023 04:11:10 EDT
Get current date/time in explicit timezone and default format:
$ dtg -z MST
Thu 06 Jul 2023 01:11:10 MST
$ dtg -z America/Los_Angeles
Thu 06 Jul 2023 01:11:10 PDT
And much more!
fd-find - a simple, fast and user-friendly alternative to find
Follow install instructions:
fd-find — command-line utility in Rust // Lib.rs
fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find.
fd is designed to find entries in your filesystem. The most basic search you can perform is to run fd with a single argument: the search pattern. For example, assume that you want to find an old script of yours (the name included netflix):
> fd netfl
Software/python/imdb-ratings/netflix-details.py
The search pattern is treated as a regular expression. Here, we search for entries that start with x and end with rc:
> fd '^x.*rc$'
X11/xinit/xinitrc
X11/xinit/xserverrc
If we want to search a specific directory, it can be given as a second argument to fd:
> fd passwd /etc
/etc/default/passwd
/etc/pam.d/passwd
/etc/passwd
fd can be called with no arguments. This is very useful to get a quick overview of all entries in the current directory, recursively (similar to ls -R):
….and this is just a small sample of what fd-find can do!
Fundoc - the right way to generate documentation
Follow install instructions:
Fundoc — command-line utility in Rust // Lib.rs
Fundoc is a language agnostic documentation generator which allows you to describe business logic in one particular source file and generate documentation from it. With Fundoc, you can describe business logic in one particular source file and generate documentation from it.
You can create a config file by executing fundoc --init command and answering few questions. Fundoc supports mdBook, so you can generate docs in that format if you desire. You can even write your own plugins to enhance Fundoc's abilities. To do so, you can simply write a Lua plugin. You can also use Fundoc's GitHub Action to automate documentation generation.
pueue- A cli tool for managing long running shell commands
Follow install instructions:
Pueue — command-line utility in Rust // Lib.rs
Pueue is a command-line task management tool for sequential and parallel execution of long-running tasks.
Simply put, it's a tool that processes a queue of shell commands. On top of that, there are a lot of convenient features and abstractions.
Since Pueue is not bound to any terminal, you can control your tasks from any terminal on the same machine.
rustscan - Faster Nmap Scanning with Rust
Follow install instructions:
RustScan — command-line utility in Rust // Lib.rs
The Modern Port Scanner. Find ports quickly (3 seconds at its fastest). Run scripts through our scripting engine (Python, Lua, Shell supported).
t-rec - Blazingly fast terminal recorder that generates animated gif images for the web
Follow install instructions:
t-rec — command-line utility in Rust // Lib.rs
Features include:
Tokei - a program that displays statistics about your code
Follow install instructions:
Tokei — command-line utility in Rust // Lib.rs
Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language.
trasher - A small command-line utility to replace rm and del by a trash system
Trasher — command-line utility in Rust // Lib.rs
It works by moving items to delete to a trash directory instead of deleting them immediatly. As moving a single item is nearly instant (even when it's a large directory), while deleting items recursively can take quite a long time, Trasher is faster than rm, especially for large directories.
watchlog - A command-line utility to help you see how a log is moving
watchlog — command-line utility in Rust // Lib.rs
Do you ever have a terminal watching logs or recompiling on save and you aren't sure if the most recent messages are from the change you just made, or 10 minutes ago? watchlog will help you but adding a message at the bottom of your terminal that haven't produced output recently. After a short period of no output watchlog will start displaying the time since last output below the command.
When the command produces more output it will look like normal if it hasn't been too long, however if it has been a while watchlog will inject a timestamp so that the logs are grouped by when they occurred when you scroll up.
yj - Command line tool that converts YAML to JSON
Follow install instructions:
YJ — command-line utility in Rust // Lib.rs
yj is a Simple command line tool to convert a YAML input file into a JSON output file.
Installing and Setting Up Rust
export PATH="$HOME/.cargo/bin:$PATH"
At the time of writing, the command looks like this:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
% rustc –version
rustc 1.67.1 (d5a82bbd2 2023-02-07)
We’re good to go!
Mapping New Commands to the Old Command Names
If you don’t want to learn the names of the new commands, you can create aliases and map the new tools to the old names. For instructions of how to do that, see my Knowledge Base Article titled ‘Developer Basics: Creating Aliases with bashrc and zshrc’
Additional Info
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: