explicitClick to confirm you are 18+

Tutorial: IPFS - Linux Install

museJun 17, 2018, 8:41:12 PM
thumb_up49thumb_downmore_vert

For a Conceptual Introduction with no code see the blog IPFS - Introductory Concepts. For all my Tutorials that include code, I will attempt to package it into a one line script to make it simple to execute.

Installation and Use of IPFS with Linux


This tutorial is to explain how to setup an IPFS node on a Linux OS. It should work immediately with no modification needed with either Debian based distributions or CentOs. Please let me know if it doesn't work on your system.

For aesthetic value and readability, I will provide an explanation of what needs to be done, accompanied by a screenshot of code and a link to the whole script here. But please don't pipe to your root shell, that's silly.


Installing IPFS

1. Checking for your architecture to download the correct binary
2. Updating
3. Downloads the IPFS binary
4. Installing and initializing IPFS
5. Installing a SystemD Daemon Service
6. Starting and Enabling SystemD Daemon Service

Using IPFS

1. Adding
2. Accessing

Installing IPFS

1. Checking Architecture

The IPFS code offers versions for both 32bit and 64bit architecture. This first section of code is to check your architecture and store it in the variable architecture to be used later so that you can download the correct version automatically.

2. Checking OS and Updating

This section of the script checks to see which OS you are running, it only checks for CentOs and Debian at the moment, it could be improved. But this should work for all Debian based Operating Systems plus CentOs. This is only necessary to decide which update command to use.

3. Downloading IPFS Binary

This section might look a little complicated, but all it's doing is manipulating a string to construct the correct URI for downloading the IPFS binary based on your system architecture, and then using the curl command to download it.

4. Installing the IPFS Binary

First we unzip the file we just downloaded, then move into that directory and install it. Before you can use IPFS, it must be initiated first, this creates a directory in your home folder to store the files that you upload to it, and also a configuration file.

5. Installing a SystemD Daemon Service

This section of code sets up an IPFS systemD daemon. A daemon is an application that runs in the background which you can set to always start up at boot time and to which you can add special firewall settings.

6. Starting and Enabling SystemD Daemon Service

The final step is starting and enabling the daemon that you installed in the step above. Starting a daemon makes the program start now. Enabling a daemon sets the program to start automatically at boot time without you needing to prompt it to start.

Using IPFS

1.  Adding

After you have followed through this script, IPFS should start up automatically on reboot. You can then add files to be served on the IPFS network by typing the first line in the image below, but with the name of the file you want to add replacing test_directory/test_file1.

ipfs add <test_file>


If you want to add an entire directory, include an -r flag to recursively add all files in a directory and sub-directories.

ipfs add -r <test_directory>

2. Accessing

You can access files on the IPFS network either through an HTTP to IPFS gateway, or directly on the IPFS Network. The most well known HTTP gateway is https://ipfs.io.

To get a file from an HTTP gateway, you can visit the URI below in your browser:
https://ipfs.io/ipfs/<hash>.
For example, to get the header image of this blog you can visit the URI below.
https://ipfs.io/ipfs/QmbB7Z8xVTLNrhiCWSHZ7me3MjzTXNhvcJi81Stio56akr

To get a file directly from IPFS, type:
ipfs get <hash>.

ipfs get <hash>