by Monica Powell

Conquering the Command Line

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

Output on Mac OS terminal after typing: telnet

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.

Above is the Terminal Icon on Mac.

Create a Basic Website Folder on the Command Line

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:

We start inside of an empty directory!
  • Make a directory (also known as a folder) called personal-website
    mkdir personal-website
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
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
We’ve created folders inside of personal-website/assets to store our project’s assets

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.

Some frequently used terminal commands are:

commands to navigate/manipulate the filesystem

list the contents of a directory

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

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

this allows you to run commands as a super user

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

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

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 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

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…

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