Install XMRig CPU Miner on Ubuntu 20.04 with CLI

Mine Monero (XMR) on Ubuntu 20.04 & Ubuntu 18.04 with XMRig CPU Miner

Monero is among the best coins to mine with a CPU because its resistance to ASIC mining. And for the best results, we like to use Ubuntu as our operating system when mining Monero. If you’re looking to setup a Monero mining rig with Ubuntu or just setting up your old PC, this tutorial will help you achieve that. Today we’ll show you how to install XMRig CPU Miner on Ubuntu 20.04.

What is XMRig?

XMRig is mining software codded in C++ language. It’s an open-source software (has a dev fee of 1%) and available to download from official github repository. We’ll be using an Ubuntu 20.04 server for this tutorial. If you’re on Ubuntu 20.04 desktop, hit CtrlAlt + T keys to launch CLI. If you’re connecting to a remote Ubuntu 20.04 server from Windows, use Putty to connect over SSH. Make sure to login with root user account.

Although we’re using Ubuntu 20.04 LTC machine for this tutorial, we’ve tested this tutorial on Ubuntu 18.04 machine as well. Follow the exact setup and let us know in the comments if you have problems with it. And if you’re on Ubuntu 16.04, you can use our install XMRig on Ubuntu 16.04 tutorial.

Prepare Ubuntu 20.04 to Install XMRig CPU Miner

Before we start installing XMRig on our Ubuntu 20.04 machine, we need to do some initial maintenance and install some dependencies. So, log in to your machine and execute following commands to update apt cache.
apt update
apt upgrade
It can take a minute or two. Once that’s done, let’s do some cleanup,
apt autoremove
Then a reboot,
reboot
Log in to your server again when it comes back online. Now we can install the XMRig dependencies with following command.
apt-get install git build-essential cmake automake libtool autoconf
Let it complete and then we’re ready to install XMRig on Ubuntu 20.04.

Install XMRig CPU Miner on Ubuntu 20.04

We will be fetching the miner directly from the official Github repository. We can use git clone command for that. Let’s do it,

git clone https://github.com/xmrig/xmrig.git

Create the working directory build and then navigate to the scripts directory.

mkdir xmrig/build && cd xmrig/scripts

Run the installation script and the navigate to build directory

./build_deps.sh && cd ../build

Install XMRig on Ubuntu 20.04

cmake .. -DXMRIG_DEPS=scripts/deps
make -j$(nproc)

Two commands above will take bit longer to process. You are ready to mine Monero on Ubuntu 20.04 once its complete.

Start mining Monero with XMRig CPU Miner on Ubuntu 20.04

If you were able to complete the above instructions successfully, you’re now ready to mine XMR on your Ubuntu 20.04 or Ubuntu 18.04 machine. There are two methods you can use the miner. The first method is by,

Using command line…

This is not the preferred way to use the miner. We’ll be passing the arguments directly from the command line with a single command. Following is the command to use,

/root/xmrig/build/./xmrig -a cryptonight -o stratum+tcp://pool.supportxmr.com:5555 -u MoneroAddress -p MinerIdentifier:Email -t 1

This will mine Monero on supportxmr.com with 1 CPU. Change your MoneroAddress, MinerIdentifier, Email and the number of treads with the -t vaule towards the end.

The second and the preferred method is by,

Using JSON config file…

In this method, we’ll store miner config in a json file. Let’s create it in the build directory,

nano /root/xmrig/build/config.json

Now use the configuration wizard to generate your XMRig miner configuration. Paste the output from wizard to the config.json file. It should look something like this,

{
    "autosave": true,
    "cpu": true,
    "opencl": false,
    "cuda": false,
    "pools": [
        {
            "url": "pool.supportxmr.com:443",
            "user": "4A5Zv5vpNcG4Tk7pF6wRHha6jZEgoF9UgFv49qijdHxeLSLYCWyCbHZA6sqBiWRSwcBcnBrJuEWxjYgtwJAQnzcT3BDvq8m",
            "pass": "test",
            "keepalive": true,
            "tls": true
        }
    ]
}

Now close the file by hitting Ctrl+X. Following command will launch the miner and start mining Monero on Ubuntu 20.04.

/root/xmrig/build/./xmrig

That’s it. You can further optimize your mining with xmr-node-proxy if you have more than 10 miners. Happy mining!!

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.