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 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. And if you’re on Ubuntu 16.04, you can use our install XMRig on Ubuntu 16.04  tutorial. This post doesn’t nor will speak to this 16.04 install of Ubuntu, but is a suggested training aid. Other newer sources could be found.

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. Once that’s done, let’s do some cleanup, grab something to snack on, take a bio break…

sudo reboot now

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. Let’s do it to it.

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

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

sudo mkdir xmrig/build && cd xmrig/scripts

Run the installation script and the navigate to build directory

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

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 is not that hard!

Start mining Monero with XMRig CPU Miner on Ubuntu 20.04

Then a reboot!

If you were able to complete the above instructions successfully, you’re now ready to mine XMR on your linux machine. There are two methods you can launch and 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,

sudo /<your_user_ID>/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 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. Let’s create it in the build directory,

nano /root/xmrig/build/config.json

Now use your favorite Linux file editor to generate your XMRig miner configuration. Paste the lines of code below the config.json file. 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 are not careful.

Please note, 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?

/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!

Optional – Automation:

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

Adding the above ^^^ will daily check for updates to Linux, apply them, reboot the server and start the XMRIG at sign on.

  • Bitcoin
Scan to Donate Bitcoin to 43Lo54TcHU5EEzwkEMY7P82csfLJD4TgSbfJVEn2z6tp6a62pPvrM48j38VBQCqNytU2YH3PvTKvCdiDNzKBtsBLDyHrUkH

Donate Bitcoin to this address

Scan the QR code or copy the address below into your wallet to send some Bitcoin


Related: