Cover photo

Setting up a Linea node on Ubuntu/Arch

Welcome Voyager! So you want to run a Linea node yourself? Of course you are.

As a passionate member of the Linea community, Running a node is a great way to help Linea achieve its final destination in the voyage, Decentralization.

And as a plus, you will no longer have to depend on a 3rd party node and will be able to sign your transactions through your own node.

Please note that this is a more simplistic and a generic approach to help you have your node up & running in the shortest possible time. If you want to run your node on a Raspberry Pi or looking for a more detailed explanation, please refer this amazing guide by Pieter.

So let’s start!

Prerequisites

  • A system running on Ubuntu(preferably 22.04) or Arch Linux.

  • Please refer this guide for hardware requirements. As a general rule, It’s recommended to have minimum 8Gb of RAM, Or 16Gb for the optimal experience.

  • An SSD drive with at least 100Gb space, more if you want to future-proof your node

  • A stable & reliable internet connection with at least +25Mbps speed.

Once you have everything ready, grab a coffee & get to work! ☕️

*Note that the commands starting with # are run as root, and those with $ as normal user.

First thing first, Let’s update our system.

Ubuntu

# apt update && sudo apt upgrade

Arch

# pacman -Syyu

And grab the necessary tools.

  • We need Geth, The official golang implementation of the Ethereum protocol.

    Ubuntu

    # apt install software-properties-common

    # add-apt-repository -y ppa:ethereum/ethereum

    # apt update && apt install ethereum

    Arch

    # pacman -S go-ethereum

  • Let’s also get micro, a text editor that will come in handy later. We will also get screen, a screen multiplexer that will help us run our node in background. And wget, a handy tool to download stuff easily.

    Ubuntu

    # apt install screen micro wget

    Arch

    # pacman -S screen micro wget

Now let’s download Linea genesis.json

$ wget https://docs.linea.build/files/genesis.json

  • And bootstrap the node using our genesis file

    $ geth --datadir ./geth-linea-data init ./genesis.json

We will have to execute a long command in order to start our node. So let’s create a simple script to make future editing+life easier, and avoid having to type it again.

Let’s create a file named LineaNode.sh in our home directory, we will be using micro editor we got previously.

$ micro ~/LineaNode.sh

Now copy paste the below command,

#!/bin/sh

geth \

--datadir ./geth-linea-data \

--networkid 59144 \

--rpc.allow-unprotected-txs \

--txpool.accountqueue 50000 \

--txpool.globalqueue 50000 \

--txpool.globalslots 50000 \

--txpool.pricelimit 1000000 \

--txpool.pricebump 1 \

--txpool.nolocals \

--http --http.addr xxx.xxx.xxx.xxx --http.port 8545 --http.corsdomain '*' --http.api 'web3,eth,txpool,net' --http.vhosts='*' \

--ws --ws.addr 127.0.0.1 --ws.port 8546 --ws.origins '*' --ws.api 'web3,eth,txpool,net' \

--bootnodes "enode://ca2f06aa93728e2883ff02b0c2076329e475fe667a48035b4f77711ea41a73cf6cb2ff232804c49538ad77794185d83295b57ddd2be79eefc50a9dd5c48bbb2e@3.23.106.165:30303,enode://eef91d714494a1ceb6e06e5ce96fe5d7d25d3701b2d2e68c042b33d5fa0e4bf134116e06947b3f40b0f22db08f104504dd2e5c790d8bcbb6bfb1b7f4f85313ec@3.133.179.213:30303,enode://cfd472842582c422c7c98b0f2d04c6bf21d1afb2c767f72b032f7ea89c03a7abdaf4855b7cb2dc9ae7509836064ba8d817572cf7421ba106ac87857836fa1d1b@3.145.12.13:30303" \

--syncmode full \

--metrics \

--verbosity 3

  • Note the xxx… part in the 12th line, we will need to replace it with your public IP.

    A simple command to get your public IP would be,

    $ wget -qO - ifconfig.me

    Or,

    $ curl https://ipinfo.io/ip

    Now save the script using Ctrl+s and exit with Ctrl+q, And make the script executable.

    $ chmod +x LineaNode.sh

Now that we have everything in place. it’s time to start our node.

Start by opening a screen session through terminal, and run the script.

$ screen

$ ./LineaNode.sh

Now your node will start looking for peers and begin to synchronize with the Linea blockchain and download block data. Note that the full syncing process will take some time depending on your internet speed, and you will have a complete copy of the Linea block data in ~/geth-linea-data folder by the time this is complete (Around 14Gb at the time of writing)

Node syncing
Node syncing

We can see that our node has started downloading block data back from ~4 months, where Linea mainnet went live.

Now that the syncing process is ongoing, we can safely detach our screen session. To do that, press Ctrl+A followed by D, and you will return to your terminal.

Now let’s wait around 24h ⏳

Welcome back, It’s time to check how our node is doing. Let’s open our terminal.

  • To open the screen session that we detached previously. we need to find its identifier.

    $ screen -ls

  • You will see something like 266.pts-0.thisu. open your screen instance using the following command, replace instance id with your own.

    $ screen -r 266.pts-0.thisu

    If everything went well, It should look like below. Note how the number* parameter is similar to the current block number that you can find at Linea block explorer.

Node up and running
Node up and running

Voila! Our node has finally completed syncing with the Linea blockchain and now you are part of the journey towards decentralization. 🌟

Now that our node is up running, It’s time to explore the Linea ecosystem with our own node.

  • Let’s switch to our node in Metamask, Go to Settings > Networks > Add Network and select Add a network manually, and fill as follows

-Network name: Linea My Node (Anything you prefer)

-New RPC URL: http://xxx.xxx.xxx.xxx:8545 (Edit with your own public IP)

-Chain ID: 59144 (For Linea Mainnet)

-Currency symbol: ETH

-Block explorer URL: https://lineascan.build

Some final notes:

  • If you come across any port related issues while setting up your node, you may want to open the specific ports through your router config.

  • By default, port 30303 is used to connect with other nodes. If that port is occupied or in case you want to use other ports, please pass it like below,

    --discovery.port VALUE

  • If you are planning on setting up your node on a headless server and run commands through SSH, the process would mostly be the same. In that case, you may create the ssh key on your PC using something like,

    $ ssh-keygen -t rsa -C "thisu@linea"

    • And push your public key to server in order to enable SSH access without password

      $ ssh-copy-id -i ~/.ssh/id_rsa.pub USER_NAME@IP_ADDRESS_OF_THE_SERVER

    • We can also copy our LineaNode.sh script to the server,

      $ scp LineaNode.sh USER_NAME@IP_ADDRESS_OF_THE_SERVER:/root/

    • You may also want to open ports for SSH access

      # iptables -I INPUT -m tcp -p tcp --dport 22 -j ACCEPT

    • And connect to the server.,

      $ ssh -i ~/.ssh/id_rsa USER_NAME@IP_ADDRESS_OF_THE_SERVER

And that sums it up. Congratulations on setting up your own node and becoming part of this exciting voyage. We hope that you continue to run your node and help Linea on Its path toward decentralization, and beyond. 💙

Keep an eye on Linea documentation on any future updates in regards to nodes.

If you come across any trouble setting up a Linea node, you may ask at Linea Community Forum here or open a ticket at the support page.

And hop over to Linea discord.

And finally, If you found this helpful, feel free to mint this entry as an NFT on Linea. 💖