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

example:

open /Applications/Google\ Chrome.app

launch app and passing command line arg

example:

nohup /Applications/Emacs.app/Contents/MacOS/Emacs -q &

open a URL in a running browser

open -a safari url

make Finder show hidden files

In Terminal, type:

defaults write com.apple.finder AppleShowAllFiles TRUE

to restart Finder, do

killall Finder

make the mouse speed faster

First, show your current scaling value.

defaults read -g com.apple.mouse.scaling

To make it faster, do:

defaults write -g com.apple.mouse.scaling 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'

screenshot

/usr/sbin/screencapture

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

or

sudo nmbd restart