
谷歌 Chrome 是一款为现代网络打造的快速、安全的网页浏览器。它可用于所有主流操作系统,并允许你在不同设备之间同步书签、历史记录和密码。
本指南介绍如何在 Ubuntu 24.04 上,使用 Google 官方软件包和软件源来安装谷歌 Chrome。
快速参考
| 任务 | 命令 |
|---|---|
| 下载软件包 | wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb |
| 安装软件包 | sudo apt install ./google-chrome-stable_current_amd64.deb |
| 启动 Chrome | google-chrome |
| 设为默认浏览器 | xdg-settings set default-web-browser google-chrome.desktop |
| 更新 Chrome | sudo apt update && sudo apt upgrade |
| 卸载 Chrome | sudo apt remove google-chrome-stable |
| 移除 Chrome 及其软件源 | sudo apt purge google-chrome-stable |
| 验证软件源文件 | cat /etc/apt/sources.list.d/google-chrome.sources |
在 Ubuntu 上安装 Google Chrome
Chrome 并非开源软件,也未包含在 Ubuntu 标准软件源中。官方的 .deb 软件包会添加 Google 签名密钥和软件源,从而使 Chrome 能够自动保持更新。
下载 Google Chrome
打开终端,使用 wget 下载最新的稳定版软件包:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
安装 Google Chrome
使用 apt 安装该软件包。运行此命令需要 sudo 权限:
sudo apt install ./google-chrome-stable_current_amd64.deb
出现提示时,输入你的密码以完成安装。
启动 Google Chrome
按下 Super(超级)键打开“活动”概览,搜索“Google Chrome”,然后启动它:
你也可以从终端启动 Chrome:
google-chrome
首次启动 Chrome 时,系统会询问你是否要将其设为默认浏览器并启用崩溃报告:
随后 Chrome 会打开欢迎页面:
在此页面,你可以使用 Google 账户登录并同步你的设置。
将 Chrome 设为默认浏览器
若要从命令行将 Chrome 设为默认浏览器,请运行:
xdg-settings set default-web-browser google-chrome.desktop
若要验证当前的默认浏览器:
xdg-settings get default-web-browser
google-chrome.desktop
更新 Google Chrome
安装过程中,系统会添加 Google 官方软件源。使用 cat 命令验证软件源文件:
cat /etc/apt/sources.list.d/google-chrome.sources
示例输出:
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# Changes to this file will not be preserved.
# This file will not be recreated if removed.
X-Repolib-Name: Google Chrome
Types: deb
URIs: https://dl.google.com/linux/chrome-stable/deb/
Suites: stable
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/google-chrome.gpg
当前 Chrome 软件包以 deb822 格式写入该文件,因此文件名以 .sources 结尾,而非 .list。旧版本使用的是单行文件 /etc/apt/sources.list.d/google-chrome.list,而在一台运行 Chrome 较久的系统上,软件包会为你迁移该旧文件——在 Chrome 下次更新时将其删除或注释掉其中的 Google 条目。如果两个文件同时存在,.list 文件就是遗留项,不再提供该软件源。Signed-By 这一行指向 Google 签名密钥,该密钥由软件包单独安装在 /usr/share/keyrings/google-chrome.gpg,因此即使 Chrome 被移除但未彻底清除,该软件源仍能正常工作。
Chrome 的更新通过标准的 Ubuntu 更新流程提供:
sudo apt update && sudo apt upgrade
卸载 Google Chrome
若要从系统中移除 Google Chrome,但保留 Google 软件源配置,请运行:
sudo apt remove google-chrome-stable
然后清理未使用的依赖项:
sudo apt autoremove
这两条命令都不会触碰你位于 ~/.config/google-chrome 的浏览器配置文件,因此重新安装后书签和设置都会保留。
若要连同软件源文件和签名密钥一起移除 Chrome,则应改用 purge(彻底清除)命令:
sudo apt purge google-chrome-stable
sudo apt update
彻底清除会删除 /etc/apt/sources.list.d/google-chrome.sources、/usr/share/keyrings/google-chrome.gpg 和 /etc/default/google-chrome,使你的 APT 配置中不再残留任何与 Google 相关的内容。
故障排查
安装因依赖错误而失败:修复损坏的依赖项,然后重新运行安装:
sudo apt --fix-broken install
sudo apt install ./google-chrome-stable_current_amd64.deb
安装后 Chrome 无法启动:关闭所有正在运行的 Chrome 进程,然后重新启动:
pkill -f google-chrome
google-chrome
软件源文件丢失且 Chrome 不再接收更新:单独重新安装软件包不会恢复该文件。Chrome 通过在 /etc/default/google-chrome 中将 repo_add_once="false" 来记录它已经配置过该软件源,而只有当该值为 true 时它才会重新创建该文件。将该值改回并重装:
sudo sed -i 's/^repo_add_once=.*/repo_add_once="true"/' /etc/default/google-chrome
sudo apt install --reinstall ./google-chrome-stable_current_amd64.deb
确认 /etc/apt/sources.list.d/google-chrome.sources 已重新存在,然后运行 sudo apt update。
常见问题
Chrome 与 Chromium 有何区别?Chromium 是 Chrome 所基于的开源项目。Chrome 增加了专有功能,例如自动更新、获许可的媒体编解码器(AAC、H.264)以及更紧密的 Google 账户集成。
如何从其他浏览器导入书签?在 Chrome 中,打开右上角的三点菜单,然后选择“书签和列表 > 导入书签和设置”,并选择你要导入的浏览器。
我可以安装 Chrome Beta 或 Dev 频道吗?可以。在下载 URL 和安装命令中,将 google-chrome-stable 替换为 google-chrome-beta 或 google-chrome-unstable 即可。
结论
在 Ubuntu 24.04 上,Google Chrome 通过官方 .deb 软件包安装,该软件包同时会添加 Google 软件源,使浏览器能够通过 apt 保持更新。如果你更偏好完全开源的浏览器,Chromium 是最接近的替代选择。