Command to open a URL?
up vote
36
down vote
favorite
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
add a comment |
up vote
36
down vote
favorite
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
add a comment |
up vote
36
down vote
favorite
up vote
36
down vote
favorite
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
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
command-line
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
add a comment |
add a comment |
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:
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.
add a comment |
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.
add a comment |
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!
add a comment |
up vote
1
down vote
Using x-www-browser URL
will open the browser or a new tab at the given URL
add a comment |
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
add a comment |
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:
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.
add a comment |
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:
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.
add a comment |
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:
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.
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:
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.
edited Jan 7 '13 at 20:44
elias
987720
987720
answered Jan 3 '11 at 21:32
Stefano Palazzo♦
62.1k33183216
62.1k33183216
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
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
add a comment |
add a comment |
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!
add a comment |
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!
add a comment |
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!
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!
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
add a comment |
add a comment |
up vote
1
down vote
Using x-www-browser URL
will open the browser or a new tab at the given URL
add a comment |
up vote
1
down vote
Using x-www-browser URL
will open the browser or a new tab at the given URL
add a comment |
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
Using x-www-browser URL
will open the browser or a new tab at the given URL
answered Nov 11 '14 at 23:07
bvidal
1114
1114
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Dec 5 at 20:35
Zanna
49.3k13126236
49.3k13126236
answered Dec 5 at 20:12
xyz
17116
17116
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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