5 modern alternatives to essential Linux command-line tools

Gain new benefits by improving your old command-line tools with updated alternatives.
283 readers like this.
Person using a laptop

In our daily use of Linux/Unix systems, we use many command-line tools to complete our work and to understand and manage our systems—tools like du to monitor disk utilization and top to show system resources. Some of these tools have existed for a long time. For example, top was first released in 1984, while du's first release dates to 1971.

Over the years, these tools have been modernized and ported to different systems, but, in general, they still follow their original idea, look, and feel.

These are great tools and essential to many system administrators' workflows. However, in recent years, the open source community has developed alternative tools that offer additional benefits. Some are just eye candy, but others greatly improve usability, making them a great choice to use on modern systems. These include the following five alternatives to the standard Linux command-line tools.

1. ncdu as a replacement for du

The NCurses Disk Usage (ncdu) tool provides similar results to du but in a curses-based, interactive interface that focuses on the directories that consume most of your disk space.

ncdu spends some time analyzing the disk, then displays the results sorted by your most used directories or files, like this:

ncdu 1.14.2 ~ Use the arrow keys to navigate, press ? for help
--- /home/rgerardi ------------------------------------------------------------
   96.7 GiB [##########] /libvirt
   33.9 GiB [###       ] /.crc
    7.0 GiB [          ] /Projects
.   4.7 GiB [          ] /Downloads
.   3.9 GiB [          ] /.local
    2.5 GiB [          ] /.minishift
    2.4 GiB [          ] /.vagrant.d
.   1.9 GiB [          ] /.config
.   1.8 GiB [          ] /.cache
    1.7 GiB [          ] /Videos
    1.1 GiB [          ] /go
  692.6 MiB [          ] /Documents
. 591.5 MiB [          ] /tmp
  139.2 MiB [          ] /.var
  104.4 MiB [          ] /.oh-my-zsh
   82.0 MiB [          ] /scripts
   55.8 MiB [          ] /.mozilla
   54.6 MiB [          ] /.kube
   41.8 MiB [          ] /.vim
   31.5 MiB [          ] /.ansible
   31.3 MiB [          ] /.gem
   26.5 MiB [          ] /.VIM_UNDO_FILES
   15.3 MiB [          ] /Personal
    2.6 MiB [          ]  .ansible_module_generated
    1.4 MiB [          ] /backgrounds
  944.0 KiB [          ] /Pictures
  644.0 KiB [          ]  .zsh_history
  536.0 KiB [          ] /.ansible_async
 Total disk usage: 159.4 GiB  Apparent size: 280.8 GiB  Items: 561540

Navigate to each entry by using the arrow keys. If you press Enter on a directory entry, ncdu displays the contents of that directory:

--- /home/rgerardi/libvirt ----------------------------------------------------
                         /..
   91.3 GiB [##########] /images
    5.3 GiB [          ] /media

You can use that to drill down into the directories and find which files are consuming the most disk space. Return to the previous directory by using the Left arrow key. By default, you can delete files with ncdu by pressing the d key, and it asks for confirmation before deleting a file. If you want to disable this behavior to prevent accidents, use the -r option for read-only access: ncdu -r.

ncdu is available for many platforms and Linux distributions. For example, you can use dnf to install it on Fedora directly from the official repositories:

$ sudo dnf install ncdu

You can find more information about this tool on the ncdu web page.

2. htop as a replacement for top

htop is an interactive process viewer similar to top but that provides a nicer user experience out of the box. By default, htop displays the same metrics as top in a pleasant and colorful display.

By default, htop looks like this:

 

In contrast to default top:

 

In addition, htop provides system overview information at the top and a command bar at the bottom to trigger commands using the function keys, and you can customize it by pressing F2 to enter the setup screen. In setup, you can change its colors, add or remove metrics, or change display options for the overview bar.

 

While you can configure recent versions of top to achieve similar results, htop provides saner default configurations, which makes it a nice and easy to use process viewer.

 

To learn more about this project, check the htop home page.

3. tldr as a replacement for man

The tldr command-line tool displays simplified command utilization information, mostly including examples. It works as a client for the community tldr pages project.

This tool is not a replacement for man. The man pages are still the canonical and complete source of information for many tools. However, in some cases, man is too much. Sometimes you don't need all that information about a command; you're just trying to remember the basic options. For example, the man page for the curl command has almost 3,000 lines. In contrast, the tldr for curl is 40 lines long and looks like this:

$ tldr curl

# curl
  Transfers data from or to a server.
  Supports most protocols, including HTTP, FTP, and POP3.
  More information: <https://curl.haxx.se>.

- Download the contents of an URL to a file:

  curl http://example.com -o filename

- Download a file, saving the output under the filename indicated by the URL:

  curl -O http://example.com/filename

- Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:

  curl -O -L -C - http://example.com/filename

- Send form-encoded data (POST request of type `application/x-www-form-urlencoded`):

  curl -d 'name=bob' http://example.com/form                                                                                            
- Send a request with an extra header, using a custom HTTP method:

  curl -H 'X-My-Header: 123' -X PUT http://example.com                                                                                  
- Send data in JSON format, specifying the appropriate content-type header:

  curl -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users/1234

... TRUNCATED OUTPUT

TLDR stands for "too long; didn't read," which is internet slang for a summary of long text. The name is appropriate for this tool because man pages, while useful, are sometimes just too long.

In Fedora, the tldr client was written in Python. You can install it using dnf. For other client options, consult the tldr pages project.

In general, the tldr tool requires access to the internet to consult the tldr pages. The Python client in Fedora allows you to download and cache these pages for offline access.

For more information on tldr, you can use tldr tldr.

4. jq as a replacement for sed/grep for JSON

jq is a command-line JSON processor. It's like sed or grep but specifically designed to deal with JSON data. If you're a developer or system administrator who uses JSON in your daily tasks, this is an essential tool in your toolbox.

The main benefit of jq over generic text-processing tools like grep and sed is that it understands the JSON data structure, allowing you to create complex queries with a single expression.

To illustrate, imagine you're trying to find the name of the containers in this JSON file:

{
  "apiVersion": "v1",
  "kind": "Pod",
  "metadata": {
    "labels": {
      "app": "myapp"
    },
    "name": "myapp",
    "namespace": "project1"
  },
  "spec": {
    "containers": [
      {
        "command": [
          "sleep",
          "3000"
        ],
        "image": "busybox",
        "imagePullPolicy": "IfNotPresent",
        "name": "busybox"
      },
      {
        "name": "nginx",
        "image": "nginx",
        "resources": {},
        "imagePullPolicy": "IfNotPresent"
      }
    ],
    "restartPolicy": "Never"
  }
}

If you try to grep directly for name, this is the result:

$ grep name k8s-pod.json
        "name": "myapp",
        "namespace": "project1"
                "name": "busybox"
                "name": "nginx",

grep returned all lines that contain the word name. You can add a few more options to grep to restrict it and, with some regular-expression manipulation, you can find the names of the containers. To obtain the result you want with jq, use an expression that simulates navigating down the data structure, like this:

$ jq '.spec.containers[].name' k8s-pod.json
"busybox"
"nginx"

This command gives you the name of both containers. If you're looking for only the name of the second container, add the array element index to the expression:

$ jq '.spec.containers[1].name' k8s-pod.json
"nginx"

Because jq is aware of the data structure, it provides the same results even if the file format changes slightly. grep and sed may provide different results with small changes to the format.

jq has many features, and covering them all would require another article. For more information, consult the jq project page, the man pages, or tldr jq.

5. fd as a replacement for find

fd is a simple and fast alternative to the find command. It does not aim to replace the complete functionality find provides; instead, it provides some sane defaults that help a lot in certain scenarios.

For example, when searching for source-code files in a directory that contains a Git repository, fd automatically excludes hidden files and directories, including the .git directory, as well as ignoring patterns from the .gitignore file. In general, it provides faster searches with more relevant results on the first try.

By default, fd runs a case-insensitive pattern search in the current directory with colored output. The same search using find requires you to provide additional command-line parameters. For example, to search all markdown files (.md or .MD) in the current directory, the find command is this:

$ find . -iname "*.md"

Here is the same search with fd:

$ fd .md

In some cases, fd requires additional options; for example, if you want to include hidden files and directories, you must use the option -H, while this is not required in find.

fd is available for many Linux distributions. Install it in Fedora using the standard repositories:

$ sudo dnf install fd-find

For more information, consult the fd GitHub repository.

Great alternatives alongside proven utilities

While I still use all the old essential tools regularly, especially when connecting remotely to servers, the alternative tools provide some extra benefits that are valuable in many scenarios. They particularly help me manage and work on my Linux desktop and laptop machines.

Do you use any other tools that help your workflow? Add them in the comments section below.

What to read next
Tags
Avatar
Ricardo Gerardi is Technical Community Advocate for Enable Sysadmin and Enable Architect. He was previously a principal consultant at Red Hat Canada, where he specialized in IT automation with Ansible and OpenShift.

29 Comments

I use "meld" in place of "diff"

Nice list, thanks. And yep, here's another along these lines: ranger.

Ranger provides a much easier way to visually traverse files and folders (via cursor and keyboard navigation, much like how ncdu above does). In seconds, one could dig around in some folders and view or edit a file with just a few keystrokes.

It's a great alternative to using multiple cd/ls cmds and then less/cat or your favored editor. Even if using tab completion with those, there are times when using ranger will simply be a lot faster. And this is especially true when looking into multiple files in one or more directories.

Thanks for the comment ! I love ranger. It was in my list for this article but I decided to write one specifically for it. Stay tuned.

In reply to by Charlie Arehart (not verified)

exa for ls

Thanks. I'll give it a try.

In reply to by Keith Peters (not verified)

Another (fancy looking) alternative for ls is lsd.

In reply to by Keith Peters (not verified)

Bat instead of cat, ripgrep instead of grep, httpie instead of curl, bashtop instead of htop, autojump instead of cd...

These are cool suggestions. You should write an article about your choices and send it to us for publication :-)

I'll definitely be checking some of these out, thanks!

In reply to by Miguel Perez (not verified)

Thanks for the suggestions. I'll check some of them out. I tried bashtop before but, at that time, it consumed too many system resources so I stayed with htop.

In reply to by Miguel Perez (not verified)

ack instead of grep for files. Million times faster.

The yq command line utility is useful too. It's just like jq, except for yaml files and has the ability to convert yaml into json.

Just spent a few hours checking the suggestions in this article and the comments. Wow! All great, thanks!
ranger and autojump are game changers

I'm surprised I haven't seen anyone say ip instead of ifconfig.

Glances is a great top replacement too

Thanks for the comment. Glances looks nice. It's an interesting project.

In reply to by Matt howard (not verified)

Try "mtr" instead of traceroute
Try "hping2" instead of ping
Try "pigz" instead of gzip

Ack instead grep code

I’ve never used ncdu, but I recommend “duc” as a du replacement https://github.com/zevv/duc/

You run a separate “duc index” command to capture disk space usage in a database file and then can explore the data very quickly with “duc ui” ncurses ui. There’s also GUI and web front-ends that give you a nice graphical pie chart interface.

In my experience the index stage is faster than plain du. You can choose to re-index only certain folders if you want to update some data quickly without rescanning everything.

glances as a replacement for htop
rg as a replacement for grep / ack

Imho, jq uses a syntax that's ok for simple queries but quickly becomes horrible when you need more complex queries. Pjy is a sensible replacement for jq, having an (improved) python syntax which is familiar to many people and much more readable: https://github.com/hydrargyrum/pjy

Thanks. Never tried "pyj". I will take a look. For more compex queries, I use "jid" to navigate the data and create the query for me. Then I use the output in "jd" for scripts.

In reply to by wurn (not verified)

Ricardo, thank you’re the article. It was interesting to read it. After IBM Netcool, it is definitely a very interesting shift in the career.

Also along the lines of command-line alternatives, take a look at marcel, which is a modern shell: https://marceltheshell.org. The basic idea is to pipe Python values instead of strings, between commands. It integrates smoothly with host commands (and, presumably, the alternatives discussed here), and also integrates remote access and database access.

“tuptime” instead of “uptime”.
It tracks the history of the system, not only the current one.

One downside of all of this is that there are even more things to remember. I learned find, diff, cat, vi (and ed), grep and a few others starting in 1976 on 6th edition. They have been enhanced some, over the years (for which I use man when I need to remember), and learned top and other things as I needed them, but things I did back then still work great now. KISS is still a "thing". Especially in scripts one is going to use on a wide variety of distributions or for a long time. These kind of tweaks are fun and all, but add complexity and reduce one's inter-system mobility. (And don't get me started on systemd 8P).

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.