Table of Contents Show
The Mac operating system has a user-friendly design, so you won’t need to spend much time learning how to use it. Mac, like Windows, has its command prompt line interface, Terminal program (Unix commands or Mac OS Terminal Commands).
Learning how to use the Terminal tool might be helpful and allow you to dive deep into Mac OS settings with ease. Not only that but there are other factors. The Terminal software makes it simple to search for files and manage files, directories, and other data. All of this gives you more power and control over your Mac.
Several commands may help you get control of your Mac, but remembering them all might take time and effort. As a result, we’ve included all the crucial Mac Terminal commands that might help boost your machine’s productivity. To access the Terminal, navigate to the Finder Menu. Then select Go To-> Utilities. Look for Terminal under Utilities. The spotlight may also be used to search for Terminal.
Let’s get started!
Mac OS Terminal Commands
Basics
S.No. | Command | Action |
1 | / | Top-level Directory |
2 | . | Current Directory |
3 | .. | Parent Directory |
4 | ~ | Home Directory |
5 | Sudo [any command] | Run a command with the security privilege of a super user |
6 | nano [file] | Opens the Terminal editor |
7 | open [file] | Opens a file |
8 | [command] -h | Get help with a command |
9 | man [command] | Show the help manual for a command |
Key Combination Shortcuts
S.No. | Command | Action |
1 | Tab | Auto-Complete file and folder names |
2 | Ctrl + A | Go to the beginning of the line that you are currently typing on |
3 | Ctrl + E | Go to the end of the line that you are currently typing on |
4 | Ctrl + U | Clear the line before the cursor |
5 | Ctrl + K | Clear the line after the cursor |
6 | Ctrl + W | Delete the word before the cursor |
7 | Ctrl + T | Swap the last two characters before the cursor |
8 | Esc + T | Swap the last two words before the cursor |
9 | Ctrl + L | Clear the screen |
10 | Ctrl + C | Kill any Unix program that is running |
11 | Ctrl + D | Exit the current shell |
12 | Option + Right Key | Move the cursor forwards one word |
13 | Option + Left Key | Move the cursor backward one word |
14 | Ctrl + _ | Undo the previous command |
15 | Ctrl + F | Move the cursor one character forwards |
16 | Ctrl + B | Move the cursor one character Backwards |
17 | Ctrl + Y | Paste whatever was cut by the previous command |
18 | Ctrl + Z | Make your running process into a suspended background process |
19 | Option + Shift + Cmd + C | Copy plain text |
20 | Shift + Cmd + V | Paste the selection |
21 | exit | End a shell session |
Change Directory
S.No. | Command | Action |
1 | cd | Home directory |
2 | cd [folder] | Change directory, e.g. cd Documents |
3 | cd ~ | Home directory |
4 | cd/ | Root of the drive |
5 | cd – | Previous directory or folder you last browsed |
6 | pwd | Show your working directory |
7 | cd .. | Move up to the parent directory |
8 | cd../.. | Move up two levels. |
List Directory Contents
S.No. | Command | Action |
1 | ls | Display the name of files and subdirectories in the directory |
2 | ls -C | Force multi-column output of the listing |
3 | ls -a | List all entries, including those with. and .. |
4 | ls -1 | Output the list of files in one entry per line format |
5 | ls -F | Display a / immediately after each path that is a directory, * after executable programs or scripts, and @ after a symbolic link |
6 | ls -S | Sort files or entries by size |
7 | ls -l | List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more |
8 | ls -l / | List of the file system from the root with symbolic links |
9 | ls -lt | List the files sorted by time modified (most recent first) |
10 | ls -lh | Long listing with human-readable file sizes in KB, MB, or GB |
11 | ls -lo | List the file names with size, owner, and flags |
12 | ls -la | List detailed directory contents, including hidden files. |
File Size And Disk Space
S.No. | Command | Action |
1 | du | List usage for each subdirectory and its contents |
2 | du -sh [folder] | Human readable output of all files in a directory |
3 | du -s | Display an entry for each specified file |
4 | df -h | Calculate your system’s free disk space |
5 | df -H | Calculate free disk space in powers of 1,000 |
Command History
S.No. | Command | Action |
1 | Ctrl + R | Search through previously used commands |
2 | history n | Shows the previous commands you’ve typed. Add a number to limit to the last n items |
3 | ![value] | Execute the last command typed that starts with a value |
4 | !! | Execute the last command type |
Permissions
S.No. | Command | Action |
1 | ls -ld | Display the default permission for a home directory |
2 | ls -ld/<dir> | Display the read, write, and access permission of a particular folder |
3 | chmod 755 <file> | Change the permission of a file to 755 |
4 | chmod -R 600 <dir> | Change the permission of a folder (and its contents) to 600 |
5 | chown <user>:<group> <file> | Change the ownership of a file to user and group. Add -R to include folder contents. |
Processes
S.No. | Command | Action |
1 | ps -ax | Output currently running processes. Here, a shows processes from all users. X shows processes that are not connected with the Terminal |
2 | ps -aux. | Shows all the processes with %cpu, %mem, page in, PID, and command |
3 | top | Display live information about currently running processes |
4 | top -ocpu -s5 | Display processes sorted by CPU usage, updating every 5 seconds |
5 | top -o rsize | Sort top by memory usage |
6 | kill PID | Quit process with ID <PID>. You’ll see PID as a column in the Activity Monitor. |
EndNote
This cheat sheet contains a large number of instructions. But you can study some of them at a time! Choose a couple that works well with your workflow and will save you the most time.
After you’ve learned these Mac OS Terminal Commands, there’s even more, to discover about the Terminal to improve your experience. Extend this by customizing the Mac Terminal to make it even more helpful.
Also read: How to Reset Your MacBook or Mac Desktop Before Selling