Command Line Interface

If you have never programmed before, you would probably use the computer as a regular consumer – accomplishing most tasks by using your mouse or trackpad, clicking on folders, dragging your files, navigating menu bars. This type of user interaction is called Graphical User Interface, or GUI ("gooey").

Most computer operating systems, Windows or Mac, are GUI based. You can read about this history of GUI.

For GUIs, everything is designed to be intuitive. A folder on the desktop would look similar to an actual folder in real life.

A computer representation of file folder on the left; a physical file folder on the right

Most icons are easily recognizable, intuitive and mimicking real life objects.

Can you think of 3 other examples?

The most noticeable feature of GUI is the mouse that you use to point and click. It's intuitive, simple and effective because it mimics how we use our fingers to point and touch.

Software developers have done a good job at designing the GUI, where a regular consumer, even a child, can pick up and learn how use a computer.

But, things weren't as fancy in the past. Programmers had to give commands to a computer through the Command Line Interface (CLI). The CLI is text-based and requires precise inputs.

For example, if you want to open Chrome in a GUI, you only have to double click the "Chrome" icon. For CLI, you have to type out something like $ open Chrome.

Command Line Interface on the left; Graphical User Interface on the right

To this day, CLI is still the preferred method for a programmers. But why? If GUI is more intuitive than CLI, why do programmers still stick with CLI? There are finite amount of space you can allocate to put icons here and there. So, there are limited amount of icons and graphical representations you can put on the screen before running out of space. Limited icons mean limited options and limited controls.

On the other hand, because CLI is command based, you can have thousands of commands and options because they are all hidden in the background. Yes, the programmer has to memorize the commands. But, the programmer gets to have a lot more controls over the computer.

What you see in GUI is actually a visual representation of the CLI. Instead of commanding with typing out, you are now commanding by clicking on icons.

Terminal

We use an application called Terminal, a command line interface. This can be found on most computers (Mac, PC, Linux). The command line language interpret is called Bash by default.

If you are using Windows, you can install Ubuntu Linux before you continue, we won't be covering the shell that comes with Windows. Please visit Ubuntu official site to learn how to install Ubuntu.

The following shortcuts and commands are for Mac OS.

To start a Terminal, open Applications > Utilities > Terminal or use the shortcut Command + Space to bring up Spotlight and type in "Terminal" and press Enter.

The tilde sign ~ is a symbol representing your home directory. The username should be the same as your computer's login account username (in this case, it's harrychen). The dollar sign $ tells you that you are on a new line, and the Terminal is ready to accept commands.

Try this, in your terminal type ls and press Enter, the Terminal will list out the equivalent in the form of text. You have just used your first command ls to list all files in the current folder.

Here, we have the test folder with 3 files: file_1, file_2 and file_3.

What would the GUI equivalent of this CLI command be? If you open up a new Finder window, you will see all 3 files (file_1, file_2 and file_3) contained in same folder test.

You can use $ open . to help you open the current folder

results matching ""

    No results matching ""