The*_*rer 18
来自:在默认和非默认浏览器中打开 URL 的终端命令(我认为这不是重复的)
如果你想打开 Chrome 到一个特定的 URL,只需运行
google-chrome www.example.com
Run Code Online (Sandbox Code Playgroud)
要将默认浏览器打开到特定 URL,请运行
xdg-open www.example.com
Run Code Online (Sandbox Code Playgroud)
如果您需要运行 Chrome 并在之后关闭终端窗口,请运行
google-chrome http://www.google.com </dev/null >/dev/null 2>&1 & disown
Run Code Online (Sandbox Code Playgroud)
>/dev/null 2>&1
将阻止来自浏览器的消息输出到终端窗口;&
将进程置于后台,disown
并将从作业列表中删除作业/进程,防止向其传播 SIGHUP 信号。
要使用其他浏览器执行此操作,只需替换google-chrome
为该其他浏览器的可执行文件名称即可。
您可以通过运行非常令人惊讶地从终端打开谷歌浏览器
google-chrome
Run Code Online (Sandbox Code Playgroud)
您也可以通过运行来启动 Firefox
firefox
Run Code Online (Sandbox Code Playgroud)
您也可以添加一个 URL 作为参数来打开它。
firefox www.askubuntu.com
Run Code Online (Sandbox Code Playgroud)
sensible-browser
似乎是您正在寻找的选项。这将运行系统上默认设置的网络浏览器,您还可以在其上传递参数以运行网络浏览器并打开给定的网站。
在终端中,放下下一个并点击Return
sensible-browser
Run Code Online (Sandbox Code Playgroud)
下一个命令将在您首选的网络浏览器中打开youtube.com :
sensible-browser youtube.com
Run Code Online (Sandbox Code Playgroud)
只需将下一个命令放入终端,点击Return并明智地选择即可:
sudo update-alternatives --config x-www-browser
Run Code Online (Sandbox Code Playgroud)
在下一个示例中,我选择luakit
作为默认浏览器。您可以根据需要多次更改默认网络浏览器。
geppettvs@T400:~$ sudo update-alternatives --config x-www-browser
There are 5 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/google-chrome-stable 200 auto mode
1 /usr/bin/firefox 40 manual mode
2 /usr/bin/google-chrome-stable 200 manual mode
3 /usr/bin/konqueror 30 manual mode
4 /usr/bin/luakit 10 manual mode
5 /usr/bin/xlinks2 69 manual mode
Press enter to keep the current choice[*], or type selection number: 4
update-alternatives: using /usr/bin/luakit to provide /usr/bin/x-www-browser (x-www-browser) in manual mode
Run Code Online (Sandbox Code Playgroud)
如果您希望在关闭终端后保持网络浏览器运行,只需在命令末尾添加一个“&”符号即可:
sensible-browser [parameters] &
Run Code Online (Sandbox Code Playgroud)
祝你好运!