Command to open a URL?











up vote
36
down vote

favorite
13












My question is pretty simple:



Is there a command I can use in bash that will open a specific URL in the default browser?










share|improve this question




























    up vote
    36
    down vote

    favorite
    13












    My question is pretty simple:



    Is there a command I can use in bash that will open a specific URL in the default browser?










    share|improve this question


























      up vote
      36
      down vote

      favorite
      13









      up vote
      36
      down vote

      favorite
      13






      13





      My question is pretty simple:



      Is there a command I can use in bash that will open a specific URL in the default browser?










      share|improve this question















      My question is pretty simple:



      Is there a command I can use in bash that will open a specific URL in the default browser?







      command-line






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 20 '14 at 23:43









      Braiam

      51.2k20134219




      51.2k20134219










      asked Jan 3 '11 at 21:31









      Nathan Osman

      20.8k32144237




      20.8k32144237






















          5 Answers
          5






          active

          oldest

          votes

















          up vote
          50
          down vote



          accepted










          There's a command that knows about your default browser:



          xdg-open http://google.com


          This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).



          There is also



          xdg-email team@stackexchange.com


          and



          xdg-mime query default text/html


          To find out what application is going to be used.



          You can set your preffered application by going to System → Preferences → Preferred Applications:



          alt text



          These utilities are part of the freedesktop.org specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.






          share|improve this answer






























            up vote
            9
            down vote













            You can use xdg-open like so:



            xdg-open http://askubuntu.com/


            From the XDG-OPEN man page:




            xdg-open opens a file or URL in the user's preferred application. If a
            URL is provided the URL will be opened in the user's preferred web
            browser.







            share|improve this answer






























              up vote
              2
              down vote













              gnome-open works as well as xdg-open but neither knows what to do with naked domain.



              So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com.



              Here is a small function to make it easier to type and accept the stripped down domain name.



              function go { gnome-open http://$1 ; }


              Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.



              So now we just type go askubuntu.com and wallah!






              share|improve this answer






























                up vote
                1
                down vote













                Using x-www-browser URL will open the browser or a new tab at the given URL






                share|improve this answer




























                  up vote
                  1
                  down vote













                  If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:



                  chromium-browser https://youtube.com


                  or



                  firefox https://youtube.com





                  share|improve this answer























                    Your Answer








                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "89"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f19919%2fcommand-to-open-a-url%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    5 Answers
                    5






                    active

                    oldest

                    votes








                    5 Answers
                    5






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    50
                    down vote



                    accepted










                    There's a command that knows about your default browser:



                    xdg-open http://google.com


                    This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).



                    There is also



                    xdg-email team@stackexchange.com


                    and



                    xdg-mime query default text/html


                    To find out what application is going to be used.



                    You can set your preffered application by going to System → Preferences → Preferred Applications:



                    alt text



                    These utilities are part of the freedesktop.org specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.






                    share|improve this answer



























                      up vote
                      50
                      down vote



                      accepted










                      There's a command that knows about your default browser:



                      xdg-open http://google.com


                      This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).



                      There is also



                      xdg-email team@stackexchange.com


                      and



                      xdg-mime query default text/html


                      To find out what application is going to be used.



                      You can set your preffered application by going to System → Preferences → Preferred Applications:



                      alt text



                      These utilities are part of the freedesktop.org specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.






                      share|improve this answer

























                        up vote
                        50
                        down vote



                        accepted







                        up vote
                        50
                        down vote



                        accepted






                        There's a command that knows about your default browser:



                        xdg-open http://google.com


                        This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).



                        There is also



                        xdg-email team@stackexchange.com


                        and



                        xdg-mime query default text/html


                        To find out what application is going to be used.



                        You can set your preffered application by going to System → Preferences → Preferred Applications:



                        alt text



                        These utilities are part of the freedesktop.org specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.






                        share|improve this answer














                        There's a command that knows about your default browser:



                        xdg-open http://google.com


                        This will also work for every other type of URI (Uniform Resource Identifier), like images - which will automatically open with eog, openoffice documents, and so on, and also on filesystem paths (xdg-open /tmp/foobar.png).



                        There is also



                        xdg-email team@stackexchange.com


                        and



                        xdg-mime query default text/html


                        To find out what application is going to be used.



                        You can set your preffered application by going to System → Preferences → Preferred Applications:



                        alt text



                        These utilities are part of the freedesktop.org specification, so you can use them in your applications - and it's going to work on all of the desktops that adhere to the spec.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 7 '13 at 20:44









                        elias

                        987720




                        987720










                        answered Jan 3 '11 at 21:32









                        Stefano Palazzo

                        62.1k33183216




                        62.1k33183216
























                            up vote
                            9
                            down vote













                            You can use xdg-open like so:



                            xdg-open http://askubuntu.com/


                            From the XDG-OPEN man page:




                            xdg-open opens a file or URL in the user's preferred application. If a
                            URL is provided the URL will be opened in the user's preferred web
                            browser.







                            share|improve this answer



























                              up vote
                              9
                              down vote













                              You can use xdg-open like so:



                              xdg-open http://askubuntu.com/


                              From the XDG-OPEN man page:




                              xdg-open opens a file or URL in the user's preferred application. If a
                              URL is provided the URL will be opened in the user's preferred web
                              browser.







                              share|improve this answer

























                                up vote
                                9
                                down vote










                                up vote
                                9
                                down vote









                                You can use xdg-open like so:



                                xdg-open http://askubuntu.com/


                                From the XDG-OPEN man page:




                                xdg-open opens a file or URL in the user's preferred application. If a
                                URL is provided the URL will be opened in the user's preferred web
                                browser.







                                share|improve this answer














                                You can use xdg-open like so:



                                xdg-open http://askubuntu.com/


                                From the XDG-OPEN man page:




                                xdg-open opens a file or URL in the user's preferred application. If a
                                URL is provided the URL will be opened in the user's preferred web
                                browser.








                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jan 3 '11 at 22:44









                                dv3500ea

                                28.5k1289143




                                28.5k1289143










                                answered Jan 3 '11 at 21:34









                                Marco Ceppi

                                36.7k24152190




                                36.7k24152190






















                                    up vote
                                    2
                                    down vote













                                    gnome-open works as well as xdg-open but neither knows what to do with naked domain.



                                    So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com.



                                    Here is a small function to make it easier to type and accept the stripped down domain name.



                                    function go { gnome-open http://$1 ; }


                                    Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.



                                    So now we just type go askubuntu.com and wallah!






                                    share|improve this answer



























                                      up vote
                                      2
                                      down vote













                                      gnome-open works as well as xdg-open but neither knows what to do with naked domain.



                                      So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com.



                                      Here is a small function to make it easier to type and accept the stripped down domain name.



                                      function go { gnome-open http://$1 ; }


                                      Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.



                                      So now we just type go askubuntu.com and wallah!






                                      share|improve this answer

























                                        up vote
                                        2
                                        down vote










                                        up vote
                                        2
                                        down vote









                                        gnome-open works as well as xdg-open but neither knows what to do with naked domain.



                                        So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com.



                                        Here is a small function to make it easier to type and accept the stripped down domain name.



                                        function go { gnome-open http://$1 ; }


                                        Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.



                                        So now we just type go askubuntu.com and wallah!






                                        share|improve this answer














                                        gnome-open works as well as xdg-open but neither knows what to do with naked domain.



                                        So gnome-open http://askubuntu.com works but not gnome-open askubuntu.com.



                                        Here is a small function to make it easier to type and accept the stripped down domain name.



                                        function go { gnome-open http://$1 ; }


                                        Paste the above in your command line, hit enter and try it out. If you like it you can save it to your .bash_aliases or .bashrc file, then source ~/.bash_aliases (assuming it is in your home directory) and it will be persistent for that session and all new sessions.



                                        So now we just type go askubuntu.com and wallah!







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Aug 7 '13 at 12:03









                                        Radu Rădeanu

                                        115k34245321




                                        115k34245321










                                        answered Aug 7 '13 at 11:57









                                        Elijah Lynn

                                        2,56721729




                                        2,56721729






















                                            up vote
                                            1
                                            down vote













                                            Using x-www-browser URL will open the browser or a new tab at the given URL






                                            share|improve this answer

























                                              up vote
                                              1
                                              down vote













                                              Using x-www-browser URL will open the browser or a new tab at the given URL






                                              share|improve this answer























                                                up vote
                                                1
                                                down vote










                                                up vote
                                                1
                                                down vote









                                                Using x-www-browser URL will open the browser or a new tab at the given URL






                                                share|improve this answer












                                                Using x-www-browser URL will open the browser or a new tab at the given URL







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 11 '14 at 23:07









                                                bvidal

                                                1114




                                                1114






















                                                    up vote
                                                    1
                                                    down vote













                                                    If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:



                                                    chromium-browser https://youtube.com


                                                    or



                                                    firefox https://youtube.com





                                                    share|improve this answer



























                                                      up vote
                                                      1
                                                      down vote













                                                      If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:



                                                      chromium-browser https://youtube.com


                                                      or



                                                      firefox https://youtube.com





                                                      share|improve this answer

























                                                        up vote
                                                        1
                                                        down vote










                                                        up vote
                                                        1
                                                        down vote









                                                        If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:



                                                        chromium-browser https://youtube.com


                                                        or



                                                        firefox https://youtube.com





                                                        share|improve this answer














                                                        If you don't necessarily want to use the default browser, you can call any browser program directly and give the URL as argument, for example:



                                                        chromium-browser https://youtube.com


                                                        or



                                                        firefox https://youtube.com






                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Dec 5 at 20:35









                                                        Zanna

                                                        49.3k13126236




                                                        49.3k13126236










                                                        answered Dec 5 at 20:12









                                                        xyz

                                                        17116




                                                        17116






























                                                            draft saved

                                                            draft discarded




















































                                                            Thanks for contributing an answer to Ask Ubuntu!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.





                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                            Please pay close attention to the following guidance:


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid



                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function () {
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f19919%2fcommand-to-open-a-url%23new-answer', 'question_page');
                                                            }
                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            Popular posts from this blog

                                                            數位音樂下載

                                                            When can things happen in Etherscan, such as the picture below?

                                                            格利澤436b