# How to install a full Bitcoin node on a testnet network with Linux Ubuntu
###### tags: `workshops_mln`
**Table of Contents**
[TOC]
## Authors
Twitter for corrections, comments or suggestions to: [@bitao36](https://twitter.com/bitao36)
[@decentralizedb](https://twitter.com/@decentralizedb) [@dulce](https://twitter.com/dulce)
This tutorial was prepared for the [Mastering Lightning Socratic Seminar](https://libreriadesatoshi.com/) through [@libreriadesatoshi](https://twitter.com/libdesatoshi).
## How to get started
If you are totally new to Bitcoin we recommend reading:
* [Reading about nodes](https://dinerosinreglas.com/nodos/)
* [Six reasons you should run bitcoin node](https://bitcoinmagazine.com/culture/six-reasons-you-should-run-bitcoin-node
)
* [Podcast about what having a Bitcoin node does for me ](https://dinerosinreglas.com/que-me-aporta-el-tener-un-nodo-de-bitcoin/)
## Installation types
There are four ways to set up a Bitcoin node, I'm going to list them starting from easiest to hardest:
1. With plug & play software such as [Umbrel](https://getumbrel.com), [RaspiBlitz](https://raspiblitz.org), [Runcitadel](https://runcitadel.space) or similar.
These programs have installers for Raspberry Pi and can also run on PCs with a Linux system.
In the case of Umbrel and Runcitadel, install a Docker container with Bitcoin Core and the LND implementation of the Lightning network by default using Tor. Which makes it easy for non-technical users to run a node in a very simple way and with privacy by default.
2. Install from Docker containers. Which requires some more technical knowledge.
3. Installation from already compiled binaries. On bitcoin.org there are binary installers for various operating systems, it is a matter of downloading them and following the instructions.
4. Download the source code, compile it and install.
In this tutorial we are going to develop point 4, which can be challenging for non-technical people. If you are a technical or not-so-technical user but eager to learn, then this tutorial is for you.
As a requirement for this tutorial, you must have previously installed a version of Linux, in our case we are going to base it on Ubuntu, as it is a distribution widely used by the Bitcoin developer community and has a fairly extensive base of information and tutorials based on this distro.
## Install programs, libraries and dependencies
**Programs we need**
We are going to install these two programs that we will need later:
```shell
sudo apt-get install git curl
```
**Libraries and dependencies**
Now we need to install some libraries. When installing libraries, sometimes you can list many in a single command and separate them with a single space. In this tutorial, I divided them into groups similar to the build documentation on [Github for Debian/Ubuntu](https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md)
Run the following commands to install all the libraries that will help compile the bitcoind code and that will also be useful in case you want to use tools to learn how to develop.
```shell
sudo apt-get install build-essential autoconf libtool autotools-dev \
automake pkg-config bsdmainutils python3
sudo apt-get install libevent-dev libboost-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install libminiupnpc-dev libnatpmp-dev
sudo apt-get install libzmq3-dev
```
If you want to use GUI (graphical interface) to manage bitcoind you must install these libraries, if you are only going to use the command line it is not necessary.
```shell
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev \
qttools5-dev-tools
```
## Compile and install bitcoind
We verify that we are in the home of the current user:
```shell
CD ~
```
And we execute this command to download the code from the Bitcoin repository:
```shell
git clone https://github.com/bitcoin/bitcoin.git
```
Once the download is finished, we change to the `bitcoin` folder that was just created by executing the command:
```shell
bitcoin cd
```
We look at the tags to see the versions available with this command:
```shell
git tag
```
You can also look at the version of the latest release at this URL:
[https://github.com/bitcoin/bitcoin/releases](https://github.com/bitcoin/bitcoin/releases)

In this case we are going to go to the latest version, which is v26.2, for that we execute this command:
```shell
git checkout v26.2
```
**We install the Berkeley Database**
This is a database that is still needed to compile, possibly not needed in the future.
We install the Berkeley database with this command (remember that we must be in the bitcoin directory):
```shell
./contrib/install_db4.sh `pwd`
```
With the following command we export the path where the database was in an environment variable BDB_PREFIX, we will need this variable later (remember you must replace the user ***admon*** with your user).
```shell
export BDB_PREFIX="/home/admon/bitcoin/db4"
```
**We start the compilation process**
Now we are going to prepare the environment to compile the Bitcoin Core reference software, to do this we execute the following command:
```shell
./autogen.sh
```
The previous command created the configure script. Several parameters can be passed to this script to adjust to our needs.
In this case we are only going to pass the parameters to configure the Berkeley database that we already installed in a previous step.
```shell!
./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_FLAGS="-I${BDB_PREFIX}/include"
```
With this configuration you are going to use GUI (Graphical Interface) and you require the QT libraries. In case you don't want to use the GUI we can pass the parameter `--with-gui=no` and it would look like this:
```shell!
./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_FLAGS="-I${BDB_PREFIX}/include" --with-gui=no
```
If everything went well, the scripts to compile bitcoind should have been created.
If not, see which libraries were missing, install them and try again.
Now yes, let's compile, to do this we execute the command:
```shell
make -j$(nproc)
```
`make` can be executed without parameters and uses a single processor core, but if we use the `-j$(nproc)` parameter we will use all the cores we have in the processor so that the compilation is done in parallel and takes less time.
This process can take between an hour and an hour and a half, depending on the cores your PC has and the available memory. I recommend that you do not have many applications open.
At the end we can see an image similar to this:

If there were no problems, the compilation will have been created, so now we are going to proceed with the installation, executing the command:
```shell
sudo make install
```
The installation will leave a console output like the one seen in the following image:

This should install the bitcoind binary in the path:
`/usr/local/bin/bitcoind` as well as `/usr/local/bin/bitcoin-cli` and `/usr/local/bin/bitcoin-qt` in case you decided to install Bitcoin Core with the interface graphics (GUI).
## Configure the bitcoin.conf file
When bitcoind is run for the first time a `.bitcoin` directory is created on the user's home that contains the `bitcoin.conf` file.
Since we have not yet executed `bitcoind`, we are going to create the directory beforehand, to do this we execute these commands that will help us by creating the `.bitcoin` directory and we will change to the created directory:
```shell
mkdir ~/.bitcoin
cd ~/.bitcoin
```
Now we create the configuration file with any text editor I will use nano for simplicity:
```shell
nano bitcoin.conf
```
We are going to use a configuration to install a node that contains the complete history of the blocks, since although it could be a pruned node (a node that does not contain the entire history of the blocks), it is highly recommended to do it with a node that has all history and thus not penalize the performance and resource consumption of the node.
Many parameters can be added to the configuration file, but to simplify things we are only going to introduce a couple of lines that will indicate that we are going to use the testnet network.
```shell=
testnet=1
txindex=1
```
Before running `bitcoind` in the background, keep in mind that the testnet blockchain will begin to download, which at the time of creating this tutorial weighs approximately 50Gigas, which will take a few minutes.
## Run bitcoind and download the blockchain
Now run `bitcoind` as a daemon so that it runs in the background and starts downloading the blockchain:
```shell
bitcoind -daemon
```
To check the progress use this command:
```shell
bitcoin-cli getblockchaininfo
```
If we check very quickly it is likely that Bitcoin is still loading and verifying the index, so we could get an error message like the following:

Don't worry, wait a few more seconds you will have a result like the following:

The **verificationprogress** parameter will indicate the percentage of progress, when it reaches 0.99 it has already downloaded the complete blockchain.
If you've made it this far congratulations, you now have a Bitcoin node ready to use. This is the first pillar to start building your monetary sovereignty.