Top 10 Mac Terminal Commands/Shortcuts You May Want to Know
macOS includes a free command-line tool named Terminal. You can execute commands in Terminal to open/uninstall apps, open/copy/move/delete files, etc. on your Mac. Below is a list of the top 10 Mac Terminal commands you may want to know. Some useful Mac Terminal shortcuts are also listed.
Top 10 Useful Mac Terminal Commands
To run Terminal commands on Mac, you need to open the Terminal app first. You can open it via Spotlight Search or go to Finder > Applications > Utilities > Terminal. Then you can run the popular Terminal commands listed below to perform various tasks.
You can type this command line in Terminal and press Enter. It will list the contents of the current directory. It will display the names of files and subdirectories in the directory.
cd [directory path] command to change the directory path. For instance,
cd /Applications, to change the current directory to Documents.
open [file name] command to open a file or app. For instance,
mkdir command, rmdir command
mkdir [folder name] command to create a new folder. Type
rmdir [folder name] if you want to delete an empty directory. Replace “folder name” in the command with the real name of the folder.
rm command, rm -r command
rm [file name or folder name] command to delete a file or folder with Terminal.
rm -r [folder name] command to remove the entire directory that may contain subdirectories or files.
Type this command to copy a file from one location to another or create a copy of the file. For instance,
cp test.txt ~/Documents/test.txt.
If you want to cut a file and move it to another location, you can use this command. For instance,
mv ~/Desktop/test.txt ~/Documents/test.txt.
Use the sudo command in Terminal to run commands with the administrator privileges. For instance,
sudo rm -r [folder name].
You can run various diskutil commands in Terminal to manage your disks or partitions on your Mac.
clear command in Mac Terminal and press Enter. It will remove all previous command lines and give you a clean Terminal screen. Optionally you can also press the Command + K shortcut to do the same operation.
man [command] and it will display a manual for the command. Replace "command" with the exact name of the command. Still, please note that running Terminal commands cannot be undone, and wrong commands may cause permanent data loss. If you are not familiar with Terminal commands, it’s not advised you use them.
Top 10 Useful Mac Terminal Shortcuts
Below we also list some useful keyboard shortcuts for Mac Terminal you may want to know.
- Ctrl + A: Go to the beginning of the line you are typing.
- Ctrl + E: Go to the end of the line you are typing.
- Ctrl + W: Delete the word before the cursor.
- Ctrl + K: Clear the line after the cursor.
- Ctrl + U: Clear the line before the cursor.
- Ctrl + L: Clear the screen.
- Ctrl + C: Kill the current running process.
- Ctrl + _: Undo the last command.
- Ctrl + Y: Paste whatever was cut by the last command.
- Ctrl + R: Search through previously used commands.
Use a Mac Cleaner Program to Keep Your Mac Clean
If you are a Mac user, you may install a Mac cleaner application to periodically scan and clean your Mac to keep your Mac running at the best performance.
BuhoCleaner is a professional Mac cleaner app that helps you boost your Mac’s performance from various aspects. You can use this tool to scan and remove junk data on your Mac in a flash. You can also use it to uninstall apps, delete files, shred files, manage startup items, analyze disk space, free up RAM, flush DNS, monitor system status, and more.
This post lists some useful Mac Terminal commands and keyboard shortcuts for your reference. If you want, you can run Mac command lines to perform various tasks. Remember to use the commands with caution, especially commands like “rm” that can permanently delete files. Double-check before executing commands to avoid unexpected consequences.