What I love about OSX is its UNIX(-like) foundation. There are the default UNIX command line tools but also lots of OSX specific commands. This is a compilation of some of these commands you might not know. Feel free to comment.
This is a mere list of commands with a short description and one or two examples. To find out more of course use
Commands may destroy all your data or cause a nuclear meltdown — use only if you know what you are doing.
Configuration and networking
– Manage a variety of configuration stuff.
sudo systemsetup -getdate # view system date systemsetup -getcomputername # display computer name
– Execute Apple Software update from the commandline
softwareupdate -l # list available updates sudo softwareupdate -i -a # install all available updates
– Manage the network configuration
sudo networksetup -listallhardwareports # list all network interfaces with MAC addresses sudo networksetup -switchtolocation home # switch network locations
– Directory service management, for example users, groups etc. – complex stuff, mostly for use on OSX server
dscl localhost -list /Local/Default/Users # list all local users
– Manage DNS cache
dscacheutil -flushcache # clear local DNS cache
– View system information (Like SystemProfiler.app in Utilities)
system_profiler # list lots of information
– Change file flags, like “hidden”, “archived”..
ls -l0 # View flags in the current directory
– View extended file attributes, like icon, creator and so on. To write these attributes use SetFileInfo
GetFileInfo any.txt # list the attributes
Disks and images
– Manage local disks
diskutil list # list local drives and partitions sudo diskutil repairPermissions / # repair permissions
– Manage disk images
hdiutil burn animage.dmg # burn imagefile to cd/dvd hdiutil create -srcfolder path any.dmg # create dmg-image from folder
– Format a disk
# dangerous enough...
– Interact with CD/DVD drives
drutil eject # eject media drutil status # show detailed information about drives and media
– Open a file with a given application.
open example.txt # opens the file in the default text editor open . # opens a new finder window with the current commandline path
– Access OSX clipboard
ls | pbcopy # copy dir listing to clipboard
– Manage Spotlight
mdutil -s / # show indexing status on root drive
– Take a screenshot
screencapture ~/Desktop/scr.png # make a screenshot and save it to the given file
– Run Applescript from the shell
osascript -e 'tell app "Terminal" to close every window whose frontmost is true' # close all terminal windows sudo osascript -e "set Volume 0" # set system volume to zero
– Manage QuickLook
qlmanage -m # list QuickLook plugins and handlers
– Run periodic system jobs
sudo periodic daily # run daily stuff
More in-depth information can be found here: