AcademyRecruit

Linux Command Line Basics for Makers

The 15 commands you will use in every project — then practice them in our terminal simulator.

LevelRecruit
Time40 min
Est. costFree
Steps5

You do not need to memorize Linux. Fifteen commands cover moving around, creating files, installing software and running programs. Practice them risk-free in the Terminal Simulator, then use them on your real Pi.

Video tutorial

Video by sentdex, embedded from YouTube. The written steps below are our own and match the parts list.

Mission steps

  1. Know where you are

    pwd prints your current folder. ls lists what is inside; ls -la also shows hidden files and permissions.

  2. Move around

    cd folder enters a folder, cd .. goes up one level, cd ~ goes home.

  3. Create and edit

    mkdir makes folders, touch creates empty files and nano file.py opens a simple editor (Ctrl+O saves, Ctrl+X exits).

  4. Install software

    sudo apt install package installs programs. For Python libraries, create a virtual environment and use pip inside it.

  5. Run and stop programs

    python3 file.py runs a script. Ctrl+C stops it. Add an & to run it in the background.

Code

pwd                 # where am I?
ls -la              # list everything
mkdir -p ~/projects/robot
cd ~/projects/robot
nano motor.py       # edit a file

# Python virtual environment (recommended)
python3 -m venv --system-site-packages ~/venv
source ~/venv/bin/activate
pip install requests

htop                # live CPU/RAM monitor (sudo apt install htop)

Tip: test every script on the bench before installing it in a moving machine.

Questions

Why does pip say 'externally-managed-environment'?

Current Raspberry Pi OS protects the system Python. Create a virtual environment (shown above) and install libraries there, or use the python3-xxx packages from apt.