TabAuto-complete file and folder namesCtrl + AGo to the beginning of the line you're currently typing onCtrl + EGo to the end of the line you're currently typing onCtrl + UClear the line before the cursorCtrl + KClear the line after the cursorCtrl + WDelete the word before the cursorCtrl + TSwap the last two characters before the cursorEsc + TSwap the last two words before the cursorCtrl + LClear the screenCtrl + CKill whatever you're runningCtrl + DExit the current shellOption + →Move cursor one word forwardOption + ←Move cursor one word backwardCtrl + FMove cursor one character forwardCtrl + BMove cursor one character backwardCtrl + YPaste whatever was cut by the last commandCtrl + ZPuts whatever you're running into a suspended background processCtrl + _Undo the last command
/(Forward Slash): Top level directory.(Single Period): Current directory..(Double Period): Parent directory~(Tilde): Home directorysudo [command]Run command with the security privileges of the super usernano [file]Opens the Terminal editoropen [file]Opens a file[command] -hGet help about a commandman [command]Show the help manual of the command
cdHome directorycd [folder]Change directory, e.g. cd Documentscd ~Home directorycd/Root of the drivecd -Previous directory or folder you last browsedpwdShow your working directorycd..Move up to the parent directorycd../..Move up two levels
lsDisplay the name of files and subdirectories in the directoryls -CForce multi-column output of the listingls -aList all entries including those with .(period) and ..(double * period)ls -1Output the list of files in one entry per line formatls -FDisplay a / (slash) immediately after each path that is a directory,* * (asterisk) after executable programs or scripts, and @ after a * symbolic linkls -SSort files or entries by sizels -lList in a long format. Includes file mode, owner and group name, * date and time file was modified, pathname, and morels -ltList the files sorted by time modified (most recent first)ls -lhLong listing with human readable file sizes in KB, MB, or GBls -loList the file names with size, owner, and flagsls -laList detailed directory contents, including hidden files
duList usage for each subdirectory and its contentsdu -sh [folder]Human readable output of all files in a directorydu -sDisplay an entry for each specified filedu -sk* | sort -nrList files and folders, totaling the size including * the subfolders. Replace sk* with sm* to list directories in MBdf -hCalculate your system's free disk spacedf -HCalculate free disk space in powers of 1,000 (as opposed to 1,024)
mkdirCreate new folder namedmkdir-p /: Create nested foldersmkdir<dir1> <dir2> <dir3>: Create several folders at * oncemkdir"": Create a folder with a space in the filenamermdirDelete a folder (only works on empty folders)rm -RDelete a folder and its contentstouch<file>: Create a new file without any extensioncp<file> Copy a file to the foldercp<file> <newfile>:Copy a file to the current foldercp<file>~//<newfile>:Copy a file to the folder and rename * the copied filecp -R<"new dir">:Copy a folder to a new folder with spaces in the * filenamecp -i<file>Prompts you before copying a file with a warning * overwrite messagecp<file1> <file2> <file3>/Users/Copy multiple files to * a folderrm<file>:Delete a file (This deletes the file permanently; use * with caution.)rm -i<file>:Delete a file only when you give confirmationrm -f<file>:Force removal without confirmationrm<file1> <file2> <file3>:Delete multiple files * without any confirmationmv<file> <newfilename>:Move/renamemv<file> Move a file to the folder, possibly by overwriting an * existing filemv -i<file> Optional -i flag to warn you before overwriting the * filemv *.png~/Move all PNG files from current folder to a different folder
Ctrl + R:Search through previously used commandshistory n:Shows the previous commands you've typed. Add a number to * limit to the last n items![value]:Execute the last command typed that starts with a value!!:Execute the last command typed
ls -ld:Display the default permission for a home directoryls -ld/Display the read, write, and access permission of a particular folderchmod 755<file>:Change the permission of a file to 755chmod -R 600Change the permission of a folder (and its contents) to 600chown<user>:<group> <file>:Change the ownership of a file to user and group. Add -R to include folder contents
ps -ax:Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the Terminalps -aux:Shows all the processes with %cpu, %mem, page in, PID, and commandtop:Display live information about currently running processestop -ocpu -s 5:Display processes sorted by CPU usage, updating every 5 secondstop -o rsize:Sort top by memory usage
ping<host>:Ping host and display statuswhois<domain>:Output whois info for a domaincurl -O<url/to/file>:Download file via HTTP, HTTPS, or FTPssh<username>@<host>:Establish SSH connection to <host> with user <username>scp<file><user>@<host>:/remote/path:Copy <file> to a remote <host>
brew doctor:Check brew for potential problemsbrew install<formula>:Install a formulabrew uninstall<formula>:Uninstall a formulabrew list:List all the installed formulasbrew search:Display available formulas for brewingbrew upgrade:Upgrade all outdated and unpinned brewsbrew update:Fetch latest version of homebrew and formulabrew cleanup:Remove older version of installed formulabrew tap homebrew/cask:Tap the cask repository from GitHubbrew cask list:List all installed casksbrew cask install<cask>:Install the given caskbrew cask uninstall<cask>:Uninstall the given cask
find -name<"file">:Find all files named <file> inside . Use wildcards (*) to search for parts of filenamesgrep"<text>" <file>:Output all occurrences of <text> inside <file> (add -i for case insensitivity)grep -rl"<text>" Search for all files containing <text> inside
cat<file>:Output the content of <file>less<file>:Output the contents of <file> using the less command that supports pagination and morehead<file>:Output the first 10 lines of <file>- <
cmd> > > <file>:Appends the output of <cmd> to <file> - <
cmd> > <file>:Direct the output of <cmd> into <file> - <
cmd1>|<cmd2>:Direct the output of <cmd1> to <cmd2>