[closed] How to install bitcoind in linux

Need step-by-step instruction on install bitcoind on linux debian

  • Autostart on server reboot
  • Monitor for crashes & restart
  • Run as user not root
  • Anything important that missing

Thank you!

asked 11 Apr '13, 05:39 bitcoind 263 bitcoind's gravatar image
closed 13 Apr '13, 17:10

Since user doesn't need to be as root, following should do but use some caution:

http://serverfault.com/questions/11270/installing-software-on-linux-without-root-privileges

Create a normal account:

adduser username

If user is already in then following should do but again use some caution!

right way:

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

modern version:

## Allows people in group sudoers to run all commands
%sudoers ALL=(ALL)       ALL

that user should to install bitcoind using code as seen on below link:

http://wp.geeklab.com.ar/gl-en/2013/03/04/how-to-install-bitcoin-0-8-0-on-debian-squeeze/

Does this answer?

(11 Apr '13, 06:34) splat44 splat44's gravatar image

go to this page

http://bitcoin.org/en/download

click the "Download for Linux (tgz, 32/64-bit) "

(11 Apr '13, 10:39) stephen02 stephen02's gravatar image

But how to run as service, so it start when rebooted? Also for crash?

(11 Apr '13, 14:50) bitcoind bitcoind's gravatar image

And all from command line, no clicks

(11 Apr '13, 14:52) bitcoind bitcoind's gravatar image

which version of debian? because the procedure can be slight different if it is debian stable (squeeze), testing (wheezy) or sid. Also, do you need absolutely the last version of bitcoind or are you ok with an older but tested version?

(11 Apr '13, 18:23) Joif Joif's gravatar image

debian 6 ideally latest version of bitcoin at least .8

(11 Apr '13, 18:37) bitcoind bitcoind's gravatar image
showing 5 of 6 show all

The question has been closed for the following reason "0bc won 10.00 mBTC for the best answer." by bitcoind 13 Apr '13, 17:10


bitcoind installation : default APT version

Debian's APT will install the version that matches the latest in the local listings of the repositories for your current Debian release. To check your release version:

cat /etc/debian_version

Anything 6.0.X is Debian Squeeze. Particularly if you're running Debian Squeeze, the most recent version in the repositories will not be the most recent bitcoind version itself. Though there is a bit of a controversy in this, the idea is to make Debian Squeeze as stable and secure as it gets - so security updates will be rolled back, but otherwise it's a pretty old bitcoind. The version for Debian Stable is currently 0.3.24, which is ancient - July 2011. Still, there are quite recent security patches for that version, which would indicate that like other software there will be security patches to come for a long time for versions 0.4 up to 0.8, and normal bugs as well.

If you're running Squeeze and want to install a newer version than 0.3.24, ask me about that (it involves work like APT package pinning, building backports or building from source). Otherwise, if you like to stay on the stable & secure side ;] - read on!

To make sure that you have the right repositories and up to date repository lists, check

apt-cache policy bitcoind

If you are running Squeeze, that should show:

bitcoind:
  Installed: 0.3.24~dfsg-1~bpo60+1
  Candidate: 0.3.24~dfsg-1~bpo60+1
  Version table:
 *** 0.3.24~dfsg-1~bpo60+1 0
        100 http://backports.debian.org/debian-backports/ squeeze-backports/main i386 Packages
        100 /var/lib/dpkg/status

The line starting with *** shows the currently installed version. If it shows anything else while you're running Squeeze, then you need to update your repositories. If the output doesn't show backports.debian.org at all, then you need to add the following line to /etc/apt/sources.list:

deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free

If you already have a backports.debian.org line in /etc/apt/sources.list, then the APT repository list is out of date. There are packages that can keep them automatically up to date, for instance cron-apt:

apt-get install cron-apt

Manually, you can update the lists with:

apt-get update

And of course upgrade packages with:

apt-get upgrade
apt-get dist-upgrade

and then install/upgrade bitcoind and its dependencies:

apt-get install bitcoind

Updating the lists with apt-get update is generally necessary when you change /etc/apt/sources.list or want to make sure you're getting the latest version of everything.

To check the currently installed bitcoind version, you can do any of the following:

bitcoind --help | head -n1
dpkg -l bitcoind
apt-cache policy bitcoind

bitcoind setup

Try dpkg -L bitcoind to see all the files that came with bitcoind. It's really just bitcoind, the binary, and some help files.

For general information see /usr/share/doc/bitcoind/. The most important files there are README.Debian and the directory "examples". README.Debian informs you of a Debian-specific configuration file that you can store per user in ~/.bitcoin/bitcoin.conf. In examples is just one file, bitcoin.conf, but as minimal as it is, there are a lot of comments there that can help you get a leg up. Run "man bitcoind" and bitcoind --help to get deeper into the configuration.

After creating your configuration file to your liking, log in as your non-root bitcoin user (from root: login -f username) and store the bitcoin.conf file in the user's ~/.bitcoin/ directory (mkdir ~/.bitcoin/ if it doesn't exist yet). Then test by just running bitcoind; there's not much output, but you can open another terminal and run tail -F ~/.bitcoin/*log for a barrage of information. Ctrl-C to abort so you can try with different settings; then, when you're done testing, put it in your crontab:

crontab -e # to start editing your crontab file

then, enter a line like this:

@reboot /usr/bin/bitcoind

Then save & exit to store the new crontab file. That @reboot line will start bitcoind under your user at every reboot.

If you don't want to reboot yet, put bitcoind to your background:

bitcoind &

Then you can log out and it will keep running nicely in the background, until you reboot at which point the crontab line kicks in and starts it again.

Logfiles described at https://en.bitcoin.it/wiki/Data_directory#Files are all in ~/.bitcoin/.

Monitoring can be done in various ways - I think the easiest would be to add another crontab line that checks whether it's still running and if not just start it again:

crontab -e

Add line:

* * * * * (pgrep bitcoind > /dev/null) || /usr/bin/bitcoind

This checks every minute (of every hour of every day of the month of every month & and every day of the week) whether there still is a process running named bitcoind, routes the output to /dev/null so it doesn't send you a mail when it does, and then starts bitcoind if it didn't find it. The cron daemon will send the bitcoin user error mails if something goes wrong.

You can stop bitcoind when it's running in the background with pkill bitcoind or bitcoind stop.

bitcoind usage : API calls

Whoops. I was amiss to omit this part; it is more or less the most important part .. To get information from bitcoind, you can use its API commands described at https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list . I think the most important ones are the following:

bitcoind help # show all API commands - note! this is different from bitcoind --help
bitcoind help <API command> # show more help about an API command
bitcoind getinfo # get bitcoind status    
bitcoind getbalance [account name] # show total balance or account's balance if name is supplied    
bitcoind listaccounts # list all accounts (labels with addresses) + balance currently in bitcoind
bitcoind getnewaddress <name> # set up an account with a new bitcoin address
bitcoind getaddressesbyaccount <name> # get bitcoin address for account named <name>
bitcoind validateaddress <address> # validate bitcoin address
bitcoind listtransactions # list transactions
bitcoind listreceivedbyaccount # list bitcoins income per account
bitcoind sendtoaddress <bitcoinaddress> <amount> # send bitcoins
bitcoind stop # will take a while to shutdown

A nice way to keep an eye on these API calls is to use watch:

    watch -n10 "echo General Info; bitcoind getinfo; printf \\\\nBalance\\\\n; bitcoind listaccounts; printf \\\\nTransactions\\\\n; bitcoind listtransactions; printf \\\\nIncome\\\\n; bitcoind listreceivedbyaccount"
link
answered 11 Apr '13, 22:22 0bc 563 0bc's gravatar image
edited 12 Apr '13, 08:35

Very good, will this install latest version?

(11 Apr '13, 23:23) bitcoind bitcoind's gravatar image

I appended a section on bitcoind version. In short, if you're running Squeeze it will at most install 0.3.24, so you would need to employ other methods to get a more recent version - but there would be drawbacks.

(11 Apr '13, 23:52) 0bc 0bc's gravatar image

Moved the APT version section up and added a usage section to make the flow more logical.

(12 Apr '13, 08:20) 0bc 0bc's gravatar image

Need latest version, hard fork coming http://bitcoin.org/may15.html

(13 Apr '13, 15:36) bitcoind bitcoind's gravatar image

I would like to add some info on the setup.

Usually I prefer to use the packages in the debian repositories. The latest version of bitcoind, as you requested, is in the experimental repository, but it is not recommended to use it with debian squeeze. So I suggest you to consider debian 7 (wheezy), it is the current testing but it is imminent to be released as the next stable, and should have less or no problem at all with bitcoind from the experimental repository.

Here the step-by-step setup. Follow the procedure as root, or as user but use sudo when needed. I'll use sudo here.

1) Add the experimental repository to get the latest version of bitcoind. To do so, run nano (or your preferred text editor) to open the sources.list:

sudo nano /etc/apt/sources.list

and add to the end of the file the following line:

deb http://ftp.us.debian.org/debian/ experimental main

save and exit.

2) Run the update:

sudo apt-get update

3) Install bitcoind from the experimental repo:

sudo apt-get install -t experimental bitcoind

4) comment out the experimental repo line in sources.list.

To run bitcoind, you can do as stated in the previous message, or do what follow.

5) To run bitcoind at the startup, add it to /etc/rc.local, use nano or your text editor:

sudo nano /etc/rc.local

add the string "bitcoind" before "exit 0", like this:

[...]

# By default this script does nothing.

bitcoind

exit 0

save and exit.

At the next reboot you should have bitcoind running.

For the monitoring and other actions, what stated in the previous message should be very complete.

link
answered 12 Apr '13, 11:31 Joif 212 Joif's gravatar image

Hi.

The first step is to install bitcoind which can be done by running the command:

sudo apt-get install bitcoind

Once bitcoind is installed you will want to create a script that runs bitcoind on bootup. To do this simply create a file, let's call it bitcoind.sh. In bitcoind.sh you will want to put simply:

#! /bin/bash

# /etc/init.d/bitcoind.sh

echo "Starting bitcoind"

bitcoind -daemon

Note that you can add -generate if you wish to mine (bitcoind -daemon -generate)

After saving the bitcoind.sh run the command:

chmod a+x bitcoind.sh

This command allows bitcoind.sh to be e[X]ecuted by [A]ll users. Next move bitcoind to the startup scripts directory. You can do so by running the command:

sudo mv bitcoind.sh /etc/init.d/

Next add bitcoind.sh to startup. You can do so by running:

update-rc.d bitcoind.sh defaults

Now to make sure that it will restart if it bitcoind crashes. I am not very fluent in bash scripting so instead I will write you a script to do so in python. I am not sure if you want to restart the entire computer if bitcoind stops/crashes or if you simply want to start bitcoind again. You said that you want it all to be run as non-root, and shutting down/restarting/switching runlevels requires root, so I will write you a script that auto-restarts bitcoind in the event of a crash. If you wish to restart the computer (needs root) it should be quite easy to modify to your liking.

Here is a script that checks if bitcoind is still running/has not crashed and starts it again if bitcoind crashes. Please note that I am using Python3 syntax and this will need to be run with Python3 (Instead of 2.7)

Here is a link to the script, as the formatting on here makes it hard to write code.

http://pastebin.com/f3NbhG7C

Copy and paste the script from pastebin to a file, let's call it autorestart.py. After saving autorestart.py, put it somewhere such as your home directory (/home/bob/autorestart.py). Next make a startup script for autorestart.py. Create a shell script and put the following into it.

#! /bin/bash

# /etc/init.d/autorestart.sh

echo "Starting bitcoind auto-restarter"

python /home/bob/autorestart.py

Then repeat the same steps that you did to bitcoin.sh to autorestart.sh by running chmod a+x autorestart.sh, moving it to /etc/init.d: mv autorestart.sh /etc/init.d/, and once again adding it to startup with update-rc.d autorestart.sh defaults. After doing all of these steps, you should have a fully functioning bitcoind server thing.

Good Luck!

link
answered 12 Apr '13, 21:12 QuestionAn... 111 QuestionAnswerer's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×3

Asked: 11 Apr '13, 05:39

Seen: 1,824 times

Last updated: 13 Apr '13, 17:10



Bitcoin forums:
Bitcointalk.org
p2p Bitcoin forum
Bitcoinforum.com

Blogs and press:
elBitcoin.org (ES)
Que es bitcoin.info (ES)
bitcoinInformant.com
bitcoinmagazine.net

Partners:
Bitcoinerr.com
ogrr.com
The Unoff. Bitcoin Forum