Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Tutorial: Working in the Terminal

You may have already noticed you’re not able to navigate the terminal using your mouse or cursor. We can navigate the terminal using the keyboard. The up and down arrow keys let you move back (up) and forward (down) through previously typed commands. The left and right arrow keys let you move within characters or symbols for a specific command.

Press the up arrow once to show the previously-typed echo command. Then, use the left and right arrow keys to navigate to the characters within the quotation marks and replace them with another word or phrase of your choosing. Press Return or Enter to run the modified command.

A couple other useful navigation tools:

Terminal syntax

A couple notes on terminal syntax:

Not all commands require arguments or options, but some commands can have one or more of each. You can also chain multiple commands together using the vertical bar | symbol. This is often called a pipe.

Have you ever tried to find a specific file on your computer? This is a common user task, but we can start to better understand how the computer stores and organizes information.

pwd

pwd

Before we start moving around, let’s use the pwd (print working directory) command to show your current location. Type pwd in the terminal and press Enter or Return. Your output might look something like this:

/Users/kwalden

This directory information is called a path (sometimes called a file path when dealing with specific files).

So in the /Users/kwalden example, the terminal is running in the kwalden subfolder which is located in the Users folder. The Users folder is located at my computer’s root.

Diagram illustrating computer directory structure

The inverted tree diagram shown above shows one example of a computer’s file system.

If you have ever used File Explorer (Windows) or Finder (Mac), you have navigated this tree structure using the graphical user interface (GUI). Now let’s think about how we navigate this structure using the command line interface (CLI).

ls

Typically by default, your terminal will open in the folder or directory for your user profile.

ls

Let’s see what other files and subdirectories are located in your current path by using the list command (ls). Type ls in the terminal and press Enter/Return.

Terminal screenshot showing directory contents

Items that are followed by a file extension (e.g. .docx, .txt, .xlsx, etc) are generally individual files. Items that do not have a file extension are typically subfolders or subdirectories.

cd

We can move down the tree using the change directory command (cd). Let’s move from your user profile folder to the Desktop.

cd Desktop 

Type cd Desktop and press Enter/Return.

When using the cd (change directory) command, we are navigating the computer’s file system using relative paths. This means the location information we are specifying in the terminal is relative to our current position or location in the file system. The previous cd Desktop command is an example of a relative path.

Absolute paths always start at the root and use backslash / symbols to indicate subfolders.

We can use the ls command again to see the materials located on our Desktop. We can also move back up the file system tree using the cd command.

cd .. 

Instead of using cd followed by a relative or absolute path, we can use cd .. (cd followed by a space and two periods) to move up one level in the tree. Type cd .. in the terminal and press Enter/Return. You can test using pwd if needed, but you should be back in the specific user profile folder.

Key Concepts