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:
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!
To see which folder (directory) you're currently in:
cd
(by itself)pwd
(print working directory)To see what files and folders are in your current location:
dir
ls
To move to a different folder:
cd foldername
To go back to the parent folder:
cd ..
To go to your home directory:
cd %USERPROFILE%
cd ~
To create a new folder:
mkdir newfoldername
To create an empty file:
type nul > filename.txt
touch filename.txt
To copy a file:
copy source.txt destination.txt
cp source.txt destination.txt
To move or rename a file:
move oldname.txt newname.txt
mv oldname.txt newname.txt
To delete a file:
del filename.txt
rm filename.txt
WARNING: Deleted files don't go to the Recycle Bin/Trash - they're gone forever!
When your terminal gets messy:
cls
clear
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!
Use the up and down arrow keys to scroll through commands you've typed before.
If something goes wrong or a command is taking too long, press Ctrl+C to stop it.
Most commands have built-in help:
command /?
(example: dir /?
)man command
(example: man ls
)Let's practice what we've learned! Follow these steps:
pwd
(Mac/Linux) or cd
(Windows)mkdir python_projects
cd python_projects
type nul > hello.py
touch hello.py
dir
ls
cd ..
Great job! You've just used the terminal to create a project folder and file!
cd "My Documents"
Now that you know the basics of using the terminal, you can: