Command Line, GUI, What’s the Difference?
The first computer I ever had was some 90’s beige, enormous hand-me-down from my dad. He gave it to me when I was about eight or nine and told me “no online stores, no chat rooms, have fun!” It ran Windows XP and had Internet access, though at this point I had no clue what an operating system or network was. Still, my brothers installed Kazaa for me and I learned how to download music (not understanding the DRM issues)!
One day, my dad decided to show me a “cool” program on XP. He opened
cmd and said, “Here. This is DOS. This is what your computer runs on.”
Now, at the time, most of what I knew about computers came from The Matrix (my brothers let me watch it with them after my parents went to sleep ☺), so seeing a terminal prompt made me excited… I could hack into other computers now! I was under the impression that the command line would give me more power and if I learned how to use it I could rule the world.
“How do I use it?”, I asked. My dad leaned forward, typed
help and struck the enter key. A wall of text filled the small black rectangle – it reminded me of the cascading text I had seen in The Matrix. “That’s how,” he replied, “Read through the help page and you’ll learn how it works.” Scrolling through it, all I saw was complete gibberish. Unfortunately, being so young, I quickly lost interest.
About seven or eight years later I began my first installation of Arch Linux. I had installed other Linux distros before, but with point-and-click installation, all of the details of what was happening behind the scenes were abstracted away from me. Arch was different. When you boot up a live ISO of Arch, here is what you’re presented with:
Now, this isn’t all that different from the command prompt I was presented with back on Windows XP, but my understanding of its power was about to change. Following the Arch Beginner’s Guide and researching commands I didn’t understand, I learned how to set up a fairly typical GUI Linux system starting with very little other than a shell, standard utilities, and a package manager. I came to an important understanding. The command line is no different than the GUI.
Well… of course they’re different, but what I mean is that they’re different interfaces to the exact same system. For example, say I want to duplicate a file inside a directory. In my GUI, I might right-click on the file, select “Copy” from the menu, right-click some white space in the directory and select “Paste” to duplicate the file. In the shell, I would use the
Both of these methods will eventually check permissions, allocate space, assign ownership, and execute whatever other operating system calls need to occur to copy a file. Neither is more correct than the other. They accomplish the same task on the same system, and all the same system calls are eventually used. To use a metaphor, whether you read a book from a page or listen to it being read to you, the same story is being told.
Now, I enjoy using the command line. I find that for most tasks, it’s easier and faster for me to use the shell, but it’s certainly not for everybody. Many people are visual and a traditional GUI environment is the most effective way for them to interface with their machine. That’s perfectly fine! However, I do think that programmers should have a fundamental understanding of how the command line works.
There are countless tools for programmers that are designed with a command line interface only. From a developer’s perspective, it’s easier to write command line applications and they can be used on systems without any graphical environment. If the tool isn’t inherently graphical (like an image editor), there’s really no reason to pull in additional dependencies other than giving the user the option of a GUI. Additionally, the command line is a simple, linear interface – lending itself to a typical programmer’s mindset. Often, the developers who are talented when it comes to low level programming are less talented when it comes to developing user-friendly GUIs.
For these reasons, I think it’s important for programmers to familiarize themselves with the command line. I’ve encountered too many developers who are mystified by the terminal and don’t fully understand how to create a program that accepts command line parameters. The culture and tools of this industry are heavily tied to the command line. Whether you prefer to use a GUI or not, it’s an important skill to learn.
The fastest way to learn, in my opinion, is to immerse yourself in it. When you have a task to accomplish, trivial or not, open up your terminal and do it with your shell. Copy a file (
cp), move a file (
mv), download a file (
curl), read a file (
cat), etc. If you’re not sure what command to use, Google it! If you don’t know how to use a command, look at the command’s documentation (
Another excellent tool to help understand commands you might encounter online is Explain Shell. You can input the command and it will explain what each individual option does and how it changes what the command will do.
Finally, research the topic! Figure out the difference between a terminal, shell, and console. Learn about pipes and I/O redirection. Write a shell script for anything you do more than once. It is all very well documented.
What do you think about the command line interface? Should it become a more standard topic for programmers to learn about? Let me know in the comments section below!