The command line
Command line interface
- Windows
- macOS/Linux
- Terminal
We'll be using:
- Windows: Git BASH
- macOS: Terminal
Open it up.
- UNIX
- UNIX-like
- POSIX standard
- Darwin (macOS)
- Debian
- Ubuntu
- Mint
- Fedora
- Red Hat Enterprise Linux (RHEL)
- Separators:
- Windows (outside of Git BASH):
\
- macOS/Linux:
/
- Windows (outside of Git BASH):
.
- current directory..
- parent directory- Absolute vs. relative
pwd
- path of working directoryls
- list filesls -al
- list all files (with dotfiles) with more details
cd
- change directory- Mac:
- From Finder, right-click on folder
- Click
Services
- Click
New Terminal at Folder
Control-r
allows you to search your command history
- Viewing
cat
less
mv
cp
mkdir
rmdir
find
- Editing
nano
vim
If files have spaces or special characters, need to put quotes around them.
- Best to avoid these when naming files, sticking to:
- Letters
- Numbers
- Periods
- Hyphens
- Underscores
- For Python files, snake case is most common.
- less:
q
- nano: control-
x
- vim: escape, then
:q!
- Other command line tools: control-
c
Worst case, close your Terminal, and that will kill whatever process was running.
echo
echo abc | less
- Exit codes
echo $?
- Environment variables
which
which jupyter
which -a python3
$PATH
- Pipes
ls | xargs cat
- Redirecting output
grep
sudo
man
Uses a "wildcard":
find . -name 'lecture_*.md'
find . -name 'lecture_*.md' | sed -E 's/([0-9]{2})/0\1/'
- PowerShell
- Bash
- zsh
Done through package managers
- Linux: Aptitude, Snapcraft, others
- Mac: Homebrew
- Windows: Windows Package Manager / WinGet, Chocolatey
Note to self: Send terminal commands+output.