Mac OS Terminal Commands: Cheatsheet Everybody Needs

Mac OS Terminal Commands: Cheatsheet Everybody Needs

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.CommandAction
1/Top-level Directory
2.Current Directory
3..Parent Directory
4~Home Directory
5Sudo [any command]Run a command with the security privilege of a super user
6nano [file]Opens the Terminal editor
7open [file]Opens a file
8[command] -hGet help with a command
9man [command]Show the help manual for a command

Key Combination Shortcuts

S.No.CommandAction
1TabAuto-Complete file and folder names
2Ctrl + AGo to the beginning of the line that you are currently typing on
3Ctrl + EGo to the end of the line that you are currently typing on
4Ctrl + UClear the line before the cursor
5Ctrl + KClear the line after the cursor
6Ctrl + WDelete the word before the cursor
7Ctrl + TSwap the last two characters before the cursor
8Esc + TSwap the last two words before the cursor
9Ctrl + LClear the screen
10Ctrl + CKill any Unix program that is running
11Ctrl + DExit the current shell
12Option + Right KeyMove the cursor forwards one word
13Option + Left KeyMove the cursor backward one word
14Ctrl + _Undo the previous command
15Ctrl + FMove the cursor one character forwards
16Ctrl + BMove the cursor one character Backwards
17Ctrl + YPaste whatever was cut by the previous command
18Ctrl + ZMake your running process into a suspended background process
19Option + Shift + Cmd + CCopy plain text
20Shift + Cmd + VPaste the selection
21exitEnd a shell session

Change Directory

S.No.CommandAction
1cdHome directory
2cd [folder]Change directory, e.g. cd Documents
3cd ~Home directory
4cd/Root of the drive
5cd –Previous directory or folder you last browsed
6pwdShow your working directory
7cd ..Move up to the parent directory
8cd../..Move up two levels.

List Directory Contents

S.No.CommandAction
1lsDisplay the name of files and subdirectories in the directory
2ls -CForce multi-column output of the listing
3ls -aList all entries, including those with. and ..
4ls -1Output the list of files in one entry per line format
5ls -FDisplay a / immediately after each path that is a directory, * after executable programs or scripts, and @ after a symbolic link
6ls -SSort files or entries by size
7ls -lList in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more
8ls -l /List of the file system from the root with symbolic links
9ls -ltList the files sorted by time modified (most recent first)
10ls -lhLong listing with human-readable file sizes in KB, MB, or GB
11ls -loList the file names with size, owner, and flags
12ls -laList detailed directory contents, including hidden files.

File Size And Disk Space

S.No.CommandAction
1duList usage for each subdirectory and its contents
2du -sh [folder]Human readable output of all files in a directory
3du -sDisplay an entry for each specified file
4df -hCalculate your system’s free disk space
5df -HCalculate free disk space in powers of 1,000

Command History

S.No.CommandAction
1Ctrl + RSearch through previously used commands
2history nShows 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.CommandAction
1ls -ldDisplay the default permission for a home directory
2ls -ld/<dir>Display the read, write, and access permission of a particular folder
3chmod 755 <file>Change the permission of a file to 755
4chmod -R 600 <dir>Change the permission of a folder (and its contents) to 600
5chown <user>:<group> <file>Change the ownership of a file to user and group. Add -R to include folder contents.

Processes

S.No.CommandAction
1ps -axOutput currently running processes. Here, a shows processes from all users. X shows processes that are not connected with the Terminal
2ps -aux.Shows all the processes with %cpu, %mem, page in, PID, and command
3topDisplay live information about currently running processes
4top -ocpu -s5Display processes sorted by CPU usage, updating every 5 seconds
5top -o rsizeSort top by memory usage
6kill PIDQuit 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

Previous Article
Snap Score: Everything You Need To Know

Snap Score: Everything You Need To Know

Next Article
How To Use CapCut on Windows and MacOS Without an Emulator?

How To Use CapCut on Windows and MacOS Without an Emulator?