Here is a list of useful Terminal Commands.
The easiest way to open Terminal is using Spotlight.
Press Command + Space and enter Terminal .
Now you see the Terminal window.
First you will see the prompt which shows your Mac’s Hostname followed by a double dot, a tilde, a blank space and your username.
The tilde is an alias for your user profile path.
If you change the folder (look at the CD command examples) you will see the folder path instead of the tilde.
Clear the Terminal window
To clear the Terminal window, simply use the command clear:
After that you’ll see only the Hostname and username with our any informations from earlier used commands.
Navigating to folders
To navigate to folders in Terminal use the Command cd and the folder you want to navigate.
For example the Applications folder use:
Now you see that your command prompt has changed.
Actually your prompt looks like:
To get back to your user profile path simply enter cd:
If you have some spaces in your folder path you’ll have to use the backslash.
To enter a folder named „unknown artist“ on your desktop use this code:
cd /desktop/unknown\ artist
Or you can use quotation marks and any spaces that path contains will be ignored.
cd „/desktop/unknown artist
You can also drag and drop the folder from Finder to your Terminal window if you are not sure how to write it.
List the Content of a folder
To show the content of a folder use the LS command:
Now you will see all folders and files in that directory
To see a formatted list use
To see all hidden folders and files use
You can combine the list view and the hidden files/folders view
Check the uptime of your Mac
If you use your Mac like me, it may bee some days / weeks after your last reboot / shutdown.
To see how long you haven’t restarted use the uptime command:
Show / Install available OSX Updates
After Apple moved the Updates to the AppStore we can use Terminal commands to show and install available updates.
To show your available updates use this command:
sudo softwareupdate -l
After entering your password it takes a few seconds an you will get a list of all available updates.
Using this command will install all available updates:
sudo softwareupdate -ia
Rerun a command
To use the same command again you’ll only have to enter:
If you want to enter the same command again with sudo in front of it use:
Download a file using Terminal
If you want to download a file without a browser use this command:
curl -0 http://url_to_the_file
Change url_to_the_file to your files URL
Shutdown/Reboot your Mac with/without delay
These commands are useful to shutdown / restart remote clients like OSX Servers.
Normally its not that useful on your own Mac.
To shutdown your Mac immediately use:
sudo shutdown -h now
To shutdown your Mac in 60 Minutes use:
sudo shutdown -h +60
To restart your Mac immediately use:
sudo shutdown -r now
To restart your Mac in 60 Minutes use:
sudo shutdown -r +60
Prevent OSX from standby
If you don“t want your Mac get in standy use this command:
This command will get your Mac awake until you press Control + C to stop it.
If you want to prevent the standby for 10 minutes use:
caffeinate -u -t 600
The time value is in seconds!
let your Mac talk
Simply use the say command to to let your Mac talk:
say "Hello my friend"
Your Mac will say Hello my friend
To let the Mac read a file use:
say -f /path_to_your/file.txt
change path_to_your_file to the path your file is located in and file.txt to the filename
See all active processes
To see all your active processes enter:
You’ll now see all running processes, the usage of RAM, CPU and a lot of other informations.
To stop the view press control + C
See all commands you’ve entered
To see all your commands you’ve used and see what you’ve done use: