The Mac Terminal is intimidating at first, but with a dozen commands you do in seconds what takes several clicks in the Finder, and things the Finder does not even allow. This guide teaches you to move around folders, handle files without deleting the wrong thing and use macOS-specific tools such as caffeinate, pmset or mdfind.
In short
- With
pwd,lsandcdyou know where you are, what is there and how to move. Tab completes names for you.rmdeletes without going through the Trash: there is no undo. Use it calmly.sudoruns as administrator; use it only when you know what the command does.
Open Terminal
Press Cmd + space bar, type Terminal and press Return. It is also under Applications → Utilities.
You will see a line like user@MacBook ~ %. The % sign shows the shell is zsh, the default since macOS Catalina. The ~ is your home folder (/Users/your_user).
On a US Mac keyboard, some symbols are typed like this:
| Symbol | Keys |
|---|---|
~ (tilde) | Shift + ` (key left of 1) |
| (pipe) | Shift + \ |
\ (backslash) | \ key |
# | Shift + 3 |
Move around folders
pwd
ls
ls -la
ls -lh
cd Documents
cd ..
cd ~
cd -
| Command | What it does |
|---|---|
pwd | Shows the folder you are in |
ls | Lists the contents |
ls -la | Lists everything, including hidden files, with details |
ls -lh | Details with readable sizes (K, M, G) |
cd folder | Enters a folder |
cd .. | Goes up one level |
cd ~ or just cd | Returns to your home folder |
cd - | Returns to the previous folder |
A detail that confuses people: if your system is not in English, the Finder shows translated names for folders such as Documents, Downloads or Desktop, but in Terminal they are always Documents, Downloads and Desktop. The system translates the names only in the interface.
Absolute and relative paths

- An absolute path starts with
/or~and works from anywhere:/Applicationsor~/Downloads. - A relative path starts where you are: if you are in
~,Documents/facturasis the same as~/Documents/facturas.
Paths with spaces
Terminal separates words by spaces. If a folder is called My photos, you have three options:
cd "My photos"
cd Mis\ fotos
cd ~/Pictures/"My photos"
The handiest trick: type cd (with a space), drag the folder from the Finder into the Terminal window and press Return. The whole path is pasted with spaces already escaped.
Tab and history: less typing
- Tab: type the first letters of a file or folder and press Tab. If there are several matches, press Tab again to see them.
- Up / down arrow: go through previous commands.
- Control + R: search history. Type part of the command and press Return to run it.
history: shows the list of previous commands.- Control + C: cancels the running command.
- Cmd + K: clears the screen (or type
clear).
Create, copy, move and delete
mkdir proyectos
mkdir -p proyectos/2026/fotos
touch notas.txt
cp notas.txt copia.txt
cp -R proyectos proyectos-copia
mv copia.txt proyectos/
mv notas.txt apuntes.txt
| Command | What it does |
|---|---|
mkdir name | Creates a folder |
mkdir -p a/b/c | Creates the whole folder chain at once |
touch file | Creates an empty file |
cp source destination | Copies a file |
cp -R folder destination | Copies a folder with all its contents |
mv source destination | Moves, or renames if the destination is another name |
rm file | Deletes a file forever |
rm -r folder | Deletes a folder and everything in it |
Be careful with rm
This is the most important rule in the guide: rm sends nothing to the Trash. The file vanishes instantly and there is no Cmd + Z. cp and mv do not ask before overwriting a file with the same name either.

Habits that avoid grief:
- Before deleting, run
lswith the same pattern to see what will go. - Use
rm -ito confirm file by file. - Use
cp -iandmv -iso they warn before overwriting. - When in doubt, move to the Trash instead of deleting.
ls *.log
rm -i *.log
mv archivo-dudoso.txt ~/.Trash/
Never copy a rm -rf command from the internet without understanding every part. A misplaced space in a path can delete far more than you intended.
open: the bridge to the Finder
open opens anything as if you double-clicked it.
open .
open informe.pdf
open -a "Preview" foto.jpg
open -R informe.pdf
open https://www.apple.com/
open .opens the current folder in the Finder.open -achooses which app opens it.open -Rreveals the selected file in the Finder.
caffeinate: keep the Mac awake
Handy for long downloads, network copies or presentations.
caffeinate
caffeinate -d
caffeinate -t 3600
caffeinate -i rsync -a ~/Documents /Volumes/Copia/
| Option | Effect |
|---|---|
| No options | Prevents sleep until you press Control + C |
-d | Also keeps the display on |
-t 3600 | Only for 3600 seconds (1 hour) |
-i command | Keeps the Mac awake while that command runs |
On a laptop, closing the lid without an external display still puts it to sleep.
pmset: power and sleep
pmset shows and changes power settings. Reading them does not require administrator rights:
pmset -g
pmset -g batt
pmset -g assertions
pmset sleepnow
pmset -glists current settings.pmset -g battgives battery percentage and whether it is charging.pmset -g assertionsshows which apps are preventing sleep. Very useful if the Mac will not sleep on its own.pmset sleepnowputs it to sleep immediately.
Changing settings requires sudo. For example, turn off the display after 10 minutes:
sudo pmset -a displaysleep 10
mdfind: Spotlight from Terminal
mdfind uses the Spotlight index, so it finds files in seconds.
mdfind presupuesto
mdfind -name factura
mdfind -onlyin ~/Documents contrato
- Without options it searches names and contents.
-namesearches names only.-onlyinlimits the search to a folder.
If a folder is excluded from Spotlight, mdfind will not see it either.
diskutil list: see drives and partitions
diskutil list
diskutil list external
diskutil info disk4
diskutil list shows all drives (disk0, disk1…), their partitions and volumes. It is the first step before formatting or repairing a drive, to identify the right one. diskutil erase commands do not ask for confirmation: double-check the identifier.
sudo: administrator rights
sudo runs a command as administrator. Terminal asks for your password and, as you type it, nothing appears on screen: no dots or asterisks. That is normal. Type it and press Return.
Three rules:
- Use
sudoonly when a command fails due to permissions and you know why it needs them. - Never combine
sudowith anrmyou have not checked. - Even with
sudoyou cannot modify the system volume: it is protected.
Built-in help
Almost every command has a manual:
man ls
Move with the arrows, search with / and quit with q.
Common problems
- “command not found”: there is a typo in the name or the program is not installed. Check upper and lower case.
- “No such file or directory”: the path is wrong or has unquoted spaces. Use Tab or drag from the Finder.
- “Operation not permitted” in Desktop, Documents or Downloads: macOS protects those folders. Give Terminal Full Disk Access in System Settings → Privacy & Security.
- The sudo password “does not type”: it does, it just is not shown.
- You overwrote a file with
cpormv: there is no undo. If you have Time Machine, restore it from there; and use-ifrom now on.



