You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Ubuntu 16.04及AWS Ubuntu实例安装Chrome遇权限问题求助

Fix "This command can only be used by root" Error When Installing Chrome on AWS Ubuntu 16.04

Got it, let's get that Chrome installation sorted out. That error pops up because your regular user account doesn't have the elevated permissions required to modify system-level packages or repositories. Here are two reliable ways to fix this:

Ubuntu on AWS defaults to disabling direct root login for security, so sudo is the standard way to run commands with temporary root privileges. Just prepend sudo to every command that throws the permission error. Here's the full, working installation sequence:

# Import Google Chrome's GPG signing key (verifies package integrity)
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

# Add Chrome's official repository to your system's package sources
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'

# Update your package index to include the new Chrome repo
sudo apt-get update

# Install the stable version of Google Chrome
sudo apt-get install google-chrome-stable

Each sudo invocation will prompt you for your regular user's password (the one you use to SSH into the AWS instance), and then run the command with root-level access.

2. Switch to Root User (Optional, Less Secure)

If you prefer to run all commands as root directly, you can switch to the root account first. Keep in mind that this is riskier—accidental commands can break your system more easily. Here's how:

# Switch to root user (enter your regular user password when prompted)
sudo su -

Once you're logged in as root, run the installation commands without sudo:

wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
apt-get update
apt-get install google-chrome-stable

When you're done, type exit to return to your regular user account.

Quick Note

AWS's default Ubuntu 16.04 instances create a user (usually named ubuntu) that's already in the sudoers group, so you shouldn't have issues using sudo out of the box. If you get a "user is not in the sudoers file" error, you'd need to adjust sudoers permissions, but that's rare for AWS-managed instances.

内容的提问来源于stack exchange,提问作者Chris Duren

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:52:44