Terminal User Guide
For advanced users, it’s also worth mentioning these aren’t the only Terminal commands you can use to change or update your Mac’s OS, and you can find plenty more to play with on the JAMF. If you’re working in Terminal on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands. Folders are called directories in UNIX. Commands that refer to filenames, as most do, assume that you’re talking about files in the.
Use these shortcuts to save time when using Terminal.
Work with Terminal windows and tabs
Action | Shortcut |
---|---|
New window | Command-N |
New window with same command | Control-Command-N |
New tab | Command-T |
New tab with same command | Control-Command-T |
Show or hide tab bar | Shift-Command-T |
Show all tabs or exit tab overview | Shift-Command-Backslash () |
New command | Shift-Command-N |
New remote connection | Shift-Command-K |
Show or hide Inspector | Command-I |
Edit title | Shift-Command-I |
Edit background color | Option-Command-I |
Make fonts bigger | Command-Plus (+) |
Make fonts smaller | Command-Minus (–) |
Next window | Command-Grave Accent (`) |
Previous window | Command-Shift-Tilde (~) |
Next Tab | Control-Tab |
Previous Tab | Control-Shift-Tab |
Split window into two panes | Command-D |
Close split pane | Shift-Command-D |
Close tab | Command-W |
Close window | Shift-Command-W |
Close other tabs | Option-Command-W |
Close all | Option-Shift-Command-W |
Scroll to top | Command-Home |
Scroll to bottom | Command-End |
Page up | Command-Page Up |
Page down | Command-Page Down |
Line up | Option-Command-Page Up |
Line down | Option-Command-Page Down |
Edit a command line
Action | Shortcut |
---|---|
Reposition the insertion point | Press and hold the Option key while moving the pointer to a new insertion point. |
Move the insertion point to the beginning of the line | Control-A |
Move the insertion point to the end of the line | Control-E |
Move the insertion point forward one character | Right Arrow |
Move the insertion point backward one character | Left Arrow |
Move the insertion point forward one word | Option-Right Arrow |
Move the insertion point backward one word | Option-Left Arrow |
Delete to the beginning of the line | Control-U |
Delete to the end of the line | Control-K |
Delete forward to the end of the word | Option-D (available when Use Option as Meta key is selected) |
Delete backward to the beginning of the word | Control-W |
Delete one character | Delete |
Forward-delete one character | Forward Delete (or use Fn-Delete) |
Transpose two characters | Control-T |
Select and find text in a Terminal window
Action | Shortcut |
---|---|
Select a complete file path | Press and hold the Shift and Command keys and double-click the path |
Select a complete line of text | Triple-click the line |
Select a word | Double-click the word |
Select a URL | Press and hold the Shift and Command keys and double-click the URL |
Select a rectangular block | Press and hold the Option key and drag to select text |
Cut | Command-X |
Copy | Command-C |
Copy without background color | Control-Shift-Command-C |
Copy plain text | Option-Shift-Command-C |
Paste | Command-V |
Paste the selection | Shift-Command-V |
Paste escaped text | Control-Command-V |
Paste escaped selection | Control-Shift-Command-V |
Find | Command-F |
Find next | Command-G |
Find previous | Command-Shift-G |
Find using the selected text | Command-E |
Jump to the selected text | Command-J |
Select all | Command-A |
Open the character viewer | Control-Command-Space |
Work with marks and bookmarks
Apple Terminal Commands List
Action | Shortcut |
---|---|
Mark | Command-U |
Mark as bookmark | Option-Command-U |
Unmark | Shift-Command-U |
Mark line and send return | Command-Return |
Send return without marking | Shift-Command-Return |
Insert bookmark | Shift-Command-M |
Insert bookmark with name | Option-Shift-Command-M |
Jump to previous mark | Command-Up Arrow |
Jump to next mark | Command-Down Arrow |
Jump to previous bookmark | Option-Command-Up Arrow |
Jump to next bookmark | Option-Command-Down Arrow |
Clear to previous mark | Command-L |
Clear to previous bookmark | Option-Command-L |
Clear to start | Command-K |
Select between marks | Shift-Command-A |
Other shortcuts
Action | Shortcut |
---|---|
Enter or exit full screen | Control-Command-F |
Show or hide colors | Shift-Command-C |
Open Terminal preferences | Command-Comma (,) |
Break | Typing Command-Period (.) is equivalent to entering Control-C on the command line |
Command-P | |
Soft reset terminal emulator state | Option-Command-R |
Hard reset terminal emulator state | Control-Option-Command-R |
Open a URL | Hold down the Command key and double-click the URL |
Add the complete path to a file | Drag the file from the Finder into the Terminal window |
Export text as | Command-S |
Export selected text as | Shift-Command-S |
Reverse search command history | Control-R |
Toggle “Allow Mouse Reporting” option | Command-R |
Toggle “Use Option as Meta Key” option | Command-Option-O |
Show alternate screen | Option-Command-Page Down |
Hide alternate screen | Option-Command-Page Up |
Open man page for selection | Control-Shift-Command-Question Mark (?) |
Search man page index for selection | Control-Option-Command-Slash (/) |
Complete directory or file name | On a command line, type one or more characters, then press Tab |
Display a list of possible directory or file name completions | On a command line, type one or more characters, then press Tab twice |
Hidden behind beautiful Mac screens is the world of Terminal Command lines. Knowing how to use these commands will help you increase your work efficiency in a great way.
Below is a list of the most basic commands divided by purpose of use:
CORE COMMANDS
Key/Command | Description |
---|---|
cd [folder] | Change directory e.g. cd Documents |
cd | Home directory |
cd ~ | Home directory |
cd / | Root of drive |
cd – | Previous directory |
ls | Short listing |
ls -l | Long listing |
ls -a | Listing incl. hidden files |
ls -lh | Long listing with Human readable file sizes |
ls -R | Entire content of folder recursively |
sudo [command] | Run command with the security privileges of the superuser (Super User DO) |
open [file] | Opens a file ( as if you double clicked it ) |
top | Displays active processes. Press q to quit |
nano [file] | Opens the file using the nano editor |
vim [file] | Opens the file using the vim editor |
clear | Clears the screen |
reset | Resets the terminal display |
CHAINING COMMANDS
Key/Command | Description |
---|---|
[command-a]; [command-b] | Run command A and then B, regardless of success of A |
[command-a] && [command-b] | Run command B if A succeeded |
[command-a] || [command-b] | Run command B if A failed |
[command-a] & | Run command A in background |
PIPING COMMANDS
Key/Command | Description |
---|---|
[command-a] | [command-b] | Run command A and then pass the result to command B e.g ps auxwww | grep google |
COMMAND HISTORY
Key/Command | Description |
---|---|
history n | Shows the stuff typed – add a number to limit the last n items |
Ctrl + r | Interactively search through previously typed commands |
![value] | Execute the last command typed that starts with ‘value’ |
![value]:p | Print to the console the last command typed that starts with ‘value’ |
!! | Execute the last command typed |
!!:p | Print to the console the last command typed |
FILE MANAGEMENT
Key/Command | Description |
---|---|
touch [file] | Create a new file |
pwd | Full path to working directory |
. | Current folder, e.g. ls . |
.. | Parent/enclosing directory, e.g. ls .. |
ls -l .. | Long listing of parent directory |
cd ../../ | Move 2 levels up |
cat | Concatenate to screen |
rm [file] | Remove a file, e.g. rm data.tmp |
rm -i [file] | Remove with confirmation |
rm -r [dir] | Remove a directory and contents |
rm -f [file] | Force removal without confirmation |
cp [file] [newfile] | Copy file to file |
cp [file] [dir] | Copy file to directory |
mv [file] [new filename] | Move/Rename, e.g. mv file1.ad /tmp |
pbcopy < [file] | Copies file contents to clipboard |
pbpaste | Paste clipboard contents |
pbpaste > [file] | Paste clipboard contents into file, pbpaste > paste-test.txt |
DIRECTORY MANAGEMENT
Key/Command | Description |
---|---|
mkdir [dir] | Create new directory |
mkdir -p [dir]/[dir] | Create nested directories |
rmdir [dir] | Remove directory ( only operates on empty directories ) |
rm -R [dir] | Remove directory and contents |
less [file] | Output file content delivered in screensize chunks |
[command] > [file] | Push output to file, keep in mind it will get overwritten |
[command] >> [file] | Append output to existing file |
[command] < [file] | Tell command to read content from a file |
SEARCH
Zsh Terminal Commands For Mac Os Catalina
Key/Command | Description |
---|---|
find [dir] -name [search_pattern] | Search for files, e.g. find /Users -name 'file.txt' |
grep [search_pattern] [file] | Search for all lines that contain the pattern, e.g. grep 'Tom' file.txt |
grep -r [search_pattern] [dir] | Recursively search in all files in specified directory for all lines that contain the pattern |
grep -v [search_pattern] [file] | Search for all lines that do NOT contain the pattern |
grep -i [search_pattern] [file] | Search for all lines that contain the case-insensitive pattern |
mdfind [search_pattern] | Spotlight search for files (names, content, other metadata), e.g. mdfind skateboard |
mdfind -onlyin [dir] -name [pattern] | Spotlight search for files named like pattern in the given directory |
HELP
Commands For Mac Os Terminal Prompt
Key/Command | Description |
---|---|
[command] -h | Offers help |
[command] –help | Offers help |
info [command] | Offers help |
man [command] | Show the help manual for [command] |
whatis [command] | Gives a one-line description of [command] |
apropos [search-pattern] | Searches for command with keywords in description |