Installing geth on ubuntu 16.10

Geth is the the command line interface for running a full ethereum node implemented in Go. I am going to be talking about how to install geth on ubuntu on 16.10.




Lets check out the ubuntu version....

geth1



It is good to avoid root user to install or run the softwares on linux for security reasons. So i have setup an exclusive user to carry out the installation of geth and run it.

geth2



Now lets prepare the dependency required to run geth. As i mentioned above geth is written in GO. So i am going to install GO run time

Download Go anywhere you like on your system , in my case i have downloaded in my home folder

curl -O https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz

geth3



Unpack it to folder where you want to install it, in my case i have created a directory where i am going to install geth and Go.

tar -C /ethereum -xzf go1.7.3.linux-amd64.tar.gz

geth4



set GOPATH and PATH

export GOPATH=/{your geth home directory}

export PATH=$PATH:{your geth home directory}/bin

in my case its

export GOPATH=/ethereum/go

export PATH=$PATH:/ethereum/go/bin



Building geth requires Go and C compilers to be installed:

sudo apt-get install -y build-essential golang




Now all the dependencies takes care off, lets clone the Geth software and build it.
switch to directory where you want to install geth , in my case its

geth5

After cloning is complete

cd go-ethereum

make geth



After build id complete you can go to "/go-ethereum/build/bin" and start geth node ..

./geth



I have put together a script that will ensure all the required variables are set before starting the node and generate the blocks in the directory you like.
open the editor of your choice and put this code, modify the paths according to your local installation.

#!/bin/bash
export GOPATH=/ethereum/go
export PATH=$PATH:/ethereum/go/bin
echo "strating............."
/ethereum/go-ethereum/build/bin/geth  --rpc --rpccorsdomain "*" --datadir /ethereum/blocks 2>> /ethereum/logs/ethereum.log

Do not forget to give execute permission on file

chmod +x script_name.sh

I am going to run geth as background process, i have installed daemon for me to be able to run the process in background.

you can install "daemon" on ubuntu

apt-get install daemon

Now all set to start the geth node...................................................................

daemon /home/ethereum/start-geth.sh

and you can tail the log to see the progress of start process....

geth6



Since we are running geth as background process, if we need to attach to geth in interactive mode , use the following command

/ethereum/go-ethereum/build/bin/geth attach ipc:/ethereum/blocks/geth.ipc

geth7

Subscribe to EtherWorld.co