Command Line Crash Course
Pt. 1: Anatomy of the Command Line
Most web software falls under the Unix umbrella of operating systems. Those include Linux, macOS, Android, and iOS.
This guide is intended for developers with limited command-line experience. The purpose is to provide a bare-bones instructional guide to the Unix command line in a practical way.
Before we get started…
I. Opening terminal
To run commands on the command line we’ll first need to open up our terminal. You can easily locate Terminal by opening spotlight on your mac and typing the word ‘terminal’.
II. Customize your terminal
There’s nothing more boring than staring at the default terminal, so why not add a little personality by changing your terminal profile.
You can do this at terminal>preferences>profiles. This menu allows you many different ways to personalize your terminal including different backgrounds, fonts, and color schemes.
Anatomy of a Command
The anatomy of a command very often consists of several easily identifiable components.
First, we’ll take a look at the entire command, then we’ll break it down into 5 sections;
Prompt, Command, Flag, Option, Argument.
ksagedeveloper@Kevins-Macbook-Pro ~ % mkdir -m a=rwx projectPrompt
The first section is known as the prompt. The prompt gives information regarding the username, machine name, and the directory.
ksagedeveloper@Kevins-Macbook-Pro ~ %ksagedeveloper = user name
ksagedeveloper@Kevins-Macbook-Pro ~ %Kevins-Macbook-Pro = machine name
Get Kevin Sage’s stories in your inbox
Join Medium for free to get updates from this writer.
The “~” symbol is demonstrating that I am currently in my home folder. If we change our directory, this will be reflected in the prompt.
Command
The second piece of our command line is the command itself. The purpose, of which, is to designate an action to be performed.
ksagedeveloper@Kevins-Macbook-Pro ~ % mkdir -m a=rwx projectFor example, mkdir is a command that creates a new directory within the current folder. In this situation, the current folder is your home directory, represented by the “~” symbol.
Flag
The next piece to our puzzle is the flag. The flag modifies how the command works and is represented by a letter or digit which follows a “-” (dash) or another flag
ksagedeveloper@Kevins-Macbook-Pro ~ % mkdir -m a=rwx projectIn this example -m is the flag that lets you establish permissions for our new directory.
Options
The next piece to our puzzle is the options. Most flags allow the ability to process specialized requests.
ksagedeveloper@Kevins-Macbook-Pro ~ % mkdir -m a=rwx projectIn this example, we can alter/create the proper permissions of our directory. a=rwx allows all users (a) permission to read (r), write(w) and delete (x) this directory.
Arguments
The final piece is our arguments which are typically reserved for the names of files and folders.
ksagedeveloper@Kevins-Macbook-Pro ~ % mkdir -m a=rwx projectHere, we’ve included the argument ‘project’ which will serve as our new directory.
Now that we have a pretty basic understanding of what makes up a terminal, command, in our next section we’ll take a look at some of the most common commands you’ll be using in most terminal sessions.






