Setting Up Bitcoin Full Node in Ubuntu

You can easily set up Bitcoin in Ubuntu using the commands below:

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind

Now before running the Bitcoin daemon program, you need to define the configuration file.

The default location of the configuration file is home location, however, you can always change it.

Switch to the home folder.

cd ~
mkdir .bitcoin
cd .bitcoin
vi bitcoin.conf

Then add the following lines in the configuration file.

server=1
testnet=1
txindex=1
rpcuser=UNIQUE_RPC_USER
rpcpassword=UNIQUE_RPC_PASSWORD

You can change the testnet=0 to connect to the main network of the Bitcoin. We have set it to 1 to connect to default network.

Save the file and run the bitcoin daemon program using the following command.

bitcoind -daemon

Now wait for few hours to sync all the blocks from Genesis and you should be good to go.

In order to check if the syncing is going on or not, run the following command.

bitcoin-cli getblockchaininfo

It will return JSON like this:

{
        "chain": "test",
        "blocks": 538777,
        "headers": 538777,
        "bestblockhash": "00000000000000000008dbf85fdd18172b5218bec32fb17caed08ebdfadbd070",
        "difficulty": 6727225469722.534,
        "mediantime": 1535397577,
        "verificationprogress": 0.999999554147431,
        "initialblockdownload": false,
        "chainwork": "000000000000000000000000000000000000000002eb7c1daac5a4c94a9b27f0",
        "size_on_disk": 205296701750,
        "pruned": false,
        "softforks": [
                 ............
        ],
        "bip9_softforks": {
            "csv": {
                          ............
            },
            "segwit": {
                          ...........
            }
        },
        "warnings": ""
    },
    "error": null,
    "id": null
}

Further links

  • Github: https://github.com/bitcoin/bitcoin/
  • Official website: https://bitcoincore.org/