Take it from a confirmed Linux guru with a couple decades on the system – these are the important command-line utilities that every Linux user should know. We’re going to assume you readers are familiar with basic things like file handling and changing permissions, or that you do that from a GUI. That’s fine, there’s graphical interface wrappers for most basic functions.
This isn’t going to be a soapbox sermon about why the command line is better than the GUI. It also isn’t going to be a basic primer for the absolute beginner. We will focus instead on the handy utilities that make Linux Linux. These are the programs which not only get something done from the command line, but make themselves the best way to get a job done. They’re the tools you will reach for the most often.
SSH is the protocol for remotely controlling one computer from another one, and if you work with computers in any professional capacity, it’s going to become one of your most-used tools. It’s an encrypted, secure tool to provide a secure connection through an unsecured network. It’s also half the reason sysadmins have to rely on the command line – what good is a remote login if you have to use the desktop?
Grep is the go-to command line utility for searching plain text files. Used properly with some command-line wildcards, it’s like a miniature Google for your local files. Grep is one of the Unix core-utils that uses regular expressions, so it’s best to learn those now and get it over with! It’s got an intimidatingly long list of features and switches, but using even a few of them will become rote, giving you a powerful, efficient tool to quickly drill down to the data you need to fetch.
The pipe “|” operator: It’s best to get familiar with this now. Piping things into and out of grep is a standard way to string Unix tools together to form powerful command-line utilities, which can also be tossed into a shell script for later re-use.
Locate is the Linux command-line file search utility. It has one down-side, in that it must build an index on a daily basis, so it can’t find new file changes up to the minute. However, the Linux “find” command can, but it’s crawling-slow. For any use where the file you’re looking for is older than 24 hours, Locate will pop up results in a second. You can also force an index re-build on the spot with the “updatedb” command, though it usually has to be run as root.
Dc is a command-line calculator. If that sounds quaint, maybe you don’t need it. But it’s surprising how much time you save firing off an equation from the command line as opposed to opening up a desktop calculator app. Dc is intimidating to some users, since it uses a form of notation known as “reverse polish,” but learn it and it becomes an integral tool you never know how you lived without.
Dc can also be scripted, which opens up a world of possibilities for shell script and piping data through commands when you need a calculation and are stuck with a language less than ideal for math precision.
Convert is part of the Image-Magick suite of graphics utilities, which you’ll probably have on your system anyway because things like PHP use it to handle images on the fly. Do make some time to dive into that manual we linked to; not only will proficiency at Image Magick feel like deep wizardry, but the manual is one of the deepest and most complete courses of documentation on any Unix-core software ever.
Have you been cropping, rotating, scaling, and captioning images by dragging open a GUI editor, loading the file, doing the thing you need to do, saving it, and closing the editor again? Boy are you ever in for a treat! With just a few typed keystrokes, the Image Magick “convert” command can handle all kinds of one-step image file operations, including all those plus converting between file formats, combining composite images, and hundreds of other handy operations.
The full Image Magick suite is as good as Photoshop in programming form. The best aspect of all is that you can batch multiple image file tasks together with a Bash wildcard. If you work with images on a regular basis (and who doesn’t?) this is indispensable. Learning Image Magick takes some initial time, but it pays off by saving you years of tedium in the long run.
Nobody is going to fault you if you skip Sed in favor of something like Perl, Python, or even Awk. But the fact remains that sed is still the fastest non-interactive way to parse and substitute text, and it’s a default utility in the Unix core. The downside is that it has its own miniature scripting language, which has the most arcane Unix utility syntax – it makes Perl look clean by comparison.
Nevertheless, once you get past the initial vertical learning curve, a good Sed command is the proverbial stitch in time. It’s handy for scripting, and like any Unix utility that processes text, you can pipe input to and from it.
Awk is the little programming language with the awkward name. Like many of our tools here, it is built for clean text handling. It, too, has more capable alternatives if you’re into Perl, Python, or some other way to do it. Awk has little to recommend it beyond it being guaranteed to be installed on every Unix-like system, and being relatively fast at executing both one-liner bits of code passed to it as an argument, or running full scripts you have saved.
Less is just a simple file pager. Nothing more, nothing… well, you know. There really isn’t a lot to say about it except you can fire it up with a file name, page through the file with the arrow keys, and quit by typing ‘q’. But it’s still a command you will use on a daily basis. It’s capable of a bit more, such as searching through a file for a string. Less is actually what your Linux system uses to read man pages.
Wc is one of those trivial utilities you ignore until you need to solve a specific problem, and then you start to appreciate its purpose. “Wc” means “word count,” but not only that, with some switches it can count lines, characters, and even bytes. And you can pipe into and out of it too, which becomes a handy way to answer questions like “how many files are in this directory?” simply by piping the output of Ls into Wc.
We’ve learned to replace all kinds of applications with the utilities we listed above, but can we actually replace… a user? Cron is a job-scheduling daemon that’s built into all Unix core systems. It can execute any command you can type, and can schedule that execution for any time and day in the future, or at regular intervals of a day, hour, or any other time unit.
Cron is not used directly from the command line; instead, you set up a Cron job by editing the configuration files. You can do a one-time scheduling operation form the command line using the At command. Typically, Cron runs regularly scheduled tasks, most often once per night, handling mundane chores such as rotating system logs or running “updatedb” for Locate.
Legend has it that savvy sysadmins have virtually replaced themselves by setting up Bash scripts to be executed by the Cron daemon while they goof off somewhere else. It’s like having your own bot! Use this power for good, never evil.
Thanks for joining us on this little tour of essential Linux command line utilities. We chose to focus on the handiest utilities that get used often, without bothering with a beginner’s level tutorial on basic file commands and whatnot. The above represents an powerful toolbox, with which you can solve almost any problem if you explore the possibilities.