root下google-chrome不能运行解决方案
ubuntu安装google-chrome:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
google-chrome为了安全考虑,拒绝在root用户下执行
在文件
/usr/bin/google-chrome
末尾加上exec -a "$0" "$HERE/chrome" "$@" --user-data-dir
,添加之后还是不能启动。
需要将谷歌的沙箱sanbox关闭,以google-chrome %U --no-sandbox
启动就可以了,更改添加以下内容:
if [[ -n "$CHROME_USER_DATA_DIR" ]]; then
# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome" \
--user-data-dir="$CHROME_USER_DATA_DIR" "$@"
else
exec -a "$0" "$HERE/chrome" --user-data-dir="/root/.config/google-chrome/" \
"$@" --no-sandbox
fi