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 fundamentals.
What is the Command Line?
“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.
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.
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 collaborate 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 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.
Recommended Command Line Resources for Beginners
What Michael Recommends
As far as recommended resources go, Michael recommends:
- LinuxCommand.org: An excellent resource to begin learning the CLI, it builds from the basics up to shell scripting
- Arch Wiki's Command Line Shell: While this information may be from the Arch Wiki it is a resource that documents many things and usually has links to other resources.
- Zed Shaw's Command Line Crash Course: Covers Linux, Mac and Windows and is well worth the read if you just want to learn the basics.
What I Recommend
- Unix Command Cheat Sheet: First things first, check out my handy Unix command line cheat sheet
- Code School's Unix Basics Screencast: I love Code School. They have awesome web development related courses and workshops. Click here to started with Code School.
- Team Treehouse's Console Foundations Course: Similar to Code School, I love Treehouse. Treehouse is also heavily geared towards web development. But, at least at the time of writing, has more course offerings than Code School. Get your first 2 weeks free at Treehouse by clicking here.
Did you find this article useful? If yes, make sure to share it with a friend.