Open a URL in the Default Browser from the Command Line

Jul 18, 2011 - 2 Comments

terminal Using the command line open tool, you can immediately launch any URL from the Terminal into the default web browser of Mac OS X. In other words, you’re launching the specified site into a GUI browser from the command line.

The syntax to open any URL into the default web browser like this is remarkably easy to use and remember:


open https://osxdaily.com

You can try this with any URL, even complex URL strings, although long query strings are best when placed into quotations.

You can also use https and even specify port numbers:

open http://yahoo.com:80

Be sure to include http:// or https:// or it will look for a local file instead, while also offering a suggestion that you made an error: “Perhaps you meant ‘http://yahoo.com’?”

Remember that you can change the Mac default web browser at any time by using Safari Preferences – yes, you use Safari to change the OS X browser even if you have no intention on using Safari and want to set something like Chrome or Firefox as the default. That may be different down the road, but for now that’s the way it’s done in all versions of OS X.

The open utility comes from Mac OS X’s ancestral NextStep roots and offers the ability to launch files and GUI apps from the command line. We’ve used the open trick on numerous occasions with a variety of tips, whether just opening a GUI app, to launch multiple instances of a single app, and even to open the present working directory in Finder from the command line. It’s a powerful tool that has a lot of usage potential.

.

Related articles:

Posted by: David Mendez in Command Line, Mac OS, Tips & Tricks

2 Comments

» Comments RSS Feed

  1. Rich says:

    Except it doesn’t work…. just says no matches found

  2. Denis says:

    Thank you, this tip was helpful to me!

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site