17370845950

Linux怎么安装谷歌浏览器 Linux命令行安装Chrome教程【详解】
Linux下安装谷歌浏览器有五种命令行方法:一、APT仓库法(Ubuntu/Debian);二、DEB包直装法(离线/受限网络);三、Snap法(支持snapd的发行版);四、RPM法(CentOS/RHEL/Fedora);五、自动化脚本法(多发行版适配)。

如果您在Linux系统中需要通过命令行安装谷歌浏览器,但不确定该使用哪种方式或遇到依赖错误、源不可达等问题,则可能是由于发行版差异、架构识别错误或网络策略限制所致。以下是多种经验证的命令行安装方法:

一、通过APT仓库添加并安装(适用于Ubuntu/Debian系)

此方法将Google官方APT源加入系统软件源列表,确保后续可通过apt update自动获取安全更新与版本升级,适合长期使用且注重稳定性的用户。

1、下载Google Chrome的GPG签名密钥:wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/google-chrome-keyring.gpg

2、将Chrome稳定版仓库地址写入源配置文件:echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list

3、更新本地APT包索引:sudo apt update

4、安装google-chrome-stable主程序包:sudo apt install google-chrome-stable -y

二、直接下载并安装DEB包(通用Debian系离线/受限网络场景)

当无法访问外部APT源或需跳过源配置步骤时,可直接获取官方构建的DEB安装包,由dpkg完成本地安装,操作轻量、路径可控。

1、使用wget获取最新稳定版64位DEB包:wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

2、调用dpkg执行安装:sudo dpkg -i google-chrome-stable_current_amd64.

deb

3、若提示依赖缺失,立即修复并重装:sudo apt --fix-broken install -y

三、使用Snap安装(适用于支持snapd的现代发行版)

Snaps是容器化软件包格式,自带运行时依赖,无需手动处理lib冲突,适合SELinux严格环境或Ubuntu Core等系统。

1、确认snapd服务已启用:sudo systemctl is-active snapd

2、如未运行则启动并设为开机自启:sudo systemctl enable --now snapd

3、从Snap Store安装稳定版Chrome:sudo snap install google-chrome

四、使用RPM包安装(适用于CentOS/RHEL/Fedora)

Red Hat系发行版原生支持RPM包管理,直接安装官方RPM可避免APT兼容性问题,且不依赖第三方仓库配置。

1、下载Chrome稳定版x86_64 RPM包:wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

2、使用dnf或yum进行本地安装:sudo dnf localinstall -y google-chrome-stable_current_x86_64.rpm

3、若使用较老版本RHEL/CentOS 7,改用yum命令:sudo yum localinstall -y google-chrome-stable_current_x86_64.rpm

五、执行自动化脚本安装(一键适配多发行版)

该方案通过社区维护的install_chrome.sh脚本自动探测系统类型、架构与包管理器,动态选择安装路径,降低人工判断成本。

1、下载脚本文件:wget http://chrome.richardlloyd.org.uk/install_chrome.sh

2、赋予脚本可执行权限:chmod u+x install_chrome.sh

3、以稳定版模式运行安装:sudo ./install_chrome.sh -s