by Monica Powell

A brief guide to getting started on UNIX/Mac OS terminal

When I was first introduced to the command line I really had to adjust to navigating my computer in a black box with just text. So I avoided the command line as much as possible. I was accustomed to the visual cues and feedback that a computer usually provides. In many ways it felt like I was re-learning how to use a computer via the command line.

Yet, since first learning how to navigate my computer using UNIX commands I’ve learned that the command line doesn’t have to be a scary thing just because there’s no visual feedback when typing a password in on the command line. As security, nothing shows up as you type in your password to indicate that any characters have been entered.

What is the command line?

The command line is a software that executes commands or instructions for a computer to manipulate or interact with its file system.

What is UNIX?

Why Use the Command Line?

In order to get started on the command line you should navigate to your applications and open the Terminal application.

0wX7Il6ZWb4qFXWhJ1rAvbrEAquvv0mWSDcV
Above is the Terminal Icon on Mac.

Create a Basic Website Folder on the Command Line

q-nEv8AuA5alFW0jj8uEDZfN7Re2bCsyWNbV
Folder structure of sample project

A folder with the above structure can be create on the command line by typing the commands inside of an empty directory:

skROBs72rmbM9R19Xll-9fVTzLXZoEi1VHrc
We start inside of an empty directory!
  • Make a directory (also known as a folder) called personal-website
    mkdir personal-website
nXYWE7E1AQgDoGiFXHYRmmop7jAGy7HR7Xt-
We’ve created a folder named personal-website
  • Navigate to inside of the directory called personal-website
    cd personal-website
  • create a directory, inside of the personal-website folder called assets
    mkdir assets
hwOipEstl7aPZxV1youY746JZnJqcuv8j5VU
We’ve created a folder inside of personal-website to contain all of our assets
  • Navigate inside of the assets folder which is inside of the personal-website folder
    cd assets
  • create a directory, inside of the assets folder named images
    mdkir images
  • create a directory, inside of the assets folder named js
    mkdir js
  • create a directory, inside of the assets folder named css
    mkdir css
VjWywXJ3fXn8IIUSS1rUS82fWBelN6qVwg28
We’ve created folders inside of personal-website/assets to store our project’s assets
loq-rOeylfEFovUlcja88GAhSSXTq4JRjjbC

Woops! We forgot to create an index.html file :(

We are in the assets folder and want an index.html file in our main personal-website folder. Typing cd .. will move us out of the assets folder and into the directory above which is personal-website. Now that we are in the personal-website folder if we type touch index.html a blank index.html file will be created.

ws7T-u5nT2AWqrsKAipU2E5upuEmeN18gCC5

Some frequently used terminal commands are:

commands to navigate/manipulate the filesystem

ls
list the contents of a directory

pwd
print working directory for the terminal to display the directory you are currently working on

touch
create or open a file without making any changes
very handy when wanting to create empty files without leaving the command line

sudo
this allows you to run commands as a super user

mv
move a file or directory
this can be used to move or rename a file by updating the file path

cd
change the current directory you are working on so that you can access files on a different part of the system
cd moves you to the root directory (top level folder on computer — usually the current User)
cd . current directory
cd .. navigates to directory two levels up

mkdir
make a new directory (or a folder)

Commands to Install Software

You can install some software from the command line using the following commands:

  • in Python pip install <package name>.
    Pip is a software package manager for Python.
  • in JavaScript npm install <package name>
    NPM is a package manager for JavaScript pages.

Commands to Run Software

In order to run a script on the command line you need to provide a command prompt and file name. Some examples are:

  • in Java javac filename.java and then java filename compiles java projects and then runs them.
  • in Python python filename runs python scripts.

If you find you are repeating a lot of commands you can scroll through your recent commands using the up/down arrows and edit them and re-run by navigating to them and then pressing enter.

Additional Resources to Get Started with Command Line Prompts

Decorating the Command Line

You can completely customize the colors and outputs on the command line to better suit your visual and aesthetic needs.

Here’s how I’ve made my command line prettier :

How to install Tomorrow Night
https://github.com/chriskempson/tomorrow-theme/blob/master/OS%20X%20Terminal/Tomorrow%20Night.terminal

Customize the terminal
I love the terminal. Besides the fact it makes you look awesome while using it, it can also do about a gazillion…mindthecode.com

If you enjoyed reading this article consider tapping the clap button ?. Wanna see more of my work? Check out my GitHub to view my code and learn more about my development experience at http://aboutmonica.com.