Terminal/Command Line Basics

Back to Home Page


What is the Terminal?

The terminal (also called "command line" or "console") is like having a text conversation with your computer. Instead of clicking on icons and buttons, you type commands to tell your computer what to do. At first, it might seem scary, but it's actually a very powerful tool that all programmers use! If you practice, you can do things much faster than if you were using the graphical user interface (aka the GUI, the icons and buttons). If you want to work on software for a living, it's a great idea to start using the terminal now--it will definitely pay off! I use the terminal for everything now, I even made this website there.

Different operating systems call it different things:


Opening the Terminal

Windows:

  1. Press the Windows key
  2. Type "cmd" or "PowerShell"
  3. Click on "Command Prompt" or "Windows PowerShell"

Mac:

  1. Open Finder
  2. Go to Applications → Utilities
  3. Double-click on "Terminal"

Linux:

  1. Press Ctrl+Alt+T
  2. Or search for "Terminal" in your applications menu

Understanding the Terminal

When you open the terminal, you'll see something like this:

C:\Users\YourName>      (Windows)
YourName@MacBook ~ %    (Mac)
username@computer:~$    (Linux)
  

This is called the "prompt". It's waiting for you to type a command!


Essential Commands

Where Am I? - Current Directory

To see which folder (directory) you're currently in:

What's in Here? - List Files

To see what files and folders are in your current location:

Moving Around - Change Directory

To move to a different folder:

cd foldername

To go back to the parent folder:

cd ..

To go to your home directory:

Creating Folders - Make Directory

To create a new folder:

mkdir newfoldername

Creating Files

To create an empty file:

Copying Files

To copy a file:

Moving/Renaming Files

To move or rename a file:

Deleting Files (Be Careful!)

To delete a file:

WARNING: Deleted files don't go to the Recycle Bin/Trash - they're gone forever!

Clear the Screen

When your terminal gets messy:


Useful Tips

Tab Completion

Press the Tab key while typing a filename or folder name, and the terminal will try to complete it for you. This saves time and prevents typos!

Command History

Use the up and down arrow keys to scroll through commands you've typed before.

Cancel a Command

If something goes wrong or a command is taking too long, press Ctrl+C to stop it.

Getting Help

Most commands have built-in help:


Practice Exercise

Let's practice what we've learned! Follow these steps:

  1. Open your terminal
  2. Check where you are with pwd (Mac/Linux) or cd (Windows)
  3. Create a new folder called "python_projects":
    mkdir python_projects
  4. Move into that folder:
    cd python_projects
  5. Create a file called "hello.py":
  6. List the files to make sure it's there:
  7. Go back to the parent directory:
    cd ..

Great job! You've just used the terminal to create a project folder and file!


Common Pitfalls


What's Next?

Now that you know the basics of using the terminal, you can:


Back to Home Page