To navigate the filesystem and use the operating system most users use the graphic user interface (GUI) such as the Desktop or the Finder (File Explorer on PC). This GUI graphically shows all the files and directories on a machine, allowing them to be clicked on with a mouse to be accessed. This allows common users to open files, run programs, etc. all at the click of a mouse. These graphics are nice for the every day computer user, but are unnecessary for programmers. Programmers tend to navigate the file system and use the operating system using command line interfaces (CLI). A command line interface is a program that processes commands in the form of lines of text. The CLI of a machine will read unix commands--built in instructions that can be invoked from a Unix terminal--or other commands written by programmers that the user wants to run and run the program associated with the command. We will go into further detail on these commands in a bit, but first let's go over the different kinds of CLIs available.
The Terminal is a CLI native to Unix and Unix-Like systems which processes Unix commands. The terminal can be found on mac by hitting command+space and searching for 'Terminal' (without the quotes) or by searching in Launchpad. On Linux the terminal can be found by hitting the super key (command/windows key) and searching for 'Terminal' (without the quotes) or by searching the applications menu. Terminal can accept any unix command natively. See below for a picture of a terminal window (note the colors of your terminal window may be different as they can be changed).
From the image above it can be seen that the the terminal first has a prompt that waits for user input to do anything:
alex-imac24@Alexs-Personal-iMac ~ %
The █ following the %
is waiting for user input such as:
The blank command prompts are from just hitting the enter key, but once a command such as ls
(explained later in this post) is entered the command is run and output produced. In this case all the contents of the current directory are listed.
The Command Prompt is a CLI native to Windows systems which processes Windows commands. The command prompt can be found on any Windows machine by entering Windows
+ S
and searching for Command Prompt
or by searching using the built in search on Windows. The command prompt is a bit different from the terminal wherein it does not natively run unix commands, instead there are different commands that have been developed by Microsoft to do some of the same things as Unix commands. See below for a picture of a command prompt window window (note the colors of your command prompt window window may be different as they can be changed).
The Command Prompt looks very similar to a terminal but if you enter a Unix Command it will not work:
This is because the Unix commands are ment to control Unix file systems, while the command prompt is controlling the Windows file system (click here for file systems explained). Since most programmers use Unix commands it is important to install a Unix terminal (called the Windows Subsystem for Linux or WSL) on all Windows machines that will be used to program.
Since Unix commands are much more popular in computer science Microsoft has built the Windows Subsystem for Linux (WSL)--a tool used to install a Unix-compatible terminal emulator on Windows. Using the WSL provides a way to mimic the Unix terminal allowing Unix commands to be run on a Windows machine.
The WSL prompts similar to how the Unix/Linux terminal prompts. The most important part though is that it accepts Unix commands:
To download and install the WSL and a Unix terminal on Windows follow this guide.
Command line interfaces accept commands typically in the form of Unix commands (with the main exceptions being the Windows Command Prompt and PowerShell). Unix commands allow the file system to be navigated, and for operations to be performed on the system.
For more on Unix Commands see this post
Command Line Interface - A program that processes commands in the form of lines of text.
Unix Commands - Built in instructions that can be invoked from a Unix terminal
Terminal - A CLI native to Unix and Unix-Like systems which processes Unix commands
Command Prompt - A CLI native to Windows systems which processes Windows commands.
Windows Subsystem for Linux (WSL) - A tool used to install a Unix-compatible terminal emulator on Windows. This enables the use of Unix commands in a Windows environment.
What is the difference between how a normal uses the operating system (through the GUI) and a Command Line Interface (CLI)?
Why might a programmer prefer to use a CLI instead of a GUI?
What are the advantages of using a CLI for navigating a file system?
Why do most non-programmers rely on a GUI?
Can both GUIs and CLIs be used to access the same files on a computer? Why or why not?
What is the terminal in macOS or Linux?
What is the Command Prompt in Windows, and how does it differ from the terminal?
Why won’t Unix commands work in the Windows Command Prompt?
What is Windows Subsystem for Linux (WSL) and why might a developer install it?
Why is WSL useful for people working on Unix-based code but using Windows?
What is a “prompt” in a terminal or CLI?
What does the prompt indicate to the user?
What kind of information is typically displayed in a terminal prompt?
What happens when you type a command into the terminal and press Enter?
What does it mean when the terminal displays a new prompt after entering a command?
What does it mean that a CLI processes commands “in the form of lines of text”?
Why do different systems (macOS/Linux vs. Windows) require different CLI programs?