XMRIG – Monero Mining

Monero Olympic Rings

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 of its resistance to ASIC mining. And for the best results, we like to use Ubuntu and Raspberry Pi miners as our operating system when mining Monero. If you’re looking to set up a Monero mining rig with Ubuntu or just set 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? (pre-lude)

XMRig is mining software codded in C++ language. It’s open-source software (has a dev fee of 1%) and is available to download from the 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 log in with the 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.

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 the following commands to update apt-cache.

sudo apt update
sudo apt upgrade -y

It can take a moment or two depending on how up-to-date your Linux instance is. . Once that’s done, let’s do some cleanup, grab something to snack on, take a bio break…

Log in to your server again when it comes back online. Now we can install the XMRig dependencies with the 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.

sudo reboot now

Install XMRig CPU Miner on Ubuntu 20.04


Log in to your server again when it comes back online. Now we can install the XMRig dependencies with the following command.

sudo apt-get install git build-essential cmake automake libtool autoconf -y

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 the git clone command for that—change directory or cd to the folder you want to install/run XMR in. Executing the command below will download and extract and build a folder structure for XMR, so choose wisely, or be prepared to move the substructure after downloading.

Let’s do it to it, RIGHT NOW.

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

An example of the way 20 some odd miners of mine are setup looks like this after cloning the GIT repository:

/home/userid/xmrig

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

sudo mkdir /home/userid/xmrig/build 
cd /home/userid/xmrig/scripts

Run the installation script and navigate to the build directory. If you have not done so already, have a coffee or bio break, this will take a little time.

sudo ./build_deps.sh
cd ..

Install XMRig on Ubuntu 20.04 (Not always necessary on Ubuntu, but this is what OS is being discussed)

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

The two commands above will take a bit longer to process. You are ready to mine Monero on Ubuntu 20.04 once they are complete! A few more steps to go here, and we are onto “picking”.

Take a breather/bio break as the rest gets longer, but it is not that hard!

Start mining Monero with XMRig CPU Miner on Ubuntu 20.04!

But wait, there is one more step.

If you were able to complete the above instructions successfully, you’re now ready to mine XMR on your Linux machine, sort of. XMRIG needs to be passed some arguments to work properly and make sure your wallet gets populated with your proof of work.

There are two methods you can launch and use the miner. The first method is by using the command line.

This is not the preferred way to use the miner. But, we will be passing the arguments directly from the command line with a single command if you choose. Following is the command to use,

sudo /<your_user_ID>/xmrig/build/./xmrig -a cryptonight -o stratum+tcp://pool.supportxmr.com:5555 -u <<YourMoneroAddress>> -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 value towards the end.

The second and the preferred method is by far better; if you know what you are doing in launching from the CMD line, proceed as you wish.

Using JSON config file…

In this method, we’ll store the miner config in a JSON file. I would suggest going to the XMR Wizzard page and using their wizard to create the skeleton of the config.json file.

Once done with the wizard, save it in the build directory:

nano <your install location>/xmrig/build/config.json

Now use your favorite Linux file editor to generate your XMRig miner configuration. It should look something like this:

{
    "autosave": true,
    "donate-level": 1,
    "cpu": true,
    "opencl": false,
    "cuda": false,
    "pools": [
        {
            "url": "pool.supportxmr.com:443",
            "user": "43Lo54TcHU5EEzwkEMY7P82csfLJD4TgSbfJVEn2z6tp6a62pPvrM48j38VBQCqNytU2YH3PvTKvCdiDNzKBtsBLDyHrUkH.<your machine name>",
            "pass": "<your machine name>",
            "rig-id": "<your machine name>",
            "keepalive": true,
            "tls": true
        },
{
            "url": "pool.supportxmr.com:443",
            "user": "43Lo54TcHU5EEzwkEMY7P82csfLJD4TgSbfJVEn2z6tp6a62pPvrM48j38VBQCqNytU2YH3PvTKvCdiDNzKBtsBLDyHrUkH.DONATION",
            "pass": "DONATION",
            "rig-id": "DONATION",
            "keepalive": true,
            "tls": true
        }
    ]
}

Edit the file before or after launching XMRIG if you know what you are doing. The following command will launch the miner and start mining Monero on Ubuntu 20.04.

It is important you pay attention to the “donate-level” entry. Most times, unless altered, the default will be set at 5%. This variable is modifiable but will find itself back at 5% if you attempt to set the donate level to 0%, so set it to 1%.

Please note that this “config.json” file will be changed once you launch XMRIG for the first time; it is to be expected. But after the initial draft and launching with XMRIG, it should remain static and safe for you to use! I hope this helped, and the donations entry would be appreciated!

It would be appreciated to use my instructions and include me in the list of your “pools” for donations. If not, may the force be with you!

sudo <your install location>/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!

Optional – Automation:

Adding the following to a corn job will perform a daily check for updates to Linux, apply them, reboot the server, and start the XMRIG upon boot of Linux.

sudo crontab -e
# m h  dom mon dow   command
0 1 * * * /usr/bin/apt-get update -y
0 2 * * * /usr/bin/apt-get upgrade -y
0 3 * * * /sbin/shutdown -r now
@reboot <your install location>/xmrig/build/xmrig -B

This is unnecessary, but for large-scale deployments that you might not want to manually update yourself, this helps with some automation. That is where Ansible could help out for CI/CD.


Leave a Reply