如何从命令行运行Firefox

时间:2020-01-09 10:40:39  来源:igfitidea点击:

如何从Linux命令行(shell提示符)运行Firefox浏览器?
如何在基于Linux或Unix的服务器上从命令行运行Firefox?
您可以使用以下带有特殊参数的命令行启动Mozilla firefox浏览器。

Firefox从命令行启动浏览器

您可以使用以下类型命令找到Firefox的完整路径:

type -a firefox

要打开浏览器,请执行:

$ firefox

或者

$ /usr/bin/firefox

Firefox打开网址

要在新标签页中打开URL,请执行:

$ /usr/bin/firefox --new-window http://www.theitroad.local/

要在新窗口中打开URL,请执行:

$ /usr/bin/firefox www.theitroad.local

Unix/Linux从命令行运行Firefox

Linux Firefox在新标签页中打开网址

您必须运行:

firefox --new-tab url
/usr/bin/firefox --new-tab https://www.theitroad.com/

Firefox搜索选项

您可以使用默认搜索引擎搜索单词(词),然后执行:

$ /usr/bin/firefox --search "term"
$ /usr/bin/firefox -search "linux add user to group"

打开Firefox选项/首选项

要打开Firefox的选项/首选项窗口,请执行:

$ /usr/bin/firefox --preferences

将Firefox设置为默认浏览器

要将Firefox应用设置为默认浏览器,请执行:

$ /usr/bin/firefox --setDefaultBrowser

如何在服务器上远程运行Firefox?

SSH通常用于以安全方式通过Internet传输不安全的流量。
您可以使用ssh客户端登录到远程服务器:

$ ssh -X [email protected]

要运行Firefox,请执行:

$ /usr/bin/firefox &
$ /usr/bin/firefox www.theitroad.local

如何从远程服务器运行Firefox

您需要终端和Gnome/KDE GUI才能与本地桌面一起使用。
但是,如果需要在远程Linux服务器上运行Firefox并在本地桌面上获取输出,请尝试ssh命令:

ssh -X [email protected] firefox www.theitroad.local

可以指定要使用的X显示:

firefox --display=DISPLAY url
firefox --display=0.0 url
DISPLAY=some-desktop:0.0 firefox url
ssh -X [email protected] "firefox --display=0.0 www.theitroad.local"

如何找出所有其他Firefox命令行选项?

运行以下命令,然后可以使用grep命令/egrep命令过滤输出:

firefox --help
firefox --help | grep search
Usage: firefox [ options ... ] [URL]
       where options include:
 
X11 options
  --display=DISPLAY  X display to use
  --sync             Make X calls synchronous
  --g-fatal-warnings Make all warnings fatal
 
Firefox options
  -h or --help       Print this message.
  -v or --version    Print Firefox version.
  -P <profile>       Start with <profile>.
  --profile <path>   Start with profile at <path>.
  --migration        Start with migration wizard.
  --ProfileManager   Start with ProfileManager.
  --no-remote        Do not accept or send remote commands; implies
                     --new-instance.
  --new-instance     Open new instance, not a new window in running instance.
  --UILocale <locale> Start with <locale> resources as UI Locale.
  --safe-mode        Disables extensions and themes for this session.
  -MOZ_LOG=<modules> Treated as MOZ_LOG=<modules> environment variable, overrides it.
  -MOZ_LOG_FILE=<file> Treated as MOZ_LOG_FILE=<file> environment variable, overrides it.
                     If MOZ_LOG_FILE is not specified as an argument or as an environment variable,
                     logging will be written to stdout.
  --headless         Run without a GUI.
  --save-recordings  Save recordings for all content processes to a directory.
  --browser          Open a browser window.
  --new-window <url> Open <url> in a new window.
  --new-tab <url>    Open <url> in a new tab.
  --private-window <url> Open <url> in a new private window.
  --preferences      Open Preferences dialog.
  --screenshot [<path>] Save screenshot to <path> or in working directory.
  --window-size width[,height] Width and optionally height of screenshot.
  --search <term>    Search <term> with your default search engine.
  --setDefaultBrowser Set this app as the default browser.
  --jsconsole        Open the Browser Console.
  --jsdebugger       Open the Browser Toolbox.
  --wait-for-jsdebugger Spin event loop until JS debugger connects.
                     Enables debugging (some) application startup code paths.
                     Only has an effect when `--jsdebugger` is also supplied.
  --devtools         Open DevTools on initial load.
  --start-debugger-server [ws:][ <port> | <path> ] Start the debugger server on
                     a TCP port or Unix domain socket path. Defaults to TCP port
                     6000. Use WebSocket protocol if ws: prefix is specified.
  --recording <file> Record drawing for a given URL.
  --recording-output <file> Specify destination file for a drawing recording.
 
      -g or --debug          Start within debugger
      -d or --debugger       Specify debugger to start with (eg, gdb or valgrind)
      -a or --debugger-args  Specify arguments for debugger