Firefox Linux命令怎么用,有哪些常用参数
- 云服务器
- 2026-07-23
- 4
启动 Firefox
在 Linux 终端中,直接输入 firefox 即可启动浏览器,如果系统提示命令未找到,可能需要安装 Firefox 或将其加入 PATH。
# 启动 Firefox(默认打开新窗口) firefox # 打开指定 URL firefox https://example.com # 新建窗口而非标签页 firefox -new-window https://example.com # 新建标签页(如果已有窗口) firefox -new-tab https://example.com
常用命令行选项
| 选项 | 说明 | 示例 |
|---|---|---|
| -P <profile_name> | 指定用户配置文件名,可同时管理多个配置 | firefox -P work |
| -CreateProfile <profile_name> | 创建新配置文件 | firefox -CreateProfile dev |
| -no-remote | 允许同时运行多个 Firefox 实例 | firefox -no-remote -P test |
| -private | 以隐私模式启动 | firefox -private |
| -safe-mode | 安全模式,禁用所有扩展 | firefox -safe-mode |
| -headless | 无界面模式,用于自动化测试 | firefox -headless https://example.com |
| -width / -height | 设置窗口初始大小 | firefox -width 1024 -height 768 |
| -kiosk | 全屏自助模式,无菜单栏和地址栏 | firefox -kiosk https://example.com |
环境变量
- MOZ_HEADLESS:设置为 1 等同于 -headless 选项。
- MOZ_CRASHREPORTER_DISABLE

:设为 1 禁用崩溃报告器。


- WAYLAND_DISPLAY:在 Wayland 环境下强制使用 Wayland 后端(如 wayland)。
- 同时运行多个配置文件:使用 -P 和 -no-remote 可独立运行不同配置,互不干扰。
- 通过命令行控制 Firefox:firefox -remote 在某些旧版本中用于控制已运行的实例,新版本中已废弃,建议使用 -new-tab 等选项。
- 查看所有可用选项:firefox --help 或 firefox -h 会列出完整的命令行参数。
- 开启远程调试:firefox -start-debugger-server 可启动 DevTools 调试服务器。
实用技巧
常见问题及解答
问题 1:如何在 Linux 中通过命令行打开 Firefox 并直接打印页面?
答:可以使用 -print 选项(需要 Firefox 支持),但更常用的方法是结合 -headless 和 pdf.js 功能。
firefox -headless -print-to-file /tmp/output.pdf https://example.com
这会生成 PDF 文件,再通过 lp 命令打印。
问题 2:如何让 Firefox 在启动时自动恢复上次的会话?
答:默认情况下 Firefox 会提示是否恢复会话,若需强制恢复,可编辑配置文件或使用 -restore-session 选项(部分版本支持),另一种方法是配置 browser.sessionstore.resume_from_crash 为 true,从命令行启动时,可以添加 -P default 并确保会话恢复功能已启用。