10 CLI Tools that You Will Love
As a web developer I use Linux every day. I would like to share some CLI applications that helped me increase my productivity. Some tools are better alternatives of existing commands, while others provide completely new features. I believe you will love them.
All the install commands are tested under Ubuntu 18.04.
grep => ack, ag
ack
and ag
are two search tools better than grep
. With ack
or ag
, you don’t have to type any options that is required by grep
to search under a given directory. Also the search result includes line number and is colorful, which is easier to read.
They basically have the same feature so you could choose one you like. On Ubuntu 18.04, they can be installed with the following commands:
# Install ack
$ sudo apt install ack# Install ag
$ sudo apt install silversearcher-ag
On Ubuntu 16.04, ack
was located in package ack-grep
so you have to use sudo apt install ack-grep
to install it but command name was still ack
.
fzf: Fuzzy Finder
fzf
is a powerful file finder that can find files, processes, environment variables fast. Compared to native auto completion, fzf
can display the completion items as a list and filter the list as you typing the command, which is much easier than pressing Tab repeatedly and trying to find the file name on a crowded screen.
It is not a ubuntu package yet so we have to install it from source:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
After install, you can use **<TAB>
to do auto completion with fzf almost anywhere:
vim **<TAB> # select files from current dir and edit
vim ../**<TAB> # select files from parent dir and edit
kill -9 <TAB> # auto complete process to kill
export **<TAB> # auto complete env var to export
<C-R> # search command line history
See its homepage for more usages.
TheFuck: command line spelling corrector
Have you ever been frustrating when typing a long command line only to find there was a typo in the command or simply missing sudo
? Then TheFuck could help. Install it by typing:
$ sudo apt install thefuck
Then you need to add this line to your ~/.bashrc
:
eval $(thefuck --alias)
After re-login (or simply reload .bashrc
by using source ~/.bashrc
), try this:
$ apt install git
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ fuck
sudo apt install git [enter/↑/↓/ctrl+c]
Reading package lists... Done
Building dependency tree
top => htop
htop
is so well-known so I won’t talk too much about it.
$ sudo apt install htop
$ htop
traceroute => mtr
mtr
is a better tool for network troubleshooting. It is faster and easier to use than original traceroute
.
$ sudo apt install mtr
To trace route, simply type:
$ mtr 8.8.8.8
This will bring a GUI window to display the trace route process and result. If you prefer CLI output, add -t
option:
$ mtr -t 8.8.8.8
df => pydf
pydf
can show disk usage in a colorful, easy to read way.
$ sudo apt install pydf
mc: File Manager
mc
(GNU Midnight Commander) is a great file manager for CLI. It uses two-pane view for file management, and also supports FTP and SFTP. Great tool when you need to do many file operations without access to GUI, for example, on the server.
Hint: mc
uses F1~F10 function keys. If you don’t have access to function keys, for example, when using mc
in terminal emulator where function keys are used for GUI operations, use Esc -> 0~9
instead.
ftp => lftp
Although FTP is less popular today but sometimes we need it to access some legacy resources. lftp
is a great CLI FTP client. Compared to ftp
it supports mget
and mput
commands that support wildcard, and the powerful mirror
command to download/upload a whole directory. It even supports downloading torrent with torrent
command!
$ sudo apt install lftp
wget => aria2
aria2
is a lightweight download tool that supports HTTP/HTTPS, FTP, SFTP, BitTorrent, and most importantly, multi-connection download. Thanks to its multi-connection download feature it can download faster than wget
. It can also resume incomplete download. See aria2 homepage for examples.
$ sudo apt install aria2
$ aria2c https://example.com/ubuntu.iso
nnn: File Analyzer
One thing I usually do when running short of disk space is to find the large files / directories with du -sh *
and delete them. nnn
can do this job better. Just type nnn
and press uppercase S
and you will see the sizes for all the directories and files.
$ sudo apt install nnn
Thanks for reading! If this post helps, Please share it with your friends by recommending it.