Mac Terminal Commands PDF: Are you a Mac user looking to become an expert in using Mac Terminal Commands? Whether your goal is to become an administrator, or simply use the terminal command line effectively, this article is here to help you understand the basics.

Are you a Mac user looking to become an expert in using Mac Terminal Commands? Whether your goal is to become an administrator or use the terminal command line effectively, this article is here to help you understand the basics.
Understanding Your Command Line
The first step in understanding how to use the Mac terminal commands is to understand what they are and what their purpose is. The command line gives you direct access to the underlying operating system that runs all of your Mac applications. You can control every element of your computer by running this command line. In essence, it gives you complete control over your computer.
Commonly Used Terminal Commands
Once comfortable with how the command line works and what commands are available, try out some of the more commonly used ones. For instance, typing “ls” into a terminal window will list all of your files and directories for viewing purposes. Another commonly used one is “cd,” which allows you to change directories from one location to another.
As you become increasingly comfortable with how things work within the terminal, start experimenting on your own time with various commands that aren’t currently being utilized.
This way, you can become familiar with all sorts of commands without worrying about damaging any crucial files or settings to discover which one works best for your needs.
What are the Terminal commands for Mac?
The Terminal is a powerful command line tool available in macOS. Here are some of the commonly used Terminal commands for Mac:
- List files and directories: ls
- Change directory: cd
- Show contents of a directory: ls -la (add ‘-l’ for long listing, add ‘-a’ for all files, including hidden ones), etc
Why Do I Need It?
Using the terminal is something only some people do every day, so having a cheat sheet handy is incredibly useful if you need to remember certain commands or want to look up specific functions quickly and easily. This resource also makes it easier for users to discover more advanced commands they may not have thought about using before.
How Do I See All Commands in Mac Terminal?
Using the “man” command in Mac Terminal is a great way to view all available commands. For example, you can type “man ls” to view information about the ls command. Additionally, you can use the –help option with any command to get more specific help on how to use it. Finally, many online resources are available where you can find information about all of the different Mac Terminal commands.
How to Use Cmd in Mac?
Using the command line on a Mac is a powerful way to perform many administrative and configuration tasks. To get started, open the Terminal application (which can be found in the Utilities folder under Applications). From here, you can run basic commands like pwd to find out your current working directory or ls to list files in that directory.
For more advanced usage, you can use commands like grep to search for text within files or chmod to modify file permissions. You can also customize many settings using configuration files (such as .bashrc) located in your user directory.
Many helpful tutorials and reference materials are available online if you would like to learn more about using the command line on a Mac.
What are some basic Mac terminal commands to get you started?
Here are some basic Mac terminal commands to get you started:
- Open Applications – open + application name: This command is used to open applications and files on Mac. To use this, type ‘open’ followed by the application name into the Terminal window. For example, if you want to launch Safari, type “open Safari” and press Enter.
- Find Files – find + filename: To find any file on your Mac, use this command by typing ‘find’ followed by the filename. This allows you to search for files beyond just their names; it will also retrieve files based on creation date, modification date, file extension, etc.
- Copy Files – cp + source address + target address: If you need to copy a file from one location to another (either within or outside of your computer), this is the command that you need! Typing “cp” followed by the source address (the current location of the file) and target address (the required destination) into the Terminal will complete a copy process in no time.
- Move Files – mv + source address + target address: This command does exactly the same job as the cp command – but with moving rather than copying. So if all you need is to move files from one location to another, type “mv” and then specify the source and destination locations to work correctly.
- Delete Files – rm + pathname: If you want to delete a specific file from a specific location in your computer, typing “rm” followed by pathname into Terminal will do this for you! It should be noted that sometimes when deleting large files, it can take longer than usual, depending on your computer’s performance and its speed.
- Create Folders – mkdir + foldername: This useful command makes creating folders easy – no more dragging icons around in Finder windows! All that needs doing here is simply entering “mkdir” with foldername right after it – just make sure not to add any dots or slashes onto foldername as this may create unnecessary errors within the Terminal itself!
Mac Terminal Commands Cheat Sheet
Learning how to navigate the Terminal using command line instructions is an essential skill. Here are some basic Mac terminal commands to get you started:
COMMAND | ACTION |
Shortcuts | |
Tab | Auto-complete file and folder names |
Ctrl + A | Go to the beginning of the line you’re currently typing on |
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 cursor one word forward |
Option + ← | Move cursor one word backward |
Ctrl + F | Move cursor one character forward |
Ctrl + B | Move 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 | |
/ (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 | |
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 | |
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 | |
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 |
du -sk* | sort -nr | List files and folders, totaling the size including the subfolders. Replace sk* with sm* to list directories in MB |
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 | |
mkdir <dir> | Create 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 new folder. In here “-V” print a line of status for every file copied |
rm <file> | Delete a file (This deletes the file permanently; use 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 current folder to a different folder |
Command History | |
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 | |
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 | |
ps -ax | Output currently running processes. Here, a shows processes from all users and x shows processes that are not connected with the 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 |
ps -ax | grep <appname> | Find a process by name or PID |
Network | |
ping <host> | Ping host and display status |
whois <domain> | Output whois info for a domain |
curl -O <url/to/file> | Download file via HTTP, HTTPS, or FTP |
ssh <username>@<host> | Establish SSH connection to <host> with user <username> |
scp <file><user>@<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 | |
brew doctor | Check brew for potential problems |
brew help | List of useful homebrew formula and cask commands |
brew install <formula>|<cask> | Install a formula or cask |
brew uninstall <formula>|cask> | Uninstall a formula or cask |
brew list –formula | List only installed formulas |
brew list –cask | List only installed cask |
brew deps <formula>|<cask> | List all the dependencies of a formula or cask |
brew search text|/regex/ | Search formula or cask through regex |
brew upgrade <formula>|<cask> | Upgrade the formula or cask |
brew outdated <formula>|<cask> | 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 formula and casks. |
Environment Variable or Path | |
printenv | Display a list of currently set environment variables. Also tells you which shell you’re using |
$echo | Tells the terminal to print something and show it to you |
echo $PATH | Check the value of the PATH variable which storea 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 shell configuration file. |
Search | |
find <dir> -name <“file”> | Find all files named <file> inside <dir>. Use wildcards (*) to search for parts of filenames |
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 | |
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> | 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> |
Mac Terminal Commands PDF
Mac Terminal, a powerful tool that allows users to enter commands in order to control various aspects of their computer. The Terminal can be daunting if you’re new to it, but luckily there are many resources available that can help you learn how to use the Terminal efficiently.
Here is a Mac Terminal Commands Cheat Sheet PDF to download for future use. Once you’ve downloaded our cheat sheet(s), just store them in an easy-to-find location – like your desktop – so you won’t ever be more than a click away from recalling all those helpful terminal commands!
Conclusion
In conclusion, the Mac Terminal is an incredibly powerful tool that can be used to do all kinds of useful tasks. To help you get started, we’ve compiled a PDF of all the important and useful commands you need to know. With it, you’ll be able to master the Mac Terminal in no time!
Get Best Software review like the Best Windows Software and Mac software as well as Android and iPhone apps and other programs like chrome extensions and more.
https://thesoftbest.com/