A simple, practical guide to terminal / command-line usage.
Made for daily practice, real work, and quick revision.
Shows where you are right now.
pwdReal case:
Youβre lost in folders β run pwd to confirm your exact location.
ls # list files
ls -l # detailed list (size, date, permissions)
ls -a # include hidden files
ls -lh # readable file sizesReal case:
Check whether screenshots, README, or output files exist before moving or deleting.
cd folder_name
cd ..
cd ~
cd /Users/username/DesktopReal case:
Navigate to your project folder before running Python scripts or zipping files.
mkdir screenshots
mkdir project logs backupsReal case:
Create folders to organize images, logs, or backup files before uploading to GitHub.
touch README.md
touch app.pyReal case:
Quickly create files for documentation or starting new code.
rm file.txtrm -r screenshotsReal case:
Delete unused files or wrong screenshots before final submission.
cp file.txt copy.txt
cp -r screenshots backup/Real case:
Create backups before editing important files.
mv old.txt new.txt
mv ui-main.png screenshots/Real case:
Rename output files or move screenshots into proper folders.
zip file.zip file.txt
zip -r project.zip project/
zip -r Matrix-Calculator-macOS.zip "Matrix Calculator.app"Explanation:
-rβ recursive (folders)- First name β zip file
- Second name β file/folder to zip
Real case:
Compress project or app files before sharing or uploading.
unzip project.zip
unzip project.zip -d output_folder/Real case:
Extract downloaded project or assignment files.
open .
open image.png
open "Matrix Calculator.app"Real case:
Instantly preview images, apps, or folders without Finder clicks.
find . -name "*.png"Real case:
Locate all screenshots or images inside a large project.
chmod +x script.shReal case:
Make shell or Python scripts executable before running them.
clearShortcut: Cmd + K
Real case:
Clean cluttered terminal output to focus on fresh commands.
whoami
dateReal case:
Confirm logged-in user or timestamp logs/debug output.
git status
git add .
git commit -m "message"Real case:
Check changes and save project progress.
| Symbol | Meaning |
|---|---|
| . | Current directory |
| .. | Parent directory |
| ~ | Home directory |
| / | Root directory |
| * | Wildcard |
Example:
rm *.pngDeletes all PNG files in the current folder.
cd python/GUI_app
ls
mkdir screenshots
mv ui*.png screenshots/
cd screenshots
zip -r ui-images.zip .
open .π Clean β organize β zip β preview β upload.
The terminal does exactly what you tell it.
If something fails, always check:
pwd
lsA quick reference guide for managing isolated Python environments and dependencies.
Confirm Python is installed on your system.
macOS / Linux:
python3 --versionWindows:
python --versionKeeps your project files organized.
mkdir python_project
cd python_projectCreates an isolated Python environment in a folder named venv.
macOS / Linux:
python3 -m venv venvWindows:
python -m venv venvSwitches your terminal to use the isolated Python & pip. Look for (venv) in your prompt.
macOS / Linux:
source venv/bin/activateWindows (CMD / PowerShell):
venv\Scripts\activateInstalls a package ONLY inside the virtual environment.
pip install numpyShows a list of all packages currently installed in the active environment.
pip listSaves exact package versions to a file. Critical for sharing projects.
pip freeze > requirements.txtExample content: numpy==1.26.4
Recreates the exact same environment on another system.
pip install -r requirements.txtStarts the Python shell.
Inside venv:
pythonmacOS System (Outside venv):
python3Confirms if you are using the venv Python or the System Python.
macOS / Linux:
which pythonWindows:
where pythonExits the virtual environment and returns to system Python.
deactivateCreates an empty file named main.py.
touch main.pyOpens the file in the simplistic terminal editor (Nano).
nano main.py| Action | Shortcut | Description |
|---|---|---|
| Save File | CTRL + O |
Press Enter to confirm filename. |
| Exit Editor | CTRL + X |
Exits Nano (prompts to save if modified). |
Shows all files and folders in the current directory.
lsPrints the entire content of main.py to the terminal screen.
cat main.pyExecutes the Python code inside the file.
python main.pyShows which Python executable is currently active.
macOS / Linux:
which pythonWindows:
where pythonAdds text to the end of the file. Does NOT delete existing content.
echo 'print("Hello World")' >> main.pyReplaces the entire file content with new text. Old content is lost.
echo 'import numpy' > main.pyWrites formatted text (safely adds a new line \n).
printf 'if __name__ == "__main__":\n print("Start")\n' >> main.py