Take command of your computer with a command line interface

A CLI might not be as pretty as a GUI, but it's significantly more powerful

Most IT professionals will be familiar with the command line interface (CLI). Like the graphical user interface (GUI), a CLI is just another way of talking to a computer.

Early users would operate computers by flipping switches. before moving on to cards and Teletype machines. Electronic terminals were next, and that's where the CLI started. It lets you type sophisticated commands for your computer rather than waving a mouse around, and even though it isn't as pretty as a GUI, it's far more powerful.

A CLI is also much faster. Let's say you need to find all files changed in May 2006. You could do this in Windows using Explorer, but it's a cumbersome processor; you'd need to open Explorer, click in the search window to bring up the Date Modified button, search the date to bring up a calendar, click your way back to May 2006, click May 1 and shift-click on May 31, and then press enter. Tiresome, right?

In a Linux-style CLI, you could simply type:

find . -type f -newermt 20060501 \! -newermt 20060601

This tells the computer to find all files newer than May 1 2006, but not older than May 31. The commands may seem like gibberish, but once you take the time to learn them, it becomes much easier to do things quickly. 

A CLI interface doesn't just speed up GUI functions - it lets you do things that GUIs can't. Let's say you work for X Corp. You've been writing its technical manuals forever, and last week, the company changed its name to Y Corp. Your manager tells you to change the name in the last five years of documents. There are hundreds of them buried in a folder structure six layers deep.

You can find those documents in the Windows GUI easily enough, but changing their text would be a nightmare. On a Linux command line, you can do it in one line:

find . -type f -exec sed -i 's/X Corp/Y Corp/g' {} +

This finds all the files in the directory and then uses a replacement function, sed, to swap out the text. 

CLIs become even more powerful when you chain multiple commands together, using one command's output as the input for the next. Modern CLIs are even scriptable, so you can write small programmes to perform many repetitive tasks. It's easy to see why expert system administrators prefer the CLI to a GUI. They can use it to automate tasks at an advanced level.

How do CLIs work?

These tools use a shell, which is a programme that interprets your commands and then sends them to the underlying operating system kernel, which runs them and produces an output that is relayed back to you. It can run on your own computer or on a remote server, accessible using a program that lets you use the shell remotely, like telnet or ssh.

Command line shells really began with Unix systems and their predecessors. One of the first shells was Runcom, a program developed at MIT in the mid-60s that allowed admins to run lots of commands as batch files. Then the Thompson shell appeared in 1971, but was mostly just an interpreter, running commands as the user typed them in, with some limited scripting capabilities. Shells evolved again with the creation of the Bourne shell (known as sh), and one of its most popular successors, Bash (Bourne-again shell). Released in 1989, the Bash free open source shell has become the de facto standard on Linux systems, but there are many others to choose from.

Microsoft also has its own rich history of CLIs. The original MS-DOS operating system was CLI-based, and early Windows versions were GUI shells running on DOS. Following ventures like Xenix (Microsoft's version of Unix) and OS/2, Windows NT became the basis for modern Windows. This introduced the CMD.exe shell, designed to be backwards-compatible with the DOS CLI.

However, CMD.exe would soon prove inadequate for more sophisticated modern-day tasks, so Microsoft created PowerShell. This was a more sophisticated object-oriented CLI that enabled users to manipulate every part of the Windows system.

Building a CLI for the future

PowerShell Core, the open-source version of PowerShell released in 2017, gave users with Linux and even Mac systems access to the powerful CLI tool. This decision also formed part of a broader Microsoft shift towards embracing Linux, having first introduced the Windows Subsystem for Linux (WSL) in 2016, allowing programmes to work on Windows operating systems, meaning Windows users could use a Bash shell.

Technically speaking, you don’t need to access cmd.exe or PowerShell directly, rather they invoke the Windows Console when you open them, which is Microsoft’s front-end user interface for cmd.exe. It renders Console essentially the same as Terminal, through which you can control Bash and other shells on Linux and Mac systems.

The company has since announced at its virtual Build 2020 conference that Windows Terminal, the successor to Windows Console, would be generally available. Among the features are multi-tabs, GPU-accelerated text rendering and support for Unicode and UTF-8 characters. This means official support for emojis. Additionally, Windows Terminal can be used with various command line systems that Microsoft also supports, including Windows PowerShell and WSL.

With the nature of the CLI evolving over time, the next generation of techies and programmers may potentially be entirely unfamiliar with the sorts of tools that have been in use for generations. This cohort may instead come to rely on voice commands or gesture-based systems. Each step represents a significant shift from the power of the CLI, although it’s well worth exploring this tool in more depth if you wish to retain ultimate control over your device.

Featured Resources

The complete guide to changing your phone system provider

Optimise your phone system for better business results

Download now

Simplify cluster security at scale

Centralised secrets management across hybrid, multi-cloud environments

Download now

The endpoint as a key element of your security infrastructure

Threats to endpoints in a world of remote working

Download now

2021 state of IT asset management report

The role of IT asset management for maximising technology investments

Download now

Most Popular

Best MDM solutions 2020
mobile device management (MDM)

Best MDM solutions 2020

21 Oct 2020
What is Neuralink?

What is Neuralink?

24 Oct 2020
Hackers demand ransom from therapy patients after clinic data breach

Hackers demand ransom from therapy patients after clinic data breach

27 Oct 2020