Mac Terminal Commands Cheat Sheet (Updated – 2023)

🗓️ October 16, 2023 By ✍️ Jaysukh patel

Mac computer includes a user-friendly interface, so you don’t need more time to excel your way through it. Unlike other devices, Mac computer has a command line prompt line interface called Terminal application. It is handy as it lets you quickly go inside macOS settings. Besides this, there are other reasons as well. In addition, you can use Terminal app for searching and managing files, folders, and more. Altogether, it offers more power and control to your Mac.

There are multiple commands that help get commands to your Mac, however, remembering all of them is an arduous task. Therefore, In this article, we covered all the essential Mac terminal commands to help you enhance your productivity.

A Guide to Use Terminal Commands on Mac

Before proceeding ahead, first learn how to access the terminal on your Mac computer.

Steps to open Terminal on your Mac

Follow the steps to Open Terminal on Mac in Easy ways.

    1. Open Spotlight search (Command + Space) on your Mac > Type Terminal and Open Other use an alternate way to open the terminal on Mac.
        • On your Mac computer, head to the Finder.
        • Select Go from the Finder menu bar.
        • Click on the Go To Folder…
        • Search for Utilities and click on it to open.
        • Next, select Terminal from there.
      • That’s it.
Tab Auto-complete folders and files
Ctrl + A Move to the beginning of the line you’re currently typing
Ctrl + E Navigate to the end of the line you’re currently typing.
Ctrl + U Vanish the line before the cursor
Ctrl + K Vanish the line after the cursor
Ctrl + W Clear the word before the cursor
Ctrl + T Switch the last two characters the cursor
Esc + T Switch the last two words before the cursor
Ctrl + L Clear the screen
Ctrl + C Exit whatever you’re using
Ctrl + D Kill the current shell
Option + → Move the cursor one word forward
Option + ← Move the cursor one word backward
Ctrl + F Move cursor one character forward
Ctrl + B Move cursor one character backward
Ctrl + Y Paste whatever you cut from the previous command
Ctrl + Z Place whatever you’re running into a dangling background procedure
Ctrl + _ Undo the previous command
Option + Shift + Cmd + C Copy plain text
Shift + Cmd + V Paste Selection
Exit Exit a shell session
/ (forward shell) Top-level directory
. (Single Period) Current directory
.. (Double Period) Parent directory
~ (Tide) Home directory
Sudo [command] Execute command along with security privileges of the superuser
Nano [file] Access the Terminal editor
Open [file] Access the files
[Command] – h Receive help about a command
man [command] Show the help manual of the command
Change directory  
cd Home directory
Cd [folder] Change directory
cd~ Home directory
cd/ Room of the drive
cd- Previous directory or folder you last browsed
pwd Show your working directory
cd.. Head up to the parent directory
cd../.. Navigate up two levels
List directory contents  
Is Highlight the name of the sub-directories in the directory
Is -C Force multi-column output of the listing
Is -a Will show list of all entries including those with .(perid) and ..(double period)
Is -1 Results the list of files in one entry per line format
Is -F Highlights a / immediately after each path that is directory, * right after executable scripts or program, and @ next to the symbolic link
Is -S Sort entries & files by size
Is -l List of long format
Is -l / List of file system from root with symbolic link
Is -It List of files sorted by time modified
Is -lh Long listing with human redeable files size in KB, MB, or GB
Is -lo List the file names with owner, size and flags
Is -la List detailed directory contents, including hidden files
File Size and Disk Space  
du List usage for all directories and it’s content
du -sh[folder] Human redeable output of all files in directory
du -s Hightlight entry of all specified file
du -sk* | sort -nr Shows the list of folders and files, totaling the size including the subfolder
df -h Calculate total free disk space
df -H Easily calculate free disk space in powers of 1000
Files and Directory Management  
mkdir <dir> Create a new folder tagged as <dir>
mkdir -p <dir>/<dir> Allows to create nested folders
mkdir <dir1> <dir2> <dir3> Create multiple folders at once
mkdir “<dir>” Create a folder with a space right in the filename
rmdir <dir> Clear the folder
rm -R <dir> Clear the folder and it’s content
touch <file> Create a fresh file without any extension
cp <file><dir> Copy file to a folder
cp <file><newfile> Copy the file to a current folder
cp <file>~/<dir>/<newfile> Copy a file to a folder and rename the copied file
cp -R<dir><”new dir”> Copy a folder to a fresh folder with spaces in the filename
cp -i <file><dir> Prompts you before copying a file with spaces in the filename
cp <file1><file2><file3>/User/<dir> Copying several files to a folder at once
ditto -V[folder path][new folder] Copy-pasting the contents of a folder to new folder.
rm <file> Delete a file
rm -i<file> Clear out the file only when giving confirmation
rm -f<file> Remove the file without confirmation
rm<file1><file2><file3> Vanish out multiple files at once
mv <file><newfilename> Rename/move
mv <file><dir> Let you move a file to folder
mv -i <file><dir> Optional -i flag to warm you before overwriting the file
mv *.png ~/<dir> Move all PNG file from present folder to a different folder
Command History  
Ctrl + R Go through previously used command
history n To see previously typed command
i[value] executes lastly run command typed that begin with a value
!! Runs last command typed
Is -ld Shows the default permission for a home directory
Is -ld/<dir> Shows the read, write, and access permission for a particular folder
chmod 755<file> Modify the permission of a file to 755
chmod -R 600 <dir> Modify the permission of a folder to 600
chown <user>:<group><file> Modify the ownership of a file to a users group. Add -R to include folders content
ps -ax Output currently running processes
ps -aux Highlight all processes with %cpu, %mem, page in, PID, and command
top Highlights live information about currently running processes
top -ocpu -s 5 Shows processes sorted by updating every 5 seconds, CPU usage
top -o rsize Sort by memory usage
kill PID Exit processes with ID<PID>
ps -ax | grep <appname> Find processes by PID and name
Ping <host> Ping host and display status
whois <domain> Output whois info for a domain
curl -O <url/to/file> Download file using http, https, or ftp
ssh <username>@<host> Create SSH connection to <host> with a <username>
scp <file><user>@<host>:/remote?path Copy <file> to remote <host>
arp -a Shows the list of devices on your local network.
iConfig en0 Shows your device IP and Mac addresses
traceroute [hostname] Analyze the path along with hops traversed by the packets from your device to a destination address
brew doctor Verify brew for potential errors
brew help List of useful homebrew cask and formula commands
brew install <formula>|cask> Install a cask or formula
brew uninstall <formula>|cask> Uninstall a formula or cask
brew list –cask Show only installed cask
brew list –formula Shows only installed formula
brew deps <formula>|<cask> Shows all dependencies of a formula or cask
brew search text|/regex/ Search cask or formula via regex
brew upgrade <formula>|<cask> Upgrade cask or formula
brew outdated <formula>|<cask> Search for outdated cask or formula
brew outdated –cask Search for outdated cask
insbrew pin [installed _formula] Pin a formula from getting upgraded
brew unpin [installed_formula] Unpin to upgrade a package
brew cleanup Clear stale lock file and outdated packages for all formula and casks
Environment Variable or Path  
printenv Highlights a list of currently set environment variables. Also shows which shells you are using.
$echo Commands Terminal to print something and shows it to you
echo $Path Verify the value of the Path Variable which stores a list of directories along with executable files
echo $Path >path.txt Export the path directory to a text files
export PATH=$PATH:absolute/path to/program/ Runs the program via terminal only in present session. If you use a program frequently, add the path to shell configuration file.
find <dir> -name <”file”> Search for all files named <file> inside <dir>. Use a wildcard (*) to inspect for parts of filenames.
grep “<text>” <file> Output all occurrences of <text> inside <file>
grep -rl “<text>” <dir> Look for files containing <text> inside <dir>
cat <file> Output the content of <file>
less <file> Output the content of <file> using the less command that supports pagination and more
head <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 output of <cmd1> to <cmd2>
Chaining Commands  
[command-a]; [command-b] Run command A then B, regardless of success of A
[command-a] && [command-b] Run command B if A is succeeded
[command-a] || [command-b] Run command B if A is failed
[command-a] & Run command A in background
PIPING Commands  
[command-a] | [command-b] Run command A and pass command to B
File Management  
touch [file] Create a new file
pwd Full path to working directory
pbpaste > [file] Paste clipboard content into file, pbpaste > paste-test.txt
pbpast Paste clipboard contents
pbcopy < [file] Copies file content to clipboards
mv [file] [new filename] Move/Rename
cp [file] [dir] Copy file to directory
cp [file] [newfile] Copy file to file

Final Thought!

So, this is the Mac terminal cheat sheet, which consumes some of the most useful commands on your Mac Terminal. There is massive number of Terminal commands, which is tough to remember—but fuss not; you need to remember some of them per your preferences.

See also  Fix iPhone Hotspot Not Working on Mac (Sonoma Updated)
Jaysukh Patel
Jaysukh Patel

Jaysukh Patel is the founder of howtoisolve. Also self Professional Developer, Techno lover mainly for iPhone, iPad, iPod Touch and iOS, Jaysukh is one of responsible person in his family. Contact On: [OR]

We will be happy to hear your thoughts

Leave a reply