← Back to Home

🖥️ Terminal & VS Code Commands

Your cheat sheet for working with the terminal and VS Code on Ubuntu. Keep this page bookmarked — you'll use these commands every time you code!

1. Open the Terminal

The terminal is where you type commands to talk to your computer. It might look scary at first, but it's actually just a text-based way to do things you'd normally do by clicking around.

Ctrl + Alt + T

Press those three keys at the same time and a terminal window will pop up!

Terminal

chica@ubuntu:~$

💡 Tip: The ~ means you're in your home folder. That's your starting point every time you open a new terminal.

2. See What's Here: ls

Before you go anywhere, you probably want to see what files and folders are in your current location. That's what ls does — it lists everything.

Terminal

chica@ubuntu:~$ ls

Desktop Documents Downloads Music

Pictures python-tutorials Videos

Folders show up in the list. Now you can see where to go!

🔍 What does ls stand for?

"list" — it lists the contents of the current directory (folder).

3. Move Around: cd

Now that you can see your folders, you need to move into one. cd stands for change directory (directory = folder).

Terminal

chica@ubuntu:~$ cd python-tutorials

chica@ubuntu:~/python-tutorials$ ls

hello-python

chica@ubuntu:~/python-tutorials$ cd hello-python

chica@ubuntu:~/python-tutorials/hello-python$

Notice how the path after : changes as you move into folders? That's how you always know where you are.

🔙 Go back one folder:
cd ..

The two dots (..) mean "go up one level" — back to the parent folder.

🏠 Go home:
cd ~

The tilde (~) always takes you back to your home folder, no matter where you are.

4. Open VS Code: code .

Once you're in the right project folder, you can open it in VS Code with one command. The dot (.) means "this folder right here."

Terminal

chica@ubuntu:~/python-tutorials/hello-python$ code .

VS Code will open with your project folder loaded in the sidebar. You'll see all your files ready to edit!

VS Code — hello-python
1 print("Hello, World!")
2

💡 Tip: You can also open the terminal inside VS Code! Go to Terminal → New Terminal in the menu, or press Ctrl + ` (the backtick key, above Tab).

5. Activate Your Python Environment

Remember virtual environments from the Getting Started tutorial? Before running Python code, you should activate your project's environment so it uses the right packages.

Terminal

chica@ubuntu:~/python-tutorials/hello-python$ source .venv/bin/activate

(.venv) chica@ubuntu:~/python-tutorials/hello-python$

See the (.venv) at the beginning of the line? That means your virtual environment is active! Now any Python packages you install or use will be specific to this project.

🚪 Deactivate when you're done:
deactivate

This turns off the virtual environment and goes back to normal.

6. Run Your Code: python filename.py

With your environment activated, running a Python file is simple:

Terminal

(.venv) chica@ubuntu:~/python-tutorials/hello-python$ python hello.py

Hello, World!

Just type python followed by the name of your file. That's it!

💡 Tip: Make sure you're in the same folder as your file, or it won't find it. Use ls to check!

📋 Quick Reference Card

Here's everything in one place. Screenshot this or print it out!

Ctrl+Alt+T
Open a new terminal window
ls
List files and folders here
cd foldername
Move into a folder
cd ..
Go back one folder
cd ~
Go to your home folder
code .
Open this folder in VS Code
source .venv/bin/activate
Activate Python environment
deactivate
Turn off Python environment
python filename.py
Run a Python file
clear
Clear the terminal screen
Ctrl+`
Open terminal inside VS Code

🎯 Putting It All Together

Here's the typical flow every time you sit down to code:

Terminal

# 1. Open terminal with Ctrl+Alt+T, then:

chica@ubuntu:~$ cd python-tutorials/hello-python

 

# 2. Open VS Code

chica@ubuntu:~/python-tutorials/hello-python$ code .

 

# 3. Activate your environment

chica@ubuntu:~/python-tutorials/hello-python$ source .venv/bin/activate

 

# 4. Run your code!

(.venv) chica@ubuntu:~/python-tutorials/hello-python$ python hello.py

Hello, World!

That's your whole workflow! Open terminal → go to your project → open VS Code → activate environment → run code. You've got this! 💪

← Previous: Getting Started Next: APIs with FastAPI →