Command Line for Absolute Beginners (or the Confused and Frustrated)

Objective: Learn how to create a new project and files using command line.

Time to Complete: 30 Mins
Prerequisites: A Mac computer
What success looks like: creating a small project and not being afraid of Terminal anymore.

What you'll learn:
1. Where am I on this computer?
2. Tell me what files and folders are here.
3. Make a new file.
4. Make a new folder.
5. Go into a folder.
6. Go back a level.
7. Clear the screen
8. What commands do you accept?
9. Last commands used.

 


9 Terminal Commands To Get Started in Web Development

 

Step 1: First things first, you'll need to open Terminal. Navigate to it through your Applications > Utilities > Terminal.app or press command+spacebar and type Terminal (click to see gif).

 

Step 2: Begin Issuing Commands

1. In Plain English: Where am I on this computer?

pwd

"Print Working Directory"
What it does: Just tells you where you're currently at.
Warning: This gives you all of the directories you're nested in, so it can look like a lot.

 

2. In Plain English: Tell me what files and folders are here

ls

"Listing"
What it does: Shows you what files and folders are around.
Warning: None.

 

3. In Plain English: Make a new folder

mkdir foldername

"Make Directory"
What it does: Creates a new, empty folder based on what you name it. So type mkdir and then what you want the folder to be named.
Warning: Creating a folder does not mean you move into it.

 

4. In Plain English: Make a new file

touch filename.filetype

What it does: creates a new, empty file of the specified type. You could type touch script.js to create a blank javascript file, or touch style.css to create a blank css file.
Warning: Making a file does not mean opening the file.

 

5. In Plain English: Go into a specific folder

cd directoryName

"Change Directory"
What it does: This is equivalent to clicking on a folder to see what's inside it.
Warning: You have to type the exact and full name of the directory exactly as it's listed, capitals or lower-case and all.

 

6. In Plain English: Go back a level

cd ..

What it does: The ".." tells your computer you want to go up a level. Think of this like a back button.
Warning: Follow up with a pwd command until your comfortable so you know where you are.

 

7. In Plain English: Clear the screen


cmd + k


What it does: Terminal will keep a running list of everything, and will often barf a ton of information you don't need. This just resets the screen.
Warning: This is a keyboard shortcut, you have to press "cmd+k" not type it like the other commands. You can also type clear.
 

 

8. In Plain English: What commands do you want from me?

program --help

What it does: Each CLI tool has a set of commands it will accept. This lists out each of them.
Warning: Not every technology you're going to use will have this.

 

9. In Plain English: What did I just tell you?

up or down arrow

What it does: Terminal remembers the commands you type and if you need to jump back to one you just issued or issued before, you can cycle through this way.
Warning: Terminal remembers even if you mistyped it. So if the last command you issued was wrong, and hit your up arrow, you will re-issue the same wrong command.




The error you will likely see and what it means.

bash: command not found
Plain English: What you typed made no sense to me. You have to tell me commands I understand. You probably misspelled something or used a command that you can only use in another program.

 

Glossary of Terms I use

Command Line

This is the program you'll use when a fancy piece of software doesn't exist. It's how you talk to your computer and tell it what to do. All computer programs do is issue the commands, but instead you'll type them instead of click on buttons. By default, every computer has one, and the one for all OSX's is called Terminal. 

Bash

Bash is the language you'll issue your commands in. Think of it as the native tongue of your computer through Command Line.


CLI Tool

CLI stands for Command-Line Interface, and it's a computer science way of describing telling your computer what to do. Many tools and tech have a CLI tool, which allows you to use their software using their commands. A CLI Tool comes with a list of per-defined commands.


GUI

Graphical User Interface (pronounced "gooey") are the programs you're used to. iTunes, Spotify, Chrome are all programs that have a GUI so that you can issue commands by clicking on stuff instead of typing out commands.


Directory

This is computer science speak for "folder".

 


Why am I writing these posts?

I have a friend, we'll call him Dave. Dave reached out to me recently asking for advice on how to switch careers to be a web developer, and more specifically, what tools and technologies he should learn.

At the time, I was just two weeks into switching careers myself into a new job as a front-end developer.  I wanted to answer it for him, but I too didn't have the best resources for this.

Then I realized, if I wasn't going to answer it for him, no one was.

Dave, these blog posts are for you. Unfortunately, help is not on it's way and no one is coming to save you. No one did for me, but here I am, and so let's end the frustration and helplessness here. Stay with me.