How to open Google Chrome or Safari from Terminal

When I try to open 'chrome' or 'safari' in terminal,

$ safari
-bash: safari: command not found
$ open safari
The file Desktop/safari does not exist.
$ chrome
-bash: chrome: command not found

How to open them in right methods.


All you need to do in Terminal, no matter what directory you're in, is use

open -a Safari
open -a Google\ Chrome

and optionally, add the URL afterwards if you want to open the Browser to the given URL

open -a Safari http://apple.com/

There are several ways you could do it. But first, if Safari is your default browser, then you can just use this to open the URL:
open <url> => open http://www.google.com (Remember to specify the protocol!) and this will open the URL in Safari (default browser)

Otherwise you can be more specific like:

/usr/bin/open https://google.com/

And to open a sepecific browser, you can do

/usr/bin/open -a Safari https://google.com/
/usr/bin/open -a Firefox https://google.com/
/usr/bin/open -a Chrome https://google.com/