cwd| Command | Action |
|---|---|
| Return/Enter | submit command |
| Tab | Autofill file/directory name |
| Ctrl + A | move cursor to beginning of line |
| Ctrl + E | move cursor to end of line |
| Ctrl +U | clear line before cursor |
| Ctrl + K | clear line after cursor |
| Ctrl + L | clear terminal screen (Joe’s pro-tip) |
| Ctrl + C | kill what’s running |
| Ctrl + R | search previous commands |
| Ctrl + _ | undo last command |
| Command | Action |
|---|---|
/ |
top level directory |
. |
current directory |
.. |
parent directory |
~ |
home directory |
cd |
home directory |
cd – |
previous directory |
pwd |
print working directory |
cd../.. |
move up two levels |
| Command | Action |
|---|---|
mkdir |
create new folder |
rmdir |
delete empty folder |
-r |
delete folder and its contents |
rm |
delete a file |
touch |
create new file |
cp |
copy file |
mv |
move/rename file or folder |
ls |
list files and subdirectories |
curl |
download URL Contents to local file |
curl -o |
download URL Contents to local file and name file |
grepgrep (g/re/p: Globally search for a Regular Expression and Print)
grep "hello" file.txtOptions alter behavior of command line instructions and can be set with:
| Command | Action |
|---|---|
-a |
all files |
-l |
list format |
-la |
list all files |
-p |
parent directory |
-r |
recursive |
-n |
line number |
-c |
count |
-s |
sort entries by size |
-i |
warn before execution |
-f |
force without warning |
-lt |
sort entries by time modified |
-lh |
display files sizes (KB, MB, GB) |
-lo |
display size, owner, & flags |
.sh extension#!/bin/zshFile permissions are represented by ten characters on command line:

The first character is the directory indicator
d: directoryi: fileThe directory indicator is followed by three permission groups:
u: user/ownerg: groupo: othersEach group has three permissions (in order):
r: (read) view a file or directory’s contentw: (write) modify a file or directory’s contentx: (execute) navigate into directory and run fileNumeric permission notation: (seen in documentation and error messages)
r = 4w = 2x = 1-rw-r--r-- = 644Modifying permissions
chmod (change mode) command updates a files’ permissions
+ or – following group type (u, g, o)and preceding permission type ( r, w, x)+ : grant permission- : revoke permissionif permission group is not specified—all groups will be modified
chmod g + r file.txt Bash: Default shell for Linux systems; uses login and non-login shells
.bash_profile is executed when bash is started manually with -l or –login
.bash_profile, bash will run .profile.bashrc automatically Zsh: Default shell for MacOS; only uses non(auto)-login when zsh is started
| Commands | Actions |
|---|---|
git config |
Configure author name and email to be associated with commits |
git init |
Converts a local directory into a Git repository |
git status |
Lists modified files and changes that need to be added or committed |
git add |
Add everything within the directory to the repo |
<file><file> |
Add specific files to the repo |
*.txt |
Add all text files to the repo |
git commit |
Snapshot of all the files in the repository (with changes) |
-m “<message>” |
Label commit with message detailing changes |
--amend |
Alter the latest commit |
| Move upwards one commit (per ^) | |
git diff |
View changes in the working directory |
--staged |
View changes in Staging Area |
<branch> |
View changes in specific commit |
<branch>^! |
View changes between specific commit and commit before it |
<branch><branch> |
View changes between two specific commits |
git log |
View commit ID |
git branch |
View all branches in repository |
-f <branch> |
Directly reassign a branch to a commit |
-d <branch> |
Delete branch |
git checkout <branch> |
Switch from branch to another |
-b <branch> |
Create a new branch and switch to it |
git merge <branch> |
Merge a branch into your active branch |
git clone /path/to/repository |
Creates working copy of local repository |
git grep “variable” |
Search working directory for “variable” |
git reset |
Reverse changes of commit to previous commit |
git revert |
Reverse changes of commit and share those changes with others |
git clone |
Create local copies of remote repositories |
git fetch |
Downloads commits in remote repository that are missing from local |