Before writing any Python code, you need to be comfortable getting around a terminal. You will use it to activate environments, run scripts and manage files throughout the bootcamp. Here are the commands you will use all the time.
TipThe most important command on this page
man <command> (or <command> --help): every command below has a manual. When in doubt, ask the tool itself before searching the internet.
Getting help
Command
What it does
man ls
Opens the manual page for ls (press q to quit)
ls --help
Quick usage summary, no manual needed
which python
Shows which executable actually runs when you type python
Finding your way around
Command
What it does
pwd
Shows the current directory: “where am I?”
ls
Lists the files in the current directory
ls -la
Lists all files (including hidden ones, starting with .) with details
cd <path>
Changes directory
cd ..
Goes up one directory level
cd ~
Goes to your home directory
Working with files and directories
Command
What it does
cat <file>
Prints the contents of a file to the screen
less <file>
Scrolls through the contents of a file (press q to quit)
mkdir <name>
Creates a new directory
touch <file>
Creates an empty file
cp <source> <destination>
Copies a file
mv <source> <destination>
Moves or renames a file
rm <file>
Deletes a file. No undo, no trash bin: be careful
rm -r <dir>
Deletes a directory and everything in it. Same warning, doubled
Searching
Command
What it does
grep "text" <file>
Searches for a piece of text inside a file
find . -name "*.py"
Searches for files by name pattern, starting from the current directory
Essential shortcuts from day one
Shortcut / Command
What it does
Tab
Autocompletes file and folder names. Use it all the time: it prevents typos
↑ / ↓
Scrolls through previous commands
Ctrl + C
Stops whatever is currently running
Ctrl + R
Searches your command history
clear
Clears the terminal screen
history
Lists recently run commands
Combining commands
Syntax
What it does
command1 \| command2
Pipe: sends the output of command1 as the input of command2
command > file.txt
Redirects the output to a file (overwrites)
command >> file.txt
Redirects the output to a file (appends to the end)
NotePractice
Open a terminal, cd into this repository and try: ls -la, cat README.md, man ls and history.
---title: "CLI Utilities"---Before writing any Python code, you need to be comfortable getting around a terminal. You will use it to activate environments, run scripts and manage files throughout the bootcamp. Here are the commands you will use all the time.::: {.callout-tip appearance="simple"}## The most important command on this page`man <command>` (or `<command> --help`): every command below has a manual. When in doubt, ask the tool itself before searching the internet.:::## Getting help| Command | What it does ||---|---||`man ls`| Opens the manual page for `ls` (press `q` to quit) ||`ls --help`| Quick usage summary, no manual needed ||`which python`| Shows which executable actually runs when you type `python`|## Finding your way around| Command | What it does ||---|---||`pwd`| Shows the current directory: "where am I?" ||`ls`| Lists the files in the current directory ||`ls -la`| Lists all files (including hidden ones, starting with `.`) with details ||`cd <path>`| Changes directory ||`cd ..`| Goes up one directory level ||`cd ~`| Goes to your home directory |## Working with files and directories| Command | What it does ||---|---||`cat <file>`| Prints the contents of a file to the screen ||`less <file>`| Scrolls through the contents of a file (press `q` to quit) ||`mkdir <name>`| Creates a new directory ||`touch <file>`| Creates an empty file ||`cp <source> <destination>`| Copies a file ||`mv <source> <destination>`| Moves or renames a file ||`rm <file>`| Deletes a file. No undo, no trash bin: be careful ||`rm -r <dir>`| Deletes a directory and everything in it. Same warning, doubled |## Searching| Command | What it does ||---|---||`grep "text" <file>`| Searches for a piece of text inside a file ||`find . -name "*.py"`| Searches for files by name pattern, starting from the current directory |## Essential shortcuts from day one| Shortcut / Command | What it does ||---|---||`Tab`| Autocompletes file and folder names. Use it all the time: it prevents typos ||`↑` / `↓`| Scrolls through previous commands ||`Ctrl + C`| Stops whatever is currently running ||`Ctrl + R`| Searches your command history ||`clear`| Clears the terminal screen ||`history`| Lists recently run commands |## Combining commands| Syntax | What it does ||---|---||`command1 \| command2`| Pipe: sends the output of `command1` as the input of `command2`||`command > file.txt`| Redirects the output to a file (overwrites) ||`command >> file.txt`| Redirects the output to a file (appends to the end) |::: {.callout-note appearance="simple"}## PracticeOpen a terminal, `cd` into this repository and try: `ls -la`, `cat README.md`, `man ls` and `history`.:::