The terminal
ls |
Listing all contents of a directory. |
ls -a |
Showing also the hidden files. |
ls -l |
Showing everything as a list. |
ls -la |
A combination of ls -a and ls -l . |
pwd |
Displaying the directory in which you are now. |
cd <dir_name> |
Navigating to the directory (cd / will show all the options). |
clear |
Clearing the terminal. |
nano <file_name> |
Opening the file in nano editor (also creating the file if it doesn’t exist). |
touch <file_name> |
Creating a new file. |
mkdir <dir_name> |
Creating a new directory. |
mv <file_path> <new_file_path> |
Moving a file and/or renaming it. |
cp <file_path> <new_file_path> |
Copying a file to a new file. |
rm <file_name> |
Removing a file. |
rm -rf <dir_name> |
Removing a directory and everything inside, recursively. |
cat <file_name> |
Displaying the content of a file. |
sudo apt update |
Updating sources to the latest. |
sudo apt install <package_name> |
Installing a package. |
sudo apt remove <package_name> |
Removing a package. |
sudo apt upgrade |
Upgrading already installed packages to the latest version. |
pip3 install <module_name> |
Installing a Python module. |
pip3 uninstall <module_name> |
Uninstalling a Python module. |
pip3 list |
Displaying all installed Python modules. |
pip3 list | grep GPIO |
Searching (like CTRL + F ) for the "GPIO" phrase in the list of Python modules. |
python3 |
Opening the Python Shell (use exit() to exit it). |
sudo shutdown now |
Shutting down the Raspberry Pi. |
sudo reboot |
Rebooting the Raspberry Pi. |
hostname -I |
Displaying the IP address of the Raspberry Pi. |
df -h |
Displaying the currently used and available space on the SD card. |
python3 <file_name.py> |
Executing a Python3 script in the terminal. |
man <command_name> |
Displaying a manual for a given command. |
which python3 |
Showing a complete path to a given command (python3 ). |
sudo
means using a command as an admin. To open an installed program, we type its name. To copy and paste, we use CTRL + SHIFT + C
and CTRL + SHIFT + V
. CTRL + X
exits a Nano file, and CTRL + S
saves it. You can use TAB for auto-completion in the Terminal. To go back to previously executed commands, use the up arrow key on your keyboard. You do not need to add a .txt extension to create a text file, you can leave it blank (Raspberry Pi OS is a Unix operating system). Press CTRL + C
to stop a running command. If you want to create a Python file using the touch command, write its extension at the end. Files and folders with a dot at the beginning are hidden.