ssd web hosting

Apr 04, 2019

21 min read

13 smart terminal tools to level up your Linux servers

Written by

Vippy The VPS

Developers either tend to love or hate the Linux server’s terminal. You have people like Matt, our CEO, who has told me many times that he could spend an entire day on the Linux terminal and love every second of it. And you have the rest of us, who need a little help and encouragement.

The Linux terminal is highly customizable. It’s far from static. That means there’s plenty of opportunities to turn a bland default terminal into a powerful (and colorful!) platform for you to get things done. There’s new and unique tools, infinite customization options, and a ton of innovation around creating a usable and highly productive text-based interface.

Let’s take a look into some of my favorite ways to customize, personalize, and make any Linux terminal a little more to my liking.

A collection of the smartest terminal tools (for a better Linux server experience)

  1. tldr: Read simplified instructions on common terminal commands
  2. how2: Get answers to your terminal questions
  3. z: Jump to ‘frecently’ used places
  4. trash-cli: Put files in the trash
  5. nnn: Manage your files visually
  6. bat: View files with syntax highlighting
  7. pomo: A Pomodoro timer in your terminal
  8. fselect: Find files with the speed of SQL
  9. exa: List files with more features (and colors) than ls
  10. peco: Get grep-like filtering with interactivity
  11. has: Do you 'has' the dependencies you need?
  12. progress: See how much longer mv, dd, cp, and more will take
  13. mackup: Sync and restore your application settings

Bonus: transfer.sh: Share files directly from the command line

tldr: Read simplified instructions on common terminal commands

You’ve probably seen this dismissive phrase before: “Go read the man pages.”

That’s a typical response (unfortunately) to Linux newcomers asking questions about how to use a particular program or utility in the terminal. Doubly unfortunate is that man pages are often tedious and hard to parse.

tldr is a solution. Once you download it, you can type in tldr $PROGRAM to get some clear information on how to use that program, plus real-life examples. You’ll probably be most interested in theBash client.

Here’s what tldr tar gets you:

Terminal tool: the tldr output for tar

How it’ll level up your server:

  • Get more immediate, real-life examples of how to use Linux/Unix utilities.
  • No more switching from a terminal to a browser a hundred times to get the information you need or copy-paste the command you’re looking for.
  • Finally learn and remember all those obscure syntaxes that you keep stumbling over.

how2: Get answers to your terminal questions

Don’t feel like reading a bunch of tldr examples to find the one you need? Not even sure which utility you need to get the job done? how2 could be your answer.

The developers of how2 bill it as “stackoverflow from the terminal” and “like man, but you can query it in natural language.” Those are some big promises, but the output is impressive:

Terminal tool: how2 answering a question about .tar.bz2

Unlike tldr, which uses curl to download and display one of the write-ups that they keep on a centralized server, how2 actively queries the Google and StackOverflow APIs to pull answers to your questions. If it finds a community-approved answer to your question, it’ll use that to populate the output. And given how many developers are wholly dependent on said answers to program anything useful (pointing at myself), you should be okay in a lot of cases.

How it’ll level up your server:

  • Real answers to your tricky-to-remember questions, like how tar works.
https://imgs.xkcd.com/comics/tar.png

z: Jump to ‘frecently’ used places

I always have a few directories that I tend to spend the most time in. A small shell script called z helps me access those directories with less overhead.

To install it, grab the source code and put the z.sh file in a directory of your choosing. Then open up your .bashrc or .zshrc file and copy in the following line:

. /path/to/z.sh

Save the file and start up a new terminal. You’ll need to use cd normally for a bit for z to build up its database of common directories, but after a short period of normal use, it’ll have a good idea of where you might want to go. Hit z and either type a portion of the path you want to go to, or hit TAB to get the first recommendation.

z uses both frequency and recency to decide which directory you’re most likely to want to visit—hence the word “frecency.” A weighted rank algorithm tracks which directories you visit, when you last visited them, and figures out where to point you next.

How it’ll level up your server:

  • No more typing out /www/www-data/wordpress/wp-content/themes/my-theme all the time.
  • Less cognitive load on getting to where you need to go.
  • Available options to prevent symlink resolution, directories to exclude, sudo mode, and more.
  • Full support for tab completion.

trash-cli: Put files in the trash

rm is a powerful tool. Almost too powerful. If you rm a file or directory on a Linux server, it’s gone. There’s no trash can backing you up when you decide, two months later, that you do need that file you deleted.

trash-cli is a solution.

If typing trash-put is too many characters, you could always alias it to tp or another that’s easy to use. You could even alias it to rm itself for a completely seamless experience, although the developer doesn’t actively recommend this.

But you do you.

How it’ll level up your server:

  • Reduce the impact of a simple rm mistake.
  • Uses the standardized FreeDesktop.org trash system, so it’s the same as your KDE, GNOME, or XFCE trash can.
  • Your trash stays in ~/.Trash so it’s easily accessible if need be.

nnn: Manage your files visually

Speaking of directories on Linux servers—I often miss the visual element of the desktop file manager. It just feels effortless to move around, select the file you’re interested in, and copy/move/delete it.

nnn is a fast and lightweight file manager that will help you navigate and deal with files on your server whenever you’re sick of cd, ls, mv, and rm.

You can install it on Ubuntu/Debian with a simple apt-get install nnn, and there’s binary releases for those who use CentOS or another OS.

How it’ll level up your server:

  • Get the comforts of a visual file manager without much overhead.
  • A plethora of keyboard shortcuts to satisfy the curiosity of power users.
  • Multiple “contexts,” similar to tabs, to explore multiple directories concurrently.
  • Full customization of colors, bookmarks, and options.

bat: View files with syntax highlighting

If you want to look at the contents of a file quickly, you’ll probably use cat or less. But both of those dump the contents of the file onto your terminal in plain white characters.

Instead, use bat. bat will display the same file, but will also automatically detect the language and display syntax highlighting. It’ll even show git modifications on the left-hand side. And if the file is long enough, bat will pipe the output to less so that you can use the Page Up and Page Down keys to navigate with ease.

Installation is pretty simple on all major OS options. The results look great:

Terminal tool: An example of how bat handles a .md file

How it’ll level up your server:

  • Combine cat and less into a single tool.
  • Quickly view version control information without doing the whole git diff thing.
  • More readily examine files with the help of syntax highlighting.
  • Combine it with tail for continuous monitoring with syntax highlighting.
  • Combine it with git show to see an older version of a file with syntax highlighting.

pomo: A Pomodoro timer in your terminal

Have trouble staying focused while you work, whether in the terminal or out? The Pomodoro Technique might be for you. But instead of finding some ad-filled mobile app or launching another browser tab, why not just use the technique right from your terminal?

pomo is a simple tool that helps you decide on a task you want to accomplish, set timed intervals, give yourself breaks, and then get to it. There is a installer script or binaries for all Linux distributions.

How it’ll level up your server:

  • Combine the terminal work you need to do with the tool that will help you stay focus. Less context switching.
  • Plan future Pomodoro sessions and initiate them when you’re ready.
  • Keep tabs on the work you’ve accomplished with the list command.

fselect: Find files with the speed of SQL

I used to think SQL queries looked like nonsense. Then I found fselect.

fselect has nothing to do with databases or SQL itself, though—it’s a tool to help you find files with a querying syntax that developers and sysadmins have been using for decades.

The full usage looks confusing:

fselect COLUMN[, COLUMN...] [from ROOT[, ROOT...]] [where EXPR] [order by COLUMNS] [limit N] [into FORMAT]

But when you look at some simple examples, the syntax starts to make sense. Here’s how to see the full path and size of any file in your home directory that ends in .cfg or .tmp:

fselect size, path from /home/user where name = '*.cfg' or name = '*.tmp'

Or any file in /tmp that’s bigger than 1GB:

fselect size, abspath from /tmp where size gt 1g

Or any image in home/user/photos that’s wider or taller than 2000px:

fselect width, height, path from /home/user/photos where width gte 2000 or height gte 2000

The syntax is far more potent than these examples—be sure to check out the detailed examples list for more possibilities.

How it’ll level up your server:

  • You might be able to replace find and ls with fselect.
  • Complex queries help you find files without typing cd a hundred times.
  • Shortcuts for common file types help narrow down searches.
  • Search within archives!

exa: List files with more features (and colors) than ls

I, for one, can never remember how to get ls to do what I’d like. I have some defaults set up in my .zshrc, but the output still isn’t as useful as I’d like. Enter exa, which bills itself as a modern replacement for ls.

exa uses “better” defaults and simple color-coordination to help distinguish between file types and the other data it displays. My favorite feature is the tree view, which lets you specify a depth to see how files relate to one another. It’s like bringing the Unix tree command into the ls fold.

To install, download a binary or use Rust’s cargo command to install: cargo install exa.

Terminal tool: examples of the output of exa

How it’ll level up your server:

  • Less thinking about or worrying over ls arguments.
  • Automatic colors for easier scanning over a bunch of files or figuring out which file has the wrong permissions settings.
  • By being a little more opinionated about options, exa is just more straightforward to use.

peco: Get grep-like filtering with interactivity

The most common way to search or filter a file for a specific string is to use grep. It works great—when you know precisely what to look for.

peco solves that problem by making the filtering process interactive. You can use peco to check out the output of ps aux and filter as you go. That way you can try many filters interactively—are you looking for processes run by $USER or a specific process name?—instead of typing out a dozen grep commands.

How it’ll level up your server:

  • Examine log files or process lists without knowing what you’re looking for quite yet.
  • Combine peco with other terminal tools or even zsh for enormous customization opportunities.

has: Do you 'has' the dependencies you need?

Want to quickly check whether your $PATH has the dependencies you need to move forward with your project or installation? Simply feed has a list of tools, like has git node ruby go and it’ll output either positives (plus installed versions) or negatives for any dependencies you still need to install.

$ has git node npm
✔ git 2.14.1
✔ node 8.2.1
✔ npm 5.3.0

How it’ll level up your server:

  • Easily understand what programs (and which versions) you have and need.
  • Stop messing about with sudo apt list --installed | grep -i node and use has node instead.

progress: See how much longer mv, dd, cp, and more will take

The coreutils available on every Linux installation—the basics like cp, mv, dd, tar, cat, and more—are great at getting things done, but they’re not great at telling you when they’re getting said thing done.

progress ends that mystery. Install the binary and run progress whenever you have a coreutil running to see its progress, the percentage completed, and a rough ETA for completion.

How it’ll level up your server:

  • No more waiting around forever for that dd command to finish.
  • Monitor “virtually any command,” according to the developer.

mackup: Sync and restore your application settings

I keep a repository of dotfiles around to make sure that whenever I reinstall my desktop’s OS, all my terminals and apps work the way I want them to. I even have a custom-made Bash script to make all the necessary symlinks and install essential packages.

I spent a ton of time creating all that. mackup will get you all the same functionality in about 2 minutes. You don’t even need to tell it which app’s settings you want backed up. Run makup backup and you’ll have a settings backup that you can bring to your Linux server. If mackup doesn’t support a specific application you use, you can easily add support.

No more wishing you had a particular feature on your server’s terminal. No more wasting time trying to copy-paste settings from one to the other. Just your perfect Linux terminal environment in a matter of minutes.

How it’ll level up your server:

  • Bring all your favorite settings for bash, zsh (and Oh My Zsh), vim, git, tmux, and plenty others, onto your Linux server.
  • Work faster and smarter with your favorite plugins and opinionated setups.
  • No need to spend time creating a custom Bash script.
  • Easy to update and restore if you find yourself having to reinstall your server’s OS frequently (aka you kill your server).

Plus a bonus: transfer.sh for sharing files directly from the command line

transfer.sh isn’t a script—it’s a service that lets you upload and share files from your Linux terminal. Transfer.sh handles uploads and downloads with curl:

$ curl --upload-file ./hi-from-ssd-nodes.txt https://transfer.sh/hi-from-ssd-nodes.txt
https://transfer.sh/gK4F5/hi-from-ssd-nodes.txt

You can download a file using curl, too. Maybe try downloading the file I had just uploaded? Due to the 14-day retention period, you have until about April 15, 2019 to try:

$ curl https://transfer.sh/gK4F5/hi-from-ssd-nodes.txt -o hi-from-ssd-nodes.txt

transfer.sh is great for those quick backups or shares when you’ve edited a configuration file and want to make sure you have access to it in case you break your VPS. Once you add the alias it’s a no-brainer.

Conclusion

The amazing (and intimidating) thing about spending time on the Linux terminal is that I’ve just barely scratched the surface on the plethora of tools, apps, and shortcuts available to me. Hopefully, you’ve found some of these useful!

If you’d like to share other smart terminal tools you’re using on your Linux servers, let me know at mailto:[email protected]. I’ll compile my favorites for a follow-up in the next few weeks!

Leave a Reply