Please enable JavaScript to use CodeHS

Terminal & Bash — Tutorial 1

Terminal Basics

Every time you drag a folder or double-click an icon, your computer is doing the same job behind the scenes that you can do with a few typed words. The terminal is a text-based way to tell your computer what to do. It looks plain, but it is one of the most powerful tools a programmer can learn.

What is a terminal?

A terminal is a program that shows the output of typed commands and lets you type new ones. On macOS and Linux, the default shell is usually Bash or Zsh. On Windows, tools like PowerShell, Command Prompt, or WSL give you similar control. In this series we focus on the Bash-style commands used on macOS, Linux, and in cloud servers.

Programmers use the terminal to:

  • move through folders faster than clicking,
  • run programs and tests in one line,
  • install libraries and deploy code,
  • automate repeated tasks with scripts.

The prompt

When you open a terminal, the first thing you see is the prompt. It usually shows your username, the computer name, and the folder you are in, then a $ or %.

Example prompt
learner@codehs:~/projects$

The part after the colon is the current folder. The ~ symbol is shorthand for your home directory, the main folder for your user account. Everything in the terminal starts from the folder you are standing in right now.

Creating files and folders

Two more commands make new things:

  • mkdir foldername — make a new directory.
  • touch filename — create an empty file or update an existing file's timestamp.

Typing is faster than right-clicking once you get used to it. It also makes your actions easy to copy, save, and share with other programmers.

Try the terminal

The simulator below starts you in your home folder. Click a hint button or type a command and press Enter. Type help if you get stuck.

bash — ~/home

Check yourself

Try each command in the simulator. Can you create a folder called projects, move into it, make a file named hello.txt, then go back to the home folder and list the contents?

The order matters: you must make the folder before you can move into it, and the file is created inside whichever folder you are in.

Quick quiz

1. What does pwd do?

2. Which command makes a new folder?

3. What does .. mean in a path?

Keep learning

You can now move around the file system, list files, and create folders. Next, learn how to copy, move, and look inside files.

Tutorial 1 of the “Terminal & Bash” series.