Skip to content

What is the Command Line? CLIs from First Principles

Eventually it happens to every new WordPress developer: someone blithely tells you to just “pop over to the command line” and suddenly you feel like a fraud. You shouldn’t–everyone is new once, and someone who won’t explain what they mean by that to you is a jerk–but you do. Most new developers hit that point, often at a local meetup or WordCamp. This is a tutorial for anyone who’s currently stuck there. And for people who are no longer stuck there, I’ll try to include enough details and anecdotes that you’ll learn a little something too.

This is not a guide which will explain to you exactly what to type into your terminal to make a certain thing happen. We’ve got a attention-limit we need to stay within. Our goal here is instead to give you a thorough understanding of the concepts that matter and make command line interfaces (CLIs) confusing for newcomers. Once you’re ready conceptually, understanding a specific command is generally a whole lot easier.

Before There Were Windows, There Were CLIs

The first thing that’s helpful in understanding the command line is understanding the things that came before computers as we know them today. Modern personal computers use “windows” to show lots of different screens of programs at once. Under (in a visual sense) those application screens, they typically have a “desktop”. These metaphors help people more quickly understand the computer. But they’re just a prettier and simpler interface to the computer’s machine heart.

Before there were windows, there was just the “terminal.” The “terminal” is the “command line.”

Before there were windows, there was just the “terminal.” The “terminal” is the “command line.” (It’s also worth knowing that before there was the terminal—a blinking white line in a black field on a screen– computer’s were generally interfaced with by physical stacks of punch cards. I’m glad I missed that era.) The terminal is just a different system of running all those sorts of programs that you can run in your GUI (short for graphical user interface) environment of macOS or Windows or desktop Linux.

Different from a GUI though, terminal programs rarely provide a lot of hand-holding and interface. The computer users who dominated in the era of terminals were people with lots of and lots of history with computers, who mostly thought that pretty interfaces got in their way. You still find these people today.

Where in most GUI systems you double click a program with your mouse to run it, on a terminal you’d type a command’s name (that is, the program name), and maybe some options you’d want it to run with, and it would run. I italicized “with your mouse” in the last sentence because that’s a big difference between GUIs and terminals: the mouse. Terminals are generally ignorant of your computer’s mouse. They came from the era before those were a common peripheral to a desktop computer. So everything about a CLI application is going to be keyboard controlled.

Terminals are generally ignorant of your computer’s mouse. They came from the era before those were a common peripheral to a desktop computer.

The other big difference is that GUI’s are generally in a persistent “waiting” state when the program is “running.” Because most terminal-running programs were from an earlier era, and because the interface didn’t really have a space to show you a set of “running” applications, they run quickly when invoked and then stop. It’s not very common for a “program” interacted with via a CLI to do much more than run in under a second and quit. (Though some do run for a while, like text editors.)

So to summarize both terminals and GUIs run programs. They differ in that:

  1. Terminal commands are simple programs running once.
  2. Unlike GUI programs which are always waiting for you, most terminal applications run quickly and quit.
  3. Terminal commands are often dense with meaning and short, because people wanted to type as little as they could get away with.
  4. Terminals don’t (generally) use the mouse in any way.

Operating System Matters

There are two kinds of “terminals” you need to understand. There are “Unix-like” terminals, and there are Windows terminals.

Terminals can be thought of as a more direct interface into the inner-workings of your computer. This is what makes them great and powerful, but this also means you have to know a little more about how your computer works. Most average consumers understand that Windows is different from the Mac, which is different from Linux. But they also know that they can run Firefox or Microsoft Word on most of those systems, which isn’t as true of terminals.

There are, really, only two kinds of “terminals” you need to understand. There are “Unix-like” terminals, and there are Windows terminals. Both Linux and Macs run a “Unix-y” operating system, and thus the terminal most commonly used on both is something called BASH (a smidge more on that later…). There are important and subtle differences between how you work on various “Unix” systems, but they’re mostly unimportant for the day-to-day work of a professional web developer. They’re the small differences that as a newbie you can ignore. (Although, if I’m honest with you, not forever. You will eventually find as you get more comfortable with the command line that those things do matter.)

Windows is the odd-one-out in the terminal game. That’s one of the big reasons that I (and I think many other web developers) left Windows-based PCs for Macs in the last decade. The historical Windows shell is different enough from the other kinds that many commands aren’t interchangeable. This is essentially an artifact of how much earlier Microsoft left the global sea of computing than everyone else. But it does make it the case that Windows users can often find the command line an even bigger barrier.

(Microsoft) Windows Realities

windows_logo_cyan_rgb_dAs a Mac user for nearly a decade, I can’t say with much confidence or certainty what’s true of trying to learn the terminal with a Microsoft operating system (either Window 10 or before) and needing to do web development tasks on a command line. I’ve heard more than a little frustration from people in that boat. And while I know that most things theoretically work on Windows, I also have heard too much that the reality is that it’s tough.

This isn’t to say that you must go buy a Mac or install a Linux variant to be a web developer. Far from that. And with the new “Bash on Ubuntu on Windows” in Windows 10 (here’s a tutorial on setting that up) you maybe can have the same kind of terminal most others users have right inside Windows itself. It may work well for you, it may not.

For most web development work, especially in the open-source world that WordPress inhabits, your servers will run Linux of some flavor. That also means that that you need to connect to them remotely and run “Unix-like” shell commands. That is very doable on a Windows machine (most often with PuTTY), but it is not “baked-in” in the way that it is on natively-Unixy systems.

How To Find Your Terminal

On a Mac, and most versions of desktop Linux, you can quickly access a terminal via an application labeled “Terminal.” Open that up, and you’ll generally find a window that lets you use your computer with a very different interface than you’re used to. On Windows, this “terminal emulator” is called “Command Prompt”. Both will let you run a program by the simple entering of a few characters that make up the relevant command.

There are alternatives. On the Mac, I personally use an application called iTerm 2 for a large number of small niceties. But the basic thing that I’m accessing is the same: a simple interface with limited features that is essentially keyboard driven.

The Different Kinds of Command Line Terminals

Another mostly brief note: there are lots of different command line terminal “shells” you can run. Most people–and basically all of those who don’t know which one they use–use a BASH shell on a Unix-like systems. The intricacies of the different shells that run atop Unix are far beyond the scope of this article and somewhat beyond the scope of my understanding. If you just know that you’re running BASH (and not ZSH or FISH or whatever) on Unix, you’ll be fine.

How You Access The Command Line on Your Server

You need a way to get access to the terminal on your server. This is done though a technology called SSH.

The final thing that we need to make sure to touch on is that you can access (on most servers, shared hosting being a common exception) the command line of the computer itself. For various reasons, mostly down to system resource efficiency, servers will not run a traditional windowing GUI system at all, even as an option. (This is different than on your local machine, where the command line is merely a different way to interact.)

In these cases, you need a way to get access to the terminal on your server. This is done though a technology called SSH. SSH stand for Secure Shell, and allows you to access the shell (again, basically terminal or command line) on a remote machine securely. Again, the intricacies of setting up and using SSH are far beyond the scope of this article. But you can basically accurately understand that SSH is how you access the command line of a remote server. The tool we mentioned earlier, PuTTY, is the most common way that Windows users use SSH. For Macs, Linux, and other Unix variants, all that’s necessary to use SSH is the ssh command on your command line.

What I Hope You Now Understand about the Command Line

You could use the command line every day and likely regularly find new things you didn’t know.

The command line is one of the bigger conceptual leaps for people who were born after the era when to use a computer was to use a simple terminal shell. GUIs have made our lives so much easier. But for people forced to drop down the command line sometimes, GUI interfaces have made a previously familiar world a little more foreign.

What I hope you now understand is that history: how the command line is really just a more primitive way of interacting with a computer. In some ways, it’s a “truer” way of interacting with it. In other way it’s just an annoyingly constraining way of interacting with it that may be required because of necessary limitations (like a server maximizing its resources).

Like most things about a computer, the operating system is underneath everything. This is why the Microsoft operating systems have a different terminal than the Mac or Linux. And Unix is the operating system class that contains both Linux and the Mac, and makes the command line of those two quite comfortably similar.

The intricacies of using the command line, never mind being completely comfortable while doing it, are vast. You could use the command line every day and likely regularly find new things you didn’t know–new commands, new flags on commands, whole new concepts underneath. But they’re also a number of small and simple commands that’ll really help you get comfortable and start to understand what’s going on. And those are worth learning, even if you never use the command line a lot.

In the coming months, we’ll come back to this topic regularly. You can get a lot done in WordPress without ever using the command line. But to really up your skills as a developer or administrator of WordPress, the command line is essential understanding. Hopefully this primer has given you a clear sense of where to look and where the major concepts are buried. Happy hacking!

Yay! 🎉 You made it to the end of the article!
David Hayes

Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Working With The Command Line and WP-CLI – WPShout
June 6, 2017 12:12 pm

[…] What is the Command Line? CLIs from First Principles […]

Anatomy of a WP-CLI Command: wp database import | WPShout
May 9, 2017 10:54 am

[…] What is the Command Line? CLIs from First Principles […]

The What, How and Why of WP-CLI: WordPress in Your Terminal | WPShout
January 31, 2017 9:42 am

[…] that allows you to use WordPress on the command line. Don’t know what the command line is? We’ve got an article explain exactly what a “terminal” is why they’re useful… The executive summary is that it’s a low-interface way to manipulate […]

Command Line File Manipulation for WordPress Developers: An Overview
November 29, 2016 11:24 am

[…] weeks ago, we published a conceptual primer on the command line for WordPress developers who’ve never used it and never thought of using it. That article didn’t really touch on […]

Rew Rixom
November 16, 2016 9:54 am

I recently switched from Mac to PC and have found ‘bash on ubuntu on windows’ to be great.

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

Would love your thoughts, please comment.x

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

20 Best Free WordPress Themes for 2024 (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...