One-line wise: A new tool for sneaky terminal commands
Today, we’re happy to deploy a new resource we think SSD Nodes users and Serverwise readers will appreciate. One-line wise is a list of our favorite terminal one-liners, from the invaluable to the downright quirky. We hope you bookmark it and make it a resource you come back to time and time again.
You can try out One-line wise now: https://www.ssdnodes.com/tools/one-line-wise/.
I know a handful of you are asking, “What’s a one-liner?”
Command-line interfaces (CLI), and the Linux terminal in general, is a highly flexible workspace. It all starts with your shell of choice—most often Bash or ZSH—has hundreds of different configurations and obscure syntaxes. On top of that, you can configure programs with a CLI in many different ways, and it’s possible to “pipe” one program to the next with the terminal. For example, you can list the files in a directory using
ls, pipe the output using
|, and search that output for a unique string using
$ ls -la | grep 'foo' -rw-r--r-- 1 joelhans staff 0 Oct 10 10:27 foo
Despite all their usefulness, one-liners can be awkward to create or understand for those who aren’t terminal experts. And because we’re all about helping people learn and get more from their VPS, we thought this was a perfect opportunity to share our expertise and give people more power over their terminal.
Using the tool is easy. You have a few options for discovering new one-liners that you might find amusing or useful.
The search box allows you to search available one-liners for specific commands or results that you’re interested in. The search function will match against the one-liner itself, the description, or the tag, so there’s plenty of opportunities to experiment and find the most relevant results. There currently is no fuzzy search (think autocorrect or did you mean?), so you’ll need to type in your queries exactly for them to work.
You can also click on any of the tags to sort one-liners by the tag in question. It’ll auto-fill the search box and perform the sorting for you.
On the bottom-right corner of every
code element (the dark-colored boxes containing the one-liners), you’ll see a small
Copy button. Click that to copy the one-liner in question to your clipboard for easy pasting into your nearest terminal.
You can’t be expected to remember these obscure one-liners, with all their strange symbols and get-this-right-or-it’ll-fail-obscurely syntaxes. Luckily, there are many ways to help make the process of using one-liners much easier.
Aliases can come in handy here. Let’s say you want to use the one-liner that shows you your CPU status frequently, but don’t want to type out the entire command every time. Using the
alias command, you can tell your shell that you’d like a simper command, like
cpu, to actually run the more complex one-liner. Here’s how it works:
alias cpu='watch grep "cpu MHz" /proc/cpuinfo'
Just change up the alias before the equals sign, and put the command in quotes on the other side.
You’ll also need to add these aliases to your
.zshrc dotfiles if you’re using Bash or Zsh, respectively, to make them persistent. If you haven’t played around with creating your dotfiles yet, this is a perfect opportunity. No dotfile repository is complete without a few dozen custom-built aliases that only the creator understands.
One-line wise is just the first of many tools we have planned, and it’s still unfinished. If you’d like to contribute, send me an email at [email protected]. We’re taking suggestions on one-liners, feature requests, bug fixes, and more.
After the dust has settled here, we’re going to get started on some other tools and resources to help you get a deeper understanding of your VPS and get more from every dollar you spend with us. We’re excited to help spread more server wisdom—thanks for reading and experimenting with us!