Skip to main content

Terminal Cheatsheet

Basic Commands

CommandAction
pwdprint working directory
lslist content of current directory
ls -alist content of current directory, including hidden files
ls -llist content of current directory with extra details
manmanual
cd child-directorychange directory
cd ..parent directory
cd ~home directory
mkdir [name]create a directory
touch [name.ext]create a file - will not overwrite a file if it exists
open [name.ext]opens file
clearempties terminal screen
cat [name.ext]displays content of file in bash (terminal)
mv [-options] [path/to/file] [path/to/directory]move file to specified location
mv [-options] [path/to/file] [new name]renames file or directory
cp [path/to/file] [path/to/directory]copies files to specified directory or file name
cp -r [path/to/file] [path/to/directory]copies files and folders to specified directory or file name
rm [path/to/file]removes file PERMANENTLY!
rm -r [path/to/directory]removes directory PERMANENTLY!
rmdirremoves empty directory PERMANENTLY!
[name of program] [arguments]start a program (example: atom [path/to/file]), node [path/to/file] ...)
Ctrl + Cabort a program that is currently active in the terminal
Ctrl + Ajump to beginning of line
Ctrl + Ejump to end of line
Ctrl + Kclear the screen
tabautocomplete
arrow upfill line with previously entered command
arrow left/rightjump to next/previous word
qend view of text in terminal (with some programs/views)
historysee a list of previously typed commands

Git Commands

CommandAction
git statusget current status for repo
git initinitialize a current folder as a repo, i.e. start tracking changes
git clone [link]makes copied remote repo a new local repo
git add [path/to/file]stage file
git commit -m ["message"]commit changes and include a message describing commit
git logdisplay timeline
git diff [path/to/file]show tracked but unstaged changes
git push origin mastersend changes to remote repository (push to gitHub)
git pull upstream masterget latest changes from a remote repository

NPM Commands

CommandAction
npm initinitialize a directory with package.json file for saving dependencies
npm install [package-name]install a package
npm i [package-name]install a package
npm install [package-name] --saveinstall a package and keep a record of it in package.json . --save is not needed/the default in versions 5.0.0 of NPM and up
npm install [package-name] -ginstall a package as a global terminal command. You may need your administer password/ us sudo to compete a global install
npm installread package.json and install all listed dependencies

For reference: List of bash commands via University of Washington's System and Software Tools course