Love it or hate it, the command line is here to stay. Sure, there are new options emerging like TermKit but it’s unlikely that the command line will ever really go away. Those who take the time to master it can run productivity circles around their peers, but with the astonishing assortment of CLI tools available, where do you even begin? We’ve compiled a few of the most useful tools and tricks into this guide to help new users gain some new knowledge, and old pros learn some new tricks.
Note: Some of the tools or commands listed here may require root privileges.
1. Making a Temporary Filesystem (Ramdisk)
There are several reasons to make a temporary RAM-based filesystem such as fast read/write times or to guarantee that the files will not persist after reboot. Making such a “fake” filesystem is easy, and just requires one command.
Where /mytemppartion is the location you wish to mount (it must already exist) and 1024m is the desired size of the ramdisk.
2. Quickly Scheduling Commands
Linux pros almost certainly know the at command, it lets you set a specific time for a job to be run. You simply say what to do and when to do it, and at takes care of the rest. Its usage can be confusing for some, so here’s one common way of scheduling a task with at.
If you want to verify that it worked, you can easily list the sceduled jobs with
3. Re-run Previous Commands
Perhaps you ran a long complicated command, but forgot to preface it with sudo, or maybe you didn’t add some necessary options to the end. Instead of retyping the whole thing or going back through your shell history, you can use “double bangs” to represent your last command.
If you’re the type who tracks your command history numbers, you can use the same approach to recall any previous command by referencing its number:
4. Find the PID of a Process
If you need to kill a particular process but don’t have its PID, there’s a simple shortcut to find it – the pgrep command. It doesn’t do anything that can’t be done with a combination of ps and grep, but every little bit helps.
5. Find the Fastest Apt Mirror
Most Debian-derived distributions (but not Ubuntu) have access to a great tool that seems to go largely unnoticed. It’s called apt-spy, and its purpose is to scan the list of known Debian mirrors to find the fastest one for you.
6. Show Listening Ports and their Processes
If you need to see what’s listening for connections on your system, and the processes handling those connections, the old trusty netstat tool is up to the job. Try
to see just such a list.
7. SSH Without Passwords
Many people, such as this author, use SSH on a nearly constant basis. It’s a great tool, there’s no denying that, but having to constantly retype your passwords can get annoying. Instead, you can simply copy your (public) SSH information to the remote machine, allowing it to authenticate you without requiring your password, and all you need is a single command.
Obviously we’ve only begun to scratch the surface when it comes to useful CLI tools, but the ones listed here are a few of those that we at MTE consider indispensable. If you’ve got any favorite utilities that we forgot to mention, let us know in the comments below.
Our latest tutorials delivered straight to your inbox