Mac OS X Misc Command Line Tips

By Xah Lee. Date: . Last updated: .

here's some macOS command line tips.

launch app using command line


open /Applications/Google\

launch app and passing command line arg


nohup /Applications/ -q &

open a URL in a running browser

open -a safari url

make Finder show hidden files

In Terminal, type:

defaults write AppleShowAllFiles TRUE

to restart Finder, do

killall Finder

make the mouse speed faster

First, show your current scaling value.

defaults read -g

To make it faster, do:

defaults write -g 5

You need to relog for this to take effect.

put system to sleep

Use applescript, like this:

osascript -e 'tell application "System Events" to sleep'



restart Dashboard

killall Dock

start Remote Login

sudo /usr/bin/sshd

You may need to generate a passphrase if this is run for the first time. Simply go to System Prefences, Sharing, and check mark Remote Login, will automatically generate the passphrase.

start Windows File Sharing

sudo smbd restart


sudo nmbd restart