Home

How do I run XMRig as root or with sudo on Linux?

You can run XMRig as root on Linux by placing sudo before the command you normally use to start it, such as sudo ./xmrig --config=./config.json. Root is Linux’s administrator account, so this gives XMRig full control of your computer—not just permission to mine.

Start XMRig with sudo

Only do this on a computer you own or have explicit permission to administer and mine on. Open a terminal and move into the folder containing your XMRig program:

cd /path/to/xmrig-folder

Replace that path with your actual folder location. If the file is not marked as executable, allow it to run:

chmod +x ./xmrig

Then start it with your configuration file:

sudo ./xmrig --config=./config.json

A configuration file stores settings such as your mining pool and wallet address. Make sure config.json contains your intended settings before you start.

Enter your Linux account password when prompted. It is normal for the terminal to show no characters while you type. Press Ctrl+C to stop XMRig.

Using an explicit configuration path helps avoid confusion about which settings load when you switch users.

If you are already logged in as root

You do not need sudo when your terminal already has root privileges. Run:

./xmrig --config=./config.json

You can check your current user with:

whoami

If the result is root, commands in that terminal already have administrator access.

On systems without sudo, you may be able to use:

su -

This usually requires the root account’s password, if that account is enabled. After switching, move back to your XMRig folder and run the program. Type exit afterward to leave the root shell.

If your account is not allowed to use sudo, ask the administrator. Do not try to bypass that restriction.

What root access actually helps with

XMRig does not always need root to mine Monero. Higher privileges mainly help with certain performance settings:

  • Huge pages: Larger chunks of memory that can reduce memory-management work. A properly configured Linux system can let an ordinary user use them.
  • MSR settings: Model-specific registers are CPU controls that XMRig can adjust on supported processors to improve RandomX performance. RandomX is Monero’s mining algorithm—the work your processor performs to mine.

Root access can help XMRig apply these settings, but it does not guarantee they will work. Your processor, Linux configuration, and virtual-machine restrictions still matter.

Check XMRig’s startup messages for huge-page allocation and MSR status. Running as root alone is not proof that either optimization succeeded.

Keep administrator access limited

Only run a trusted XMRig build with sudo. Obtain it from the official project and verify its published checksums or signatures where available. Never run an unknown “mining booster” as root.

Avoid making XMRig permanently run with root privileges through a special executable permission, or allowing it unrestricted password-free sudo access. A malicious or replaced binary would then have an easy route to controlling your system.

For ongoing mining, consider having an administrator configure the required memory and CPU settings separately, then running XMRig under a dedicated, non-root account.

The bottom line

For a straightforward launch, use sudo ./xmrig --config=./config.json. Check the startup output, keep your configuration path explicit, and use administrator privileges only when you actually need them.

All 1,000 questions

MyAiMiner.com

MyAiMiner.com — Monero mining blog. 1,000 questions. Clear answers.

Monero (XMR) Mining BLOG

Hashes0
Blocks accepted0
Blocks rejected0
Runtime00:00:00