In this article I will consolidate several useful shortcuts for Mac
Intro
#In this article I will consolidate several useful shortcuts for Mac
Mac Shortcuts
#Startup
#Action | Shortcut |
---|
Boot without automatic login | Left shift (Press and hold when macOS progress indicator appears) |
Boot in Safe Mode (Intel) | Shift (Press and hold) |
Boot in Safe Mode (Apple Silicon) | Power (Press and hold), then select a volume, then hold Shift while clicking Continue in Safe Mode |
Boot in Single User Mode (Intel, unavailable in macOS Mojave and later) | Cmd + S |
Boot in Verbose Mode (Intel) | Cmd + V |
Boot in Target Disk Mode (Intel) | T |
Boot from a NetBoot network server | N |
Boot to Startup Manager (Intel) | Option |
Boot to Startup Manager (Apple Silicon) | Power |
Load macOS Recovery (Intel) | Cmd + R |
Load macOS Recovery over the internet (Intel) | Option + Cmd + R |
Load macOS Recovery (Apple Silicon) | Power, then select Options, then click Continue |
Enter Apple Diagnostics (Intel) | D |
Enter Apple Diagnostics (Apple Silicon) | Cmd + D |
Load Apple Diagnostics over the internet | Option + D |
Reset NVRAM or PRAM (Intel, unnecessary on Apple Silicon Macs) | Option + Cmd + P + R |
Eject removable media | F12 |
Finder
#Action | Shortcut |
---|
Rename selected file or folder | Enter |
Duplicate selected file or folder | Cmd + D |
Create a new folder | Shift + Cmd + N |
Create a new Smart Folder | Option + Cmd + N |
Create a new folder from selected file(s) | Control + Cmd + N |
Make an alias for the item | Control + Cmd + A |
Move selected item(s) to the Trash | Cmd + Delete |
Delete selected item(s) immediately | Option + Cmd + Delete |
Empty the Trash | Cmd + Shift + Delete |
Empty the Trash immediately | Option + Cmd + Shift + Delete |
Preview selected file(s) with Quick Look in a window | Space |
Preview selected file(s) with Quick Look in fullscreen mode | Option + Space |
Start a slideshow using selected item(s) | Control + Space |
Go to folder | Cmd + Shift + G |
Connect to server | Cmd + K |
Move up one folder | Cmd + Up arrow |
Move down one folder | Cmd + Down arrow |
Eject selected volume | Cmd + E |
Get info | Cmd + I |
Show Attributes Inspector | Option + Cmd + I |
Open a new Finder window | Cmd + N |
Close active Finder window | Shift + Cmd + N |
Cycle through windows | Cmd + < |
Open a new Finder tab | Cmd + T |
Close active Finder tab | Cmd + W |
View options | Cmd + J |
Icon view | Cmd + 1 |
List view | Cmd + 2 |
Column view | Cmd + 3 |
Gallery view | Cmd + 4 |
Hide all Finder windows | Cmd + H |
Hide all other windows except Finder | Option + Cmd + H |
Search | Cmd + F |
Open a Computer window | Cmd + Shift + C |
Open the Recents folder | Cmd + Shift + F |
Open the Documents folder | Cmd + Shift + O |
Open the Desktop folder | Cmd + Shift + D |
Open the Downloads folder | Option + Cmd + L |
Open your account’s home folder | Cmd + Shift + H |
Open an AirDrop window | Cmd + Shift + R |
Open the network browser | Cmd + Shift + K |
Open your iCloud Drive | Cmd + Shift + I |
Open your public shared folder | Cmd + Shift + S |
Open the Applications folder | Cmd + Shift + A |
Open the Utilities folder | Cmd + Shift + U |
Show/hide the Finder sidebar | Cmd + Control + S |
Show/hide the Path Bar | Option + Cmd + P |
Show/hide the Status Bar | Option + Cmd + / (Slash) |
Document
#Action | Shortcut |
---|
Bold text | Cmd + B |
Italicize text | Cmd + I |
Underline text | Cmd + U |
Scroll one page up | Fn + Up arrow |
Scroll one page down | Fn + Down arrow |
Jump to the beginning of the document | Fn + Left arrow |
Jump to the end of the document | Fn + Right arrow |
General
#Action | Shortcut |
---|
Display the macOS screenshotting tools | Cmd + 5 |
Take a screenshot of the entire screen | Shift + Cmd + 3 |
Take a screenshot of a portion of the screen | Shift + Cmd + 4 (then hold Space to drag the selection, if needed) |
Take a screenshot of a specific window or menu | Cmd + Shift + 4, then Space |
Select all | Cmd + A |
Select multiple non-contiguous item(s) | Cmd + Left click |
Select multiple adjacent item(s) | Shift + Left click |
Hide current window | Cmd + H |
Hide all other windows | Option + Cmd + H |
Minimize the current window | Cmd + M |
Minimize all windows | Option + Cmd + M |
Close current window | Cmd + W |
Close all windows | Option + Cmd + W |
Open | Cmd + O |
Save | Cmd + S |
Print | Cmd + P |
Find | Cmd + F |
Find and replace | Option + Cmd + F |
Copy | Cmd + C |
Paste | Cmd + V |
Paste and delete original items | Option + Cmd + V |
Paste and match style | Shift + Option + Cmd + V |
Undo | Cmd + Z |
Redo | Shift + Cmd + Z |
Zoom in | Cmd + + (Plus) |
Zoom out | Cmd + - (Minus) |
Access in-app help | Cmd + ? |
Open preferences for the current app | Cmd + , (Comma) |
Open Spotlight search | Cmd + Space |
Hide/show the Dock | Option + Cmd + D |
Show the Character Viewer | Control + Cmd + Space |
Show the emoji picker | Fn |
Show desktop icons as stacks | Cmd + Control + 0 |
Switch the current app to fullscreen mode | Control + Cmd + F |
Switch to the next open app | Cmd + Tab |
Switch to the previous open app | Shift + Cmd + Tab |
Quit the selected app in the app switcher | Cmd + Shift, then Q |
Force quit apps | Option + Cmd + Esc |
Switch to the next window in the current app | Cmd + ~ (Tilde) |
Lock the screen | Cmd + Control + Q |
Log out | Shift + Cmd + Q |
Log out without confirmation | Option + Shift + Cmd + Q |
Put display(s) to sleep | Shift + Control + Eject |
Put your computer to sleep | Option + Cmd + Eject |
Quit all apps and restart | Control + Cmd + Eject |
Quit all apps and shut down | Control + Option + Cmd + Power |
Choose from Sleep, Restart, and Shutdown options | Control + Eject |
The Mac Terminal Cheat Sheet
#Keyboard Shortcuts
#COMMAND | ACTION |
---|
Tab | Auto-complete file and folder names |
Cmd+ F | Find instances of specific text in the Terminal |
Ctrl + A | Go to the beginning of the line you’re currently typing on |
Cmd + A | Select everything in the Terminal |
Cmd + P | Print Terminal inputs and outputs |
Ctrl + E | Go to the end of the line you’re currently typing on |
Ctrl + U | Clear the line before the cursor |
Ctrl + K | Clear the line after the cursor |
Ctrl + W | Delete the word before the cursor |
Ctrl + T | Swap the last two characters before the cursor |
Esc + T | Swap the last two words before the cursor |
Ctrl + L | Clear the screen |
Ctrl + C | Kill whatever you’re running |
Ctrl + D | Exit the current shell |
Option + → | Move the cursor one word forward |
Option + ← | Move the cursor one word backward |
Ctrl + F | Move the cursor one character forward |
Ctrl + B | Move the cursor one character backward |
Ctrl + Y | Paste whatever was cut by the last command |
Ctrl + Z | Puts whatever you’re running into a suspended background process |
Ctrl + _ | Undo the last command |
Option + Shift + Cmd + C | Copy plain text |
Shift + Cmd + V | Paste the selection |
exit | End a shell session |
Basics
#COMMAND | ACTION |
---|
/ (Forward Slash) | Top-level directory |
. (Single Period) | Current directory |
.. (Double Period) | Parent directory |
~ (Tilde) | Home directory |
sudo [command] | Run command with the security privileges of the super user |
nano [file] | Opens the Terminal editor |
open [file] | Opens a file |
[command] -h | Get help about a command |
man [command] | Show the help manual of the command |
Change Directory
#COMMAND | ACTION |
---|
cd | Home directory |
cd [folder] | Change directory, e.g. cd Documents |
cd ~ | Home directory |
cd / | Root of the drive |
cd - | Previous directory or folder you last browsed |
pwd | Show your working directory |
cd.. | Move up to the parent directory |
cd../.. | Move up two levels |
List Directory Contents
#COMMAND | ACTION |
---|
ls | Display the name of files and subdirectories in the directory |
ls -C | Force multi-column output of the listing |
ls -a | List all entries including those with .(period) and ..(double period) |
ls -1 | Output the list of files in one entry per line format |
ls -F | Display a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic link |
ls -S | Sort files or entries by size |
ls -l | List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more |
ls -l / | List of the file system from root with symbolic links |
ls -lt | List the files sorted by time modified (most recent first) |
ls -lh | Long listing with human readable file sizes in KB, MB, or GB |
ls -lo | List the file names with size, owner, and flags |
ls -la | List detailed directory contents, including hidden files |
File Size and Disk Space
#COMMAND | ACTION |
---|
du | List usage for each subdirectory and its contents |
du -sh [folder] | Human readable output of all files in a directory |
du -s | Display an entry for each specified file |
df -h | Calculate your system’s free disk space |
df -H | Calculate free disk space in powers of 1,000 (as opposed to 1,024) |
File and Directory Management
#COMMAND | ACTION |
---|
mkdir dir | Create a new folder named dir |
mkdir -p dir/dir | Create nested folders |
mkdir dir1 dir2 dir3 | Create several folders at once |
mkdir “dir” | Create a folder with a space in the filename |
rmdir dir | Delete a folder (only works on empty folders) |
rm -R dir | Delete a folder and its contents |
touch file | Create a new file without any extension |
cp file dir | Copy a file to the folder |
cp file newfile | Copy a file to the current folder |
cp file~/dir/newfile | Copy a file to the folder and rename the copied file |
cp -R dir <“new dir”> | Copy a folder to a new folder with spaces in the filename |
cp -i file dir | Prompts you before copying a file with a warning overwrite message |
cp file1 file2 file3/Users/dir | Copy multiple files to a folder |
ditto -V [folder path][new folder] | Copy the contents of a folder to a new folder. Here “-V” prints a line of status for every file copied |
rm file | Delete a file (This deletes the file permanently; use it with caution.) |
rm -i file | Delete a file only when you give confirmation |
rm -f file | Force removal without confirmation |
rm file1 file2 file3 | Delete multiple files without any confirmation |
mv file newfilename | Move/rename |
mv file dir | Move a file to the folder, possibly by overwriting an existing file |
mv -i file dir | Optional -i flag to warn you before overwriting the file |
mv *.png ~/dir | Move all PNG files from the current folder to a different folder |
Command History
#COMMAND | ACTION |
---|
Ctrl + R | Search through previously used commands |
history 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 |
Permissions
#COMMAND | ACTION |
---|
ls -ld | Display the default permission for a home directory |
ls -ld/dir | Display the read, write, and access permission of a particular folder |
chmod 755 file | Change the permission of a file to 755 |
chmod -R 600 dir | Change the permission of a folder (and its contents) to 600 |
chown user:group file | Change the ownership of a file to user and group. Add -R to include folder contents |
Processes
#COMMAND | ACTION |
---|
ps -ax | Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with Terminal |
ps -aux | Shows all the processes with %cpu, %mem, page in, PID, and command |
top | Display live information about currently running processes |
top -ocpu -s 5 | Display processes sorted by CPU usage, updating every 5 seconds |
top -o rsize | Sort top by memory usage |
kill PID | Quit process with ID PID. You’ll see PID as a column in the Activity Monitor |
Network
#COMMAND | ACTION |
---|
ping host | Ping the host and display the status |
whois domain | Output whois info for a domain |
curl -O url/to/file | Download a file via HTTP, HTTPS, or FTP |
ssh username@host | Establish SSH connection to host with user username |
scp fileuser@host:/remote/path | Copy file to a remote host |
arp -a | View a list of all devices on your local network. It will show you the IP and MAC address of all the devices |
ifconfig en0 | View your device IP and MAC address |
traceroute [hostname] | Identify the path and the hops traversed by the packets from your device to the destination address |
Homebrew
#COMMAND | ACTION |
---|
brew doctor | Check brew for potential problems |
brew help | List of useful homebrew formula and cask commands |
brew install formula | Install a formula or cask |
brew uninstall formula | Uninstall a formula or cask |
brew list –formula | List only installed formulas |
brew list –cask | List only installed cask |
brew deps formula | List all the dependencies of a formula or cask |
brew search text | Search formula or cask through regex |
brew upgrade formula | Upgrade the formula or cask |
brew outdated formula | Search for outdated formula or cask |
brew outdated –formula | Search for outdated formula |
brew outdated –cask | Search for outdated cask |
brew pin [installed_formula] | Pin a formula from getting upgraded |
brew unpin [installed_formula] | Unpin to upgrade a package |
brew cleanup | Remove stale lock files and outdated packages for all formulas and casks |
Environment
#COMMAND | ACTION |
---|
printenv | Display a list of currently set environment variables. Also tells you which shell you’re using |
$echo | Ask Terminal to print something and show it to you |
echo $PATH | Check the value of the PATH variable, which stores a list of directories with executable files |
echo $PATH >path.txt | Export the path directory to a text file |
export PATH=$PATH:absolute/path to/program/ | Execute a program via Terminal only in your current session. If you use a program regularly, add the path to the shell configuration file. |
Search
#COMMAND | ACTION |
---|
find dir -name “file” | Find all files named file inside dir. Use wildcards (*) to search for parts of filenames |
find dir -size +size | Find all files larger than size in dir |
find dir -size -size | Find all files less than size in dir |
grep “text” file | Output all occurrences of text inside file (add -i for case insensitivity) |
grep -rl “text” dir | Search for all files containing text inside dir |
Output
#COMMAND | ACTION |
---|
cat file | Output the content of file |
less file | Output the contents of file using the less command that supports pagination and more |
head file | Output the first 10 lines of file |
cmd < file | Use file contents as input to cmd |
cmd > > file | Appends the output of cmd to file |
cmd > file | Direct the output of cmd into file |
Terminal Windows
#COMMAND | ACTION |
---|
Cmd + N | Open a new Terminal window |
Cmd + T | Open a new Terminal tab |
Cmd + D | Split the Terminal window into two panes |
Cmd + tab number | Switch from one Terminal tab to another |
Cmd + Page Up | Scroll one page up the Terminal window |
Cmd + Page Down | Scroll one page down the Terminal window |
Cmd + W | Close a Terminal tab |
Option + Shift + Cmd + W | Close all Terminal tabs |
Mac Commands
#The following page provides information on available Mac commands:
Reference
#