Run Google Chrome as Root in Linux

Fix Chrome User Data Dir (Quick Hack)

  1. Open google-chrome binary (or wrapper) in your favorite editor:
vim /usr/bin/google-chrome
  1. Add --user-data-dir at the very end of the exec line. Example:
exec -a "$0" "$HERE/chrome" "$@" --user-data-dir
  1. Save, close, and you’re done.
    Now you can run Chrome without profile issues 🙂

Update: Fix Chrome User Data Dir (Modern Way)

Older trick (editing /usr/bin/google-chrome) may not work now since it’s often a binary, not a script.

Use one of these instead:

Method 1: Run directly from terminal

google-chrome --user-data-dir=/tmp/chrome-root --no-sandbox

Method 2: Update .desktop launcher

  1. Open:
vim /usr/share/applications/google-chrome.desktop

(or copy to local first)

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/<br>vim ~/.local/share/applications/google-chrome.desktop
  1. Find the Exec= line and update it like:
Exec=/usr/bin/google-chrome --user-data-dir=/tmp/chrome-root --no-sandbox %U
  1. Save, reload apps, done.

Method 3: Simple wrapper (clean way)

vim ~/chrome-root

Add:

#!/bin/bash<br>/usr/bin/google-chrome --user-data-dir=/tmp/chrome-root --no-sandbox "$@"

Make executable:

chmod +x ~/chrome-root

Run:

~/chrome-root

Note

Chrome blocks running as root by default, that’s why --no-sandbox is needed.
This is just for testing/debugging, don’t use it for daily browsing 😄