Terminal on macOS is a very powerful tool. Whether you are a beginner or a casual user who wants to be productive, mastering some basic commands will save a lot of time.
Here is a list of the most useful MacBook Terminal commands, grouped by function:
1. File & Folder Navigation (Basic)
Before manipulating files, you need to know how to navigate directories.
pwd(Print Working Directory): Displays the current folder location.ls: Lists files and folders in the active directory.ls -la: Displays all files, including hidden files, with size details.
cd [folder_name]: Changes to a specific folder.cd ..: Goes up one level to the parent folder.cd ~: Returns directly to the Home folder (user).
clear: Clears the Terminal screen.
2. File & Folder Management
Commands to create, delete, and move files without opening Finder.
mkdir [folder_name]: Creates a new folder.touch [file_name.txt]: Creates a new file (e.g., text file, HTML, etc.).cp [source] [destination]: Copies a file.cp -R [source_folder] [destination_folder]: Copies a folder and all its contents.
mv [source] [destination]: Moves or renames a file/folder.rm [file_name]: Permanently deletes a file (Caution: this does not go to Trash!).rm -rf [folder_name]: Forcefully deletes a folder and all its contents. Use with extreme caution.
3. macOS Secret Tricks (System Tweaks)
Some special commands to change your Mac's system behavior not found in Settings menu.
Show Hidden Files in Finder:
Bashdefaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder
(Change
_TRUE_to_FALSE_to hide them again).Prevent Mac from Going into Sleep Mode:
Bashcaffeinate
(Mac will not sleep while this Terminal is open. Press
_Control + C_to stop it).Change Screenshot Format (Default: PNG to JPG):
Bashdefaults write com.apple.screencapture type jpg; killall SystemUIServer
4. System & Network Information
To check your Mac's health or internet connection.
toporhtop: Displays running processes and CPU/RAM usage in real-time (like Task Manager). Pressqto exit.ping [website_address]: Checks internet connection to a specific site (e.g.,ping google.com).ifconfig: Displays network information, including your Mac's local IP address (look underen0).networksetup -setairportpower en0 off(oron): Turns Wi-Fi off or on via Terminal.
5. Power Commands (Important Shortcuts)
If your Mac freezes or you need to perform a quick command:
killall [Application_Name]: Force quits a hanging application.- Example:
killall Finderorkillall Safari.
- Example:
sudo shutdown -h now: Shuts down Mac immediately with administrator privileges.sudo shutdown -r now: Restarts Mac immediately.
๐ก Additional Tips:
* Tab Key: While typing a file or folder name, press the Tab key. Terminal will auto-complete the name.
- Sudo: If a command requires
sudo, it means you need Administrator access. You will be prompted to enter your Mac password (characters won't appear as you type, just press Enter).
Written by
Wilan
A regular contributor to Bali Island Tekno who actively shares knowledge about technology, programming, and the world of software engineering.