Terminal

Terminal Shortcuts:

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

Change Directory:

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

File & Directory Management:

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

grep

Options alter behavior of command line instructions and can be set with:

Shorthand Commands

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

The Shell

Shell Scripting

Shell Permissions

Start-Up Files


Git

Git Commands

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