Science and technology

5 trendy alternate options to important Linux command-line instruments

In our each day use of Linux/Unix methods, we use many command-line instruments to finish our work and to grasp and handle our methods—instruments like du to watch disk utilization and high to indicate system assets. Some of those instruments have existed for a very long time. For instance, high was first launched in 1984, whereas du‘s first launch dates to 1971.

Over the years, these instruments have been modernized and ported to completely different methods, however, basically, they nonetheless observe their unique thought, look, and really feel.

These are nice instruments and important to many system directors’ workflows. However, in recent times, the open supply neighborhood has developed various instruments that supply further advantages. Some are simply eye sweet, however others drastically enhance usability, making them an important selection to make use of on trendy methods. These embrace the next 5 alternate options to the usual Linux command-line instruments.

1. ncdu as a alternative for du

The NCurses Disk Usage (ncdu) instrument gives comparable outcomes to du however in a curses-based, interactive interface that focuses on the directories that eat most of your disk area.

ncdu spends a while analyzing the disk, then shows the outcomes sorted by your most used directories or information, like this:

ncdu 1.14.2 ~ Use the arrow keys to navigate, press ? for assist
--- /house/rgerardi ------------------------------------------------------------
   96.7 GiB [##########] /libvirt
   33.9 GiB [###       ] /.crc
    7.zero GiB [          ] /Projects
.   four.7 GiB [          ] /Downloads
.   three.9 GiB [          ] /.native
    2.5 GiB [          ] /.minishift
    2.four GiB [          ] /.vagrant.d
.   1.9 GiB [          ] /.config
.   1.eight GiB [          ] /.cache
    1.7 GiB [          ] /Videos
    1.1 GiB [          ] /go
  692.6 MiB [          ] /Documents
. 591.5 MiB [          ] /tmp
  139.2 MiB [          ] /.var
  104.four MiB [          ] /.oh-my-zsh
   82.zero MiB [          ] /scripts
   55.eight MiB [          ] /.mozilla
   54.6 MiB [          ] /.kube
   41.eight MiB [          ] /.vim
   31.5 MiB [          ] /.ansible
   31.three MiB [          ] /.gem
   26.5 MiB [          ] /.VIM_UNDO_FILES
   15.three MiB [          ] /Personal
    2.6 MiB [          ]  .ansible_module_generated
    1.four MiB [          ] /backgrounds
  944.zero KiB [          ] /Pictures
  644.zero KiB [          ]  .zsh_history
  536.zero KiB [          ] /.ansible_async
 Total disk utilization: 159.four GiB  Apparent measurement: 280.eight GiB  Items: 561540

Navigate to every entry through the use of the arrow keys. If you press Enter on a listing entry, ncdu shows the contents of that listing:

--- /house/rgerardi/libvirt ----------------------------------------------------
                         /..
   91.three GiB [##########] /photos
    5.three GiB [          ] /media

You can use that to drill down into the directories and discover which information are consuming essentially the most disk area. Return to the earlier listing through the use of the Left arrow key. By default, you’ll be able to delete information with ncdu by urgent the d key, and it asks for affirmation earlier than deleting a file. If you wish to disable this habits to stop accidents, use the -r possibility for read-only entry: ncdu -r.

ncdu is out there for a lot of platforms and Linux distributions. For instance, you should utilize dnf to put in it on Fedora immediately from the official repositories:

$ sudo dnf set up ncdu

You can discover extra details about this instrument on the ncdu web page.

2. htop as a alternative for high

htop is an interactive course of viewer just like high however that gives a nicer person expertise out of the field. By default, htop shows the identical metrics as high in a pleasing and colourful show.

By default, htop appears like this:

In distinction to default high:

In addition, htop gives system overview data on the high and a command bar on the backside to set off instructions utilizing the operate keys, and you’ll customise it by urgent F2 to enter the setup display. In setup, you’ll be able to change its colours, add or take away metrics, or change show choices for the overview bar.

While you’ll be able to configure current variations of high to attain comparable outcomes, htop gives saner default configurations, which makes it a pleasant and simple to make use of course of viewer.

To be taught extra about this venture, examine the htop home page.

three. tldr as a alternative for man

The tldr command-line instrument shows simplified command utilization data, largely together with examples. It works as a shopper for the neighborhood tldr pages project.

This instrument will not be a alternative for man. The man pages are nonetheless the canonical and full supply of knowledge for a lot of instruments. However, in some instances, man is an excessive amount of. Sometimes you do not want all that details about a command; you are simply attempting to recollect the fundamental choices. For instance, the person web page for the curl command has virtually three,000 strains. In distinction, the tldr for curl is 40 strains lengthy and appears like this:

$ tldr curl

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

- Download the contents of an URL to a file:

  curl http://instance.com -o filename

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

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

- Download a file, following [L]ocation redirects, and routinely [C]ontinuing (resuming) a earlier file switch:

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

- Send form-encoded information (POST request of sort `software/x-www-form-urlencoded`):

  curl -d 'identify=bob' http://instance.com/kind                                                                                            
- Send a request with an additional header, utilizing a customized HTTP methodology:

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

  curl -d '"name":"bob"' -H 'Content-Type: software/json' http://instance.com/customers/1234

... TRUNCATED OUTPUT

TLDR stands for “too long; didn’t read,” which is web slang for a abstract of lengthy textual content. The identify is suitable for this instrument as a result of man pages, whereas helpful, are typically simply too lengthy.

In Fedora, the tldr shopper was written in Python. You can set up it utilizing dnf. For different shopper choices, seek the advice of the tldr pages project.

In normal, the tldr instrument requires entry to the web to seek the advice of the tldr pages. The Python shopper in Fedora permits you to obtain and cache these pages for offline entry.

For extra data on tldr, you should utilize tldr tldr.

four. jq as a alternative for sed/grep for JSON

jq is a command-line JSON processor. It’s like sed or grep however particularly designed to cope with JSON information. If you are a developer or system administrator who makes use of JSON in your each day duties, that is an important instrument in your toolbox.

The principal good thing about jq over generic text-processing instruments like grep and sed is that it understands the JSON information construction, permitting you to create advanced queries with a single expression.

To illustrate, think about you are looking for the identify of the containers on 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"
      ,
     
    ],
    "restartPolicy": "Never"
 

If you attempt to grep immediately for identify, that is the end result:

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

grep returned all strains that include the phrase identify. You can add just a few extra choices to grep to limit it and, with some regular-expression manipulation, yow will discover the names of the containers. To receive the end result you need with jq, use an expression that simulates navigating down the information construction, like this:

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

This command offers you the identify of each containers. If you are searching for solely the identify of the second container, add the array component index to the expression:

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

Because jq is conscious of the information construction, it gives the identical outcomes even when the file format adjustments barely. grep and sed could present completely different outcomes with small adjustments to the format.

jq has many options, and masking all of them would require one other article. For extra data, seek the advice of the jq project page, the person pages, or tldr jq.

5. fd as a alternative for discover

fd is a straightforward and quick various to the discover command. It doesn’t goal to exchange the entire performance discover gives; as a substitute, it gives some sane defaults that assist loads in sure situations.

For instance, when trying to find source-code information in a listing that accommodates a Git repository, fd routinely excludes hidden information and directories, together with the .git listing, in addition to ignoring patterns from the .gitignore file. In normal, it gives sooner searches with extra related outcomes on the primary attempt.

By default, fd runs a case-insensitive sample search within the present listing with coloured output. The identical search utilizing discover requires you to supply further command-line parameters. For instance, to look all markdown information (.md or .MD) within the present listing, the discover command is that this:

$ discover . -iname "*.md"

Here is identical search with fd:

$ fd .md

In some instances, fd requires further choices; for instance, if you wish to embrace hidden information and directories, it’s essential to use the choice -H, whereas this isn’t required in discover.

fd is out there for a lot of Linux distributions. Install it in Fedora utilizing the usual repositories:

$ sudo dnf set up fd-find

For extra data, seek the advice of the fd GitHub repository.

Great alternate options alongside confirmed utilities

While I nonetheless use all of the outdated important instruments commonly, particularly when connecting remotely to servers, the choice instruments present some further advantages which are invaluable in lots of situations. They significantly assist me handle and work on my Linux desktop and laptop computer machines.

Do you utilize every other instruments that assist your workflow? Add them within the feedback part under.

Most Popular

breakingExpress.com features the latest multimedia technologies, from live video streaming to audio packages to searchable archives of news features and background information. The site is updated continuously throughout the day.

Copyright © 2017 Breaking Express, Green Media Corporation

To Top