cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1050
Views
1
Helpful
0
Comments
Alexander Stevenson
Cisco Employee
Cisco Employee

AlexStevenson_0-1689625896344.png

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 …. catlsmanps, 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
  • fd-find - a simple, fast and user-friendly alternative to find
  • Fundoc - the right way to generate documentation
  • pueue- A cli tool for managing long running shell commands
  • rustscan - Faster Nmap Scanning with Rust
  • t-rec - Blazingly fast terminal recorder that generates animated gif images for the web
  • Tokei - a program that displays statistics about your code
  • trasher - A small command-line utility to replace rm and del by a trash system
  • watchlog - A command-line utility to help you see how a log is moving
  • yj - Command line tool that converts YAML to JSON

 

dtg - Date/time CLI utility

AlexStevenson_1-1689625896358.png

Follow install instructions:

https://lib.rs/crates/dtg

 

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

AlexStevenson_2-1689625896368.png

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

AlexStevenson_3-1689625896369.png

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

AlexStevenson_4-1689625896374.png

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

AlexStevenson_5-1689625896375.png

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).

Features

  • Scans all 65k ports in 3 seconds.
  • Full scripting engine support. Automatically pipe results into Nmap, or use our scripts (or write your own) to do whatever you want.
  • Adaptive learning. RustScan improves the more you use it. No bloated machine learning here, just basic maths.
  • The usuals you would expect. IPv6, CIDR, file input and more.
  • Automatically pipes ports into Nmap.

 

 

 

t-rec - Blazingly fast terminal recorder that generates animated gif images for the web

AlexStevenson_6-1689625896376.png

Follow install instructions:

t-rec — command-line utility in Rust // Lib.rs

 

Features include:

  • Screenshotting your terminal with 4 frames per second (every 250ms)
  • Generates high quality small sized animated gif images or mp4 videos
  • Runs on MacOS, Linux and NetBSD
  • Uses native efficient APIs
  • Runs without any cloud service and entirely offline
  • No issues with terminal sizes larger than 80x24
  • No issues with fonts or colors
  • No issues with curses based programs
  • No issues with escape sequences
  • No record and replay - just one simple command to rule them all
  • Can record every arbitrary window you want (e.g. browser, ide)

 t-rec.gif

 

 

 

Tokei - a program that displays statistics about your code

AlexStevenson_8-1689625896395.png

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.

 
tokei.png

 

 

 

 trasher - A small command-line utility to replace rm and del by a trash system

 
textfx (25).png
Follow install instructions:

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

 
textfx (21).png
Follow install instructions:

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.

 
Picture1.gif

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

 
textfx (24).png

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

 

  1.  Rust is installed and managed by the rustup tool. Add it to your PATH by appending one of the following to your .bash_profile, .bashrc or .zshrc configuration files:

export PATH="$HOME/.cargo/bin:$PATH"

  1. You can install Rust using cURL. The most recent version of the command will be found at https://www.rust-lang.org/tools/install

At the time of writing, the command looks like this:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Restart your shell with ‘exec bash’, ‘exec zsh’, etc..
  2. Check that Rust is installed:
% 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

  • This was just the first installment in this series; more articles to come!
  • Inspiration for this article was provided by DJ Ware @CyberGizmo

 

 

 

Getting Started

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:

Quick Links