Home  »  Blog  »  10 Terminal commands that you might not know!

10 Terminal commands that you might not know!

In the day to day systems administrator or the increasingly popular DevOps , using the terminal is something that consumes much of our time, whether doing normal tasks, automation tasks or during system configuration processes.

We spend much of our time in front of a terminal and we must learn the most interesting commands that help us perform tasks more quickly and comfortably, detecting in which we spend more time ( or in which tasks we take more ), to look for ways to simplify and Take advantage of our time.

  • 10 terminal commands that you may not have known (I)
  • 10 terminal commands that you may not have known (II)
  • 10 terminal commands that you may not have known (III)

In this article ( which pretends to be a series of them ), we will comment on interesting commands to simplify our life in terminals of GNU / Linux systems , also applicable to WSL ( Linux subsystem of Windows ), where we can have a native terminal of Linux in Windows systems 10

1. Autojump: Skip through folders more efficiently

With autojump we can improve the classic way to access directories with cd. Usually, we usually write folders or directories in the form of a relative path through which we are accessing, or even absolute paths when we want to “jump” to a specific folder.

This becomes somewhat tedious when we have to be moving through several folders intermittently. With the pushdand commands popd, we can use a stack to store or recover the most used folders, but autojump manages this in an even smarter way, since we only have to write part of the name of the folder we want to access and it will be based on the folders in which we have most been, since it maintains an internal database with this information.

Autojump, improved cd

To install it, we just have to make one sudo apt-get install autojumpand execute the next command . /usr/share/autojump/autojump.sh, which will activate an alias jto use autojump .

2. tmux: Terminal multiplexer

Tmux is a multiplexer of terminals, or what is the same, a tool that allows to divide a terminal in text mode, in several different terminals. Tmux offers two main advantages for which it is already worth working with it: make better use of space and recover lost sessions .

The first one is the most obvious, since being able to divide into several terminals , you can take better advantage of the space and work at the same time you see information from another command. The second one is very interesting. Many times the remote connections by SSH are interrupted by connection problems , micro- breaks , sudden closures or similar errors. If we have an open connection with tmuxand it is interrupted, we just have to reconnect and write tmux attachto recover the session as it was.

tmux on Linux

Once a session is opened with tmux, press CTRL+ Band then %to divide the terminal horizontally or CTRL+ Band then “vertically divide the terminal. In the same way, you can continue dividing the divided terminals.

More interesting details:

  • CTRL+ By ?: Moves to the terminal on the left. Idem with the rest of cursors for other directions: up, right or down.
  • CTRL+ Band ALT+ ?: Expand or reduce the current terminal to the indicated address.
  • CTRL+ Band CTRL+ O: Rotate the site terminals.
  • CTRL+ D: Closes the current terminal.

If you do not like tmux , you can try Oh My Tmux! , a special configuration to make it more beautiful and comfortable, or other similar alternative managers like byobu or dvtm .

3. micro: Intuitive text editor

One of the most traumatic points when starting to use Linux terminals, are the most commonly used text editors. VIM is one of the most versatile and powerful, but also one of the most feared.

Many times, you start using nano , a much simpler editor than vim , but also much simpler. An alternative to these two is micro , a very intuitive text editor that even preserves as standard the usual key combinations that we use as CTRL+ Sto save, CTRL+ Qto exit, CTRL+ Uundo, CTRL+ Cto copy and CTRL+ Vto paste.

Micro text editor

In addition, we can also use it through pipes to send the output of a command directly to the editor, change color schemes, and many other interesting details.

To install it, we just have to write the following:

curl https://getmic.ro | bash
sudo mv micro /usr/local/bin

4. vnstat: Network consumption statistics

In many cases we are interested in knowing how much bandwidth we have consumed in our equipment ( or the equipment we use as a server ) during a specific period of time. Vnstat is an excellent tool that shows us that: how much bandwidth we have consumed during a certain time.

Vnstat: Bandwidth statistics

We can see the transfer of bandwidth by hours, days, weeks, months or even live, among other options.

5. dtrx: Automatic compressed file extractor

Another common problem when dealing with compressed files is that, depending on the format, you have to use a different tool or specific parameters. Special mention in the case of tar, as well tells us the great XKCD in 1168: Tar , although in the latest versions has tried to solve in a certain way.

Dtrx: Extractor of compressed files

The tool dtrx aims to solve this problem, giving us a unified to extract any file system: tarzipcpiodebrpmgem7zcablzhrargzbz2lzmaxzand even some files exeself – extracting.

With the parameter you -lcan list and view the contents of the compressed file before extracting it.

6. Exa: ls improved

Exa is defined as a modern replacement of ls. It is a command created with Rust that makes it a little easier to read file listings in linux, visualizing with colors and adding some extra features such as the git status of a folder or viewing folders in tree format.

Exa: Modern replacement of ls

For automatic installation, it is required to have installed Rust and its charge installer . In case of not having it, you can always download the binary and install it in our system:

wget https://github.com/ogham/exa/releases/download/v0.8.0/exa-linux-x86_64-0.8.0.zip
unzip exa-linux-x86_64-0.8.0.zip
sudo mv exa-linux-x86_64 /usr/local/bin/exa

7. Googler / ddgr: Searching from terminal

Googler and ddgr are two tools to search in search engines such as Google or DuckDuckGo from a terminal. Using the parameter -n Xyou can specify the number of results, if you only want to search for something specific, or with -jthe first result in a browser. You can also browse the results interactively with the nand keys por return information in JSON format with the parameter --json.

Googler / ddgr: Google and DuckDuckGo

Googler comes in the apt repository of Debian 9 Stretch , but ddgr is not, so if you want to install it, follow these simple steps:

wget https://github.com/jarun/ddgr/releases/download/v1.4/ddgr_1.4-1_debian9.amd64.deb
sudo dpkg -i ddgr_1.4-1_debian9.amd64.deb

8. htop: improved top

A very famous and well-known command is topin GNU / Linux. It is a linux process manager, which shows the top of processes that consume more resources ( memory, CPU, etc … ). Htopis a well-known tool that substantially improves the classic Linux top , adding a syntax of colors very well achieved, and a series of options and parameters of very extensive personalization.

Htop: Improving the top of GNU / Linux

Among its options, you can search or filter, display an advanced color scheme that gives more information about the current system consumption, sorting by specific columns or collapsing the names of repeated processes, among many other options.

9. TIV: Terminal Image Viewer

On multiple occasions, we are connected through an SSH connection where we do not have a graphical environment or we only have access to a text terminal. Using tiv ( Terminal Image Viewer ) we can “see” images or graphics from the terminal without having to download them to another computer or start a graphical environment. TIV interprets the image specified in a low resolution version in text mode, where we can get an idea of ​​what the image is like.

Terminal Image Viewer

You can also set one *.jpgto show a gallery of the images to be displayed. TIV incorporates some interesting options or parameters, such as:

  • -256: Reduces the number of colors to 256. Useful in cases in which colors are displayed incorrectly.
  • -w: Sets the maximum width of characters in the image.
  • -h: Sets the maximum height of lines in the image.

If TerminalImageViewer ( TIV ) does not convince us, we can try it with timg or terminal-image , the latter available in NodeJS.

10. Fuck: “Shit, I was wrong”

Finally, a great command with which it will be very difficult to continue living from now on: fuck . This command ( an alias of thefuck ), allows us when we write a command in the terminal and we have an error, simply, writing ” fuck” , it will try to correct the previous command to its version without errors.

The fuck: The command of Linux to correct your mistakes

When writing, fucka line will appear where we are given the most probable matches and we can move up and down, or press ENTERto send the suggestion or CTRL+ Cto cancel it.

Alternatively, keep in mind that if we write !!in a terminal, the previous command is sent again. Many times, when we forget the one sudoin a command, it is enough to write sudo !!.

The author prefers to keep secret.

Tribute to Binit Ghimire Binit Ghimire was an amazing ,talented,and very helpful security researcher with an amazing skillset and knowledge about different stuffs in Infosec…

Start a discussion