Learning the command line on any system can be daunting, so why not leverage that knowledge against multiple operating systems? Here are some that can help.
As an admin, one of the things that irks me after a particularly long day is the switch over, or mental reset that comes with changing gears between Windows, Linux, or macOS. It may seem like a trifling nuisance, but it doesn’t get any easier over time when you execute a long string and press enter, only to have the console attempt to process the command and end in failure.
It’s those lost seconds that lead to minutes, then hours. Even worse is when you’re trying to figure something out and can’t quite get it, though you’re sure the command is right. Only then do you realize that you’re attempting to run a command from one shell in another.
SEE: TechRepublic Premium editorial calendar: IT policies, checklists, toolkits, and research for download (TechRepublic Premium)
Some time ago, as I got more into macOS and Linux, I noticed that some commonly used commands share their usage and syntax across platforms. I began to use these whenever possible. Below you’ll find a collection of common, highly utilized commands that will make a useful addition (or replacement) to your knowledge base, especially if tasked with supporting multiple systems.
1. Secure shell (SSH)
Secure Shell (SSH) has long been a staple in macOS and Linux distros, however, a few years back Microsoft introduced it as a native component to its Windows line of OSes. It works exactly the same to securely connect to systems remotely, encrypting data transmissions, and generating keys for extra security. It is usually turned off by default but can be enabled either by command line or GUI.
Wget is one of those utilities that you might not have a real appreciation for until you use it and see how truly awesome it is. It is used to download data from servers, typically web servers, but can also be used as a tool to synchronize entire directories to a local drive. It has a large set of syntax for filtering data allowing you to copy as much or as little as you’d like or need. It also includes progress monitoring and can resume downloads from where it left off.
Going back to the early 1970s, the DD command has been used for a number of tasks: Transfer, recovery, and modification of data on a disk are some of the common use cases for employing this command. With many other types of commands to do this faster, why use DD? Apart from it being OS-independent, it also can be used to copy entire chunks of data from one drive to another, using it to make 100%, integrity-verified copies of files, directories, or entire drives to partitions, other disks, ISO files, or optical media.
SEE: macOS Big Sur: A cheat sheet (free PDF) (TechRepublic)
What ping does cannot be measured in time saved for countless admins throughout the world. The command is ubiquitous among many computer users, even non-IT-personnel, who are aware of what it means and does. While I believe ping to be pretty universal at this point, every few years I do get the “What is ping?” question. For those: It’s the command used to determine if a device is communicating online.
SEE: 10 more PowerShell cmdlets you can use instead of CMD commands (TechRepublic)
Curl works similarly to wget, except that where wget supports HTTP/S and FTP protocols, curl supports those and a whole lot more. Since curl can be used to transfer data bidirectionally and was created to work non-interactively, it’s perfectly suited for scripts and other automated tasks. It uses the URL path to get data from or send it to that location and includes a plethora of arguments for fetching secured data, providing credentials, data rate-limiting, proxying requests, the list goes on.
The network statistics command displays network connections and their respective port numbers, how the connections are configured (inbound/outbound), the types of connections they are, and the routing tables for each connection. It can also provide summary information over the total number of data transmitted/received, including parameters detailing loss and over IPv4/6 to name but a few.
SEE: How to run multiple Linux commands from one line (TechRepublic)
This command has been in use by Linux admins since its inception and continues to be a go-to command for retrieving the last few lines of its standard output. It does this however with a set of syntax that allows admins to filter data based on a specific input or wildcards to further breakdown reporting to just the details that are necessary. macOS has long had this feature as well, and surprisingly so has Windows, albeit through the resource kits made available for free by Microsoft for each version of Windows. The tail utility may be copied over to the System32 folder to provide the same functionality Linux and macOS admins continue to enjoy.
The cd or Change Directory command should be known to all but maybe the newest of computer users. Whether you’re trying to move forward or backward in the directory hierarchy, cd is the way to do it. Since it does not provide any real interaction, it can lend itself easily to be used in scripting and automation.
When working with data it needs a place to go. Unless you prefer desktops cluttered with files everywhere, the Make Directory command is your only salvation when it comes to organizing data in neat little folders, or nested within subdirectories. It can be used to create a single, one-shot directory, or can be customized (and scripted out) to create an entire directory tree structure.
SEE: 16 Terminal commands every user should know (TechRepublic)
The oldest command listed here is also, arguably, one of the least used, at least in my experience. The sort command does exactly as its name implies, it sorts the data of the input file into an order of your choosing. Depending on whether the data needs to be sorted by alphabetical, numerical, reversed, or some random or custom order, this is the utility to get it done quickly and efficiently.