Terminal Basics

Part of the journey of growing into a skilled programmer is about becoming proficient with the tools we have at our disposal. The terminal is a text-based system that allows you, as a user, to control your computer and do everything from creating new files and folders to starting up entire applications.

Interacting with the terminal is something you will most likely do everyday in your coding career. You may find the terminal initially intimidating to use - all commands must be entered as text and the terminal has its own language. However, once you get over this initial learning curve, you'll discover the terminal is your most powerful tool!

Let's start with the basics. There are a few differences between the terminal on Mac and Windows environments. On Mac and Linux users should use the Terminal application, while Windows users should use the Ubuntu application (or the Ubuntu shell on Windows Terminal). Anytime the curriculum refers to the terminal, make sure you are using the correct application based off of your operating system.

When you finish this reading, you should be able to:

File tree

As you start writing code on your local computer you'll find it soon becomes essential to have the ability to navigate around your file system. Before you start exploring the syntax of how to navigate your file system - you will learn the basics of how your files are structured.

Below is a basic visualization of what a file tree might look like:

file-directory

Essential terminology

To explain the above picture properly you first need to learn some important terminology that you will see at App Academy.

Now look again at the image above. The root directory sits at the top of the chart as the outer main directory. All other directories can be accessed from root by following a path (the dotted lines in the chart above). All directories can contain both files and subdirectories.

Basic terminal navigation

NOTE: Unix refers to the parent operating system upon which Mac is built upon and Linux is inspired by. They have (nearly) identical commands and features and both use the Terminal.

Windows Users only: Windows is not Unix-based, so if you were a Windows user, you had to install WSL and use Ubuntu as your terminal because Ubuntu is a Linux distribution. For the rest of the course, you will be using Ubuntu to enter terminal commands that App Academy introduces. You should also be using Ubuntu to test out the commands in this reading.

Navigation of the Unix file system

Let's get started! Open a new terminal. It should greet you with a prompt that may look like this:

~ $

Navigation commands

Here are some basic terminal commands that will help you navigate the file structure:

When opening a fresh terminal window the default directory opened will be the home directory. Your home directory will be represented by a ~. So for example, if your computer user's name was janedoe then a fresh terminal would open to ~ and using the pwd command would print out your current location.

Running the pwd command in the terminal when the terminal is in the home directory would print out something like this:

For Mac users: /Users/janedoe
For Linux users: /home/janedoe
For Windows users (on the Ubuntu terminal): /home/janedoe

Create a new directory or file

Note: A directory is also often referred to as a folder in a file structure.

GUI vs. CLI

There are two different kinds of tools that developers use to execute tasks like viewing and managing computer files.

The CLI, Command Line Interface, predates the GUI, graphic user interface, that you are familiar with. Many coding specific programs can only be run from the command line (like Node.js or mocha!). Working with your own computer will really help these ideas sink in, and once your have fluency with commands in the CLI you'll find it much faster to do essential tasks without a GUI.

What you've learned