Understanding the Command Line for Beginners

| Get awesome (and free) stuff here

The Command Line Interface (CLI) is a way of interacting with your computer. And if you ever want to be a serious programmer, or even half-serious, you need to learn the command line.

Admittedly, the CLI looks intimidating to a lot of first-timers. (It was for me.) But it’s not that bad.

However, while I can navigate around the command line, I’m no expert in it. Which is why I invited my friend Michael Gattozzi to help explain some of the command line basics.

Disclosure: I’m a proud affiliate for some of the resources mentioned in this article. If you buy a product through my links on this page, I may get a small commission for referring you. Thanks!

What is the Command Line?

Michael explains,

“When you use programs with Graphical User Interfaces (GUI) certain buttons perform certain tasks on the computers. The Command Line Interface does that too, but it allows you to do it with more precision and power. You type words and hit enter, the shell interprets those words, and works with the OS kernel and files to execute the command.”

Okay, this may sound really confusing. So let me break it down.

The GUI is what most people use 95% of the time to tell their computer what to do. Below is the GUI version of opening the folder “myapp” on my desktop.

GUI screen capture opening "myapp" folder

That looks normal, right?

The image below has been taken inside the CLI on my computer. Here, I am also opening the folder “myapp” and then listing the other files/folders within it.

Seeing files in myapp folder via the command line

The shell is essentially where you are writing the commands in the command line. Bash is a widely used Unix shell (as seen above.) For Windows machines, you typically would use Command Prompt.

According to Google, a Kernel is,

“… the kernel is the central component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level.”

The point is, both the GUI and CLI are ways you can interact with your computer. But when it comes to the command line, once you learn the commands, it is faster and more powerful to navigate around your computer. That’s why many programmers prefer it.

In fact, there are lots of directions your computer can only execute if you tell it to do so via the command line. Yet another reason why programmers must learn how to use it.

Why is the CLI important when it comes to programming?

According to Michael,

“A lot of very useful programs work best on the CLI and it’s easier to setup and run them on there. For instance git, an often-used software revisioning system, was designed exclusively for the command line (though someone has probably made a GUI). It’s easier and faster to use and work on the code base with it.”

Despite whether you have used it or not, I am sure most of you reading this have heard of Github or Bitbucket before. This is what Michael is talking about above. Lots of programmers working individually or in collaborative environments “push” their repository to Github or Bitbucket. There are also many other features and benefits to using git.

Moreover, Michael explains

“The CLI allows you to do manipulations with your system’s internals and with code in a much more fine-tuned way.. [It] offers greater flexibility and control than a GUI regardless of what OS is used. Many programs that you might want to use in your software that are hosted on say Github also require running some commands on the CLI in order to get them running.”

Basically, it’s really, really important that you at least have a basic understanding of the command line. But to be a full-fledged developer, you have to be comfortable working in it.

Who should learn how to use the command line?

Learning how to operate within the command line has practical applications for any sort of programmer, especially those working on the backend.

“If you’re a backend developer [it] matters more since you’ll be dealing with the server aspect of it, such as what OS is it running, configuration files, and other things needed to make sure it is running …. [also] making sure the code for your site is working.”

Nonetheless, even if you’re a front end developer, knowing how to work with the CLI is beneficial.

“Front end developers don’t need to know it as much as you are really just designing the pages for the website, though it certainly wouldn’t hurt to know it if you’re trying to beef up your resume … And you’ll definitely need to know some of it if your team is using git.”

Some people, like Michael, use the CLI almost exclusively for they find it preferable to the GUI.

Personally, I could never see myself using the CLI predominantly. However, I do realize that it is crucial to understand if you ever want to be taken seriously at the professional level.

Note: A Difference in Operating Systems

Depending on if you use Windows or Mac/Linux, there will be differences in the CLI. As Michael notes, “most distributions of Linux and Mac run bash as their choice of shell for the terminal”. Nonetheless, all of the commands are standard across Unix machines.

While Windows does have a CLI, unless you work in IT or are doing Penetration Testing, Michael wouldn’t recommend learning it is a prerequisite. Additionally, its commands and how it works are different from Linux and Mac.

What Michael Recommends

As far as recommended resources go, Michael recommends:

What I Recommend

Did you find this article useful? If yes, make sure to share it with a friend

About Michael Gatozzi

Michael Gattozzi is a student at Umass Boston and a member of the MA Army National Guard. In his free time he likes to write scripts, read technical and non technical things, and tinker with his laptop for the perfect setup. He’s also a follower of the Google Dark Arts and an Arch Linux die hard fan.

You can follow him on github on github.com/mgattozzi and on Twitter @mgattozzi.

Image courtesy of JoshuaDavisPhotography via Flickr.

laurence photo