Once upon a time, working in IT meant learning to use the command-line interface. Whether you were a programmer, a system administrator or both, you could barely do your job without CLI tools. That has changed for today’s generation of IT professionals. From administering clouds, to managing code on GitHub, to patching operating systems, most workflows can now be handled via graphical tools. That does not mean, however, that CLI tools are totally deprecated. For some tasks, CLI tools still get the job done better than their GUI alternatives.
Here’s a look at seven such tools that remain essential for IT pros to know and love, even in a world dominated by graphical user interfaces. Most of these tools are native to Linux and other Unix-like systems, although most can also run on Windows.
Let’s start with file, a basic CLI utility that performs a simple but important task: identifying which type of a file a given file is. Whether a file has an extension or not--or even if it has an extension, but the extension does not accurately reflect the type of file it is--the file CLI tool will identify it for you, in most cases, with a simple command.
You can do the same thing using a variety of graphical tools, of course. But nothing beats the simplicity of a simple file some-filename command when you need to figure out which type of file was included in an email attachment, or you want to make sure the PDF file someone sent you is actually a PDF.
Have you ever needed to figure out the IP address of another device on your network, or wanted to scan the network for open ports that should be closed for security reasons? Nmap is a CLI tool that allows you to do this and much more. It can scan an individual host or an entire subnet in whichever degree of depth you choose, reporting information about which hosts are up, which services they are running, which operating systems are installed on them, and so on.
There is a graphical interface for Nmap, called Zenmap. If you want to use Nmap through a GUI interface, you can. But it also works perfectly well (and a bit faster) as a CLI tool.
Dig is a simple tool for performing DNS lookups. It offers a quick and easy way of figuring out which hostnames map to which IP addresses on a network.
Some folks prefer host or nslookup--CLI tools that do basically the same thing as dig--over dig. For my money, however, dig is the best DNS lookup tool, particularly because it makes it easy to direct requests to specific DNS servers using a command like dig @22.214.171.124 google.com. This is handy in situations where you want to see if the DNS information reported from one DNS server (like your ISP’s) is different from that of another DNS server (like one of Google’s). Disparities between DNS servers could indicate a security problem, attempts to block certain hosts or just outdated DNS records.
Modern Web browsers offer excellent interfaces and incredible usability. One thing they just can’t do well (at least not with the help of extensions), however, is downloading a bunch of Web content automatically or recursively. If you have a long list of Web pages you want to download via Firefox or Chrome, for example, you’re going to have to open and save each one manually. It will take a long time and be very boring.
This is where wget comes in handy. If you want to scrape the contents of an entire website, submit a list of queries to a form and download the results, or perform similar tasks, wget makes it easy to do so. You can also configure the user agent in wget to whatever you like using the --user-agent= argument, which is useful in situations where websites block requests from wget.
These days, virtually every kind of graphical application that manages text--from Microsoft Word to most text editors to Visual Studio--lets you perform searches using regular expressions. However, using a graphical tool to do regex searches is often clunky. It’s usually hard to search through multiple files at once this way, and the tools don’t always interpret wildcards or other special characters in the same way.
This is why I remain a fierce defender of grep, which lets you search one file or many files for a particular string or a regular expression. You can pass a large selection of arguments to grep to configure exactly how it behaves. For example, if you want it to return just exact matching phrases instead of the entire line of text of which they’re a part, you can use the -o flag. With the -A and -B flags, you can tell grep to return lines that precede or follow a match.
No matter how many features your favorite graphical tool may offer for working with regular expressions, it likely can’t match the functionality of grep, which remains an essential CLI tool for modern environments.
The first time I encountered sed, I wondered why anyone used it. The tool manipulates text, which is useful, but its syntax can seem hopelessly arcane if you’re not familiar with it. Commands look like this:
And that’s a pretty simple sed command, which performs a very basic search-and-replace!
Despite this apparent obscurity, I’ve learned over the years to love sed (and wrap my head around its bizarre syntax). It’s an incredibly handy CLI tool when you need to perform complex find-and-replace operations that involve specific variables or conditions, print select parts of a file, delete certain parts of a file, and so on. I can’t think of any graphical tool that offers equivalent functionality in a single package.
All of the tools we’ve looked at so far are classic Unix CLI utilities. Now, let’s take a look at a more modern CLI tool that has become essential for many developers and IT admins today: Kubectl, the CLI tool for managing Kubernetes clusters.
If you work with Kubernetes, kubectl is not just a nice-to-know tool; it’s absolutely essential, because it’s the only way to perform some types of tasks, like running interactive commands or accessing a shell in a running container. Although there are Web consoles for Kubernetes, they are designed more for monitoring purposes than for in-depth cluster management.
It’s tempting to believe that it is not necessary for modern IT pros to learn CLI tools, but that’s just not the case. The tools described above provide functionality that would be much harder to implement using graphical applications--or that, in some cases, simply isn’t available at all without a CLI solution. No matter how much you prefer GUIs over the command line, there are still some CLI tools that everyone in IT should know today.