Open a URL in the Default Browser from the Command Line

Jul 18, 2011 - Leave a Comment

Using the command line open tool, you can immediately launch any URL from the Terminal into the default web browser. The syntax is remarkably easy:

open http://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 specify port numbers:

open http://yahoo.com:80

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

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 it recently to a launch multiple instances of a single app, and to open the present working directory in Finder.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

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

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

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