Home Getting started with Installation of IPFS CLI in Linux
Post
Cancel

Getting started with Installation of IPFS CLI in Linux

Command-line quick start of IPFS

If you’re command-line savvy and just want to get up and running with IPFS right away, follow this quick-start guide. Please note that this guide assumes that you’ll be installing go-ipfs, the reference implementation written in Go.

Don’t want to use the command line right now? Give the desktop-app implementation of IPFS a try. It also does all the steps listed on this page automatically, so you can run IPFS from the terminal later whenever you want.

Prerequisites & Dependencies

System requirements

IPFS requires 512MiB of memory and can run an IPFS node on a Raspberry Pi. However, how much disk space your IPFS installation takes up depends on how much data you’re sharing. A base installation takes up about 12MB of disk space. One can enable automatic garbage collection via --enable-gc and adjust the default maximum disk storage for data retrieved from other peers.

Official distributions

The IPFS team manages the dist.ipfs.io websiteto help users quickly find the latest version of every IPFS package. As soon as a new release of an IPFS package comes out, it is automatically shown on dist.ipfs.io, so you can be sure you’re getting the latest software. These steps detail how to download and install the latest go-ipfs from dist.ipfs.io using the command-line.

CLI Quick start for Linux

Download the Linux binary from dist.ipfs.io

1
wget https://dist.ipfs.io/go-ipfs/v0.11.0/go-ipfs_v0.11.0_linux-amd64.tar.gz

Unzip the file:

1
2
3
4
5
6
7
8
tar -xvzf go-ipfs_v0.11.0_linux-amd64.tar.gz

> x go-ipfs/install.sh
> x go-ipfs/ipfs
> x go-ipfs/LICENSE
> x go-ipfs/LICENSE-APACHE
> x go-ipfs/LICENSE-MIT
> x go-ipfs/README.md

Move into the go-ipfs folder and run the install script:

1
2
3
4
cd go-ipfs
sudo bash install.sh

> Moved ./ipfs to /usr/local/bin

Test that IPFS has installed correctly:

1
2
3
ipfs --version

> ipfs version 0.11.0

Initialize the repository

ipfs stores all its settings and internal data in a directory called the repository. Before using IPFS for the first time, you’ll need to initialize the repository with the ipfs init command:

Be careful with sudo on Unix platforms (including macOS)! If you run sudo ipfs init, the repository will be created for the root user instead of your local user account. IPFS doesn’t need root privileges, so it’s best to run all ipfs commands as a regular user!

1
2
3
4
5
6
7
8
ipfs init

> initializing ipfs node at /Users/jbenet/.ipfs
> generating 2048-bit RSA keypair...done
> peer identity: Qmcpo2iLBikrdf1d6QU6vXuNb6P7hwrbNPW9kLAH8eG67z
> to get started, enter:
>
>   ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

If you are running on a server in a data center, you should initialize IPFS with the server profile. Doing so will prevent IPFS from creating a lot of data center-internal traffic trying to discover local nodes:

1
ipfs init --profile server

The hash after peer identity: is your node’s ID and will be different from the one shown in the above output. Other nodes on the network use it to find and connect to you. You can run ipfs id at any time to get it again if you need it.

Now, try running the command suggested to you in the output of ipfs init. The one that looks like ipfs cat /ipfs/<HASH>/readme.

You should see something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Hello and Welcome to IPFS!

██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗  ███████╗
██║██╔═══╝ ██╔══╝  ╚════██║
██║██║     ██║     ███████║
╚═╝╚═╝     ╚═╝     ╚══════╝

If you see this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!

 -------------------------------------------------------
| Warning:                                              |
|   This is alpha software. use at your own discretion! |
|   Much is missing or lacking polish. There are bugs.  |
|   Not yet secure. Read the security notes for more.   |
 -------------------------------------------------------

Check out some of the other files in this directory:

  ./about
  ./help
  ./quick-start     <-- usage examples
  ./readme          <-- this file
  ./security-notes

You can explore other objects in the repository. In particular, the quick-start directory which shows example commands to try:

1
ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/quick-start

Take your node online

Once you’re ready to join your node to the public network, run the ipfs daemon in another terminal and wait for all three lines below to appear to know that your node is ready:

1
2
3
4
5
ipfs daemon

> Initializing daemon...
> API server listening on /ip4/127.0.0.1/tcp/5001
> Gateway server listening on /ip4/127.0.0.1/tcp/8080

Make a note of the TCP ports you receive. If they are different, use yours in the commands below.

Now, switch back to your original terminal. If you’re connected to the network, you should be able to see the IPFS addresses of your peers when you run:

1
2
3
4
5
6
ipfs swarm peers

> /ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
> /ip4/104.236.151.122/tcp/4001/p2p/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
> /ip4/134.121.64.93/tcp/1035/p2p/QmWHyrPWQnsz1wxHR219ooJDYTvxJPyZuDUPSDpdsAovN5
> /ip4/178.62.8.190/tcp/4002/p2p/QmdXzZ25cyzSF99csCQmmPZ1NTbWTe8qtKFaZKpZQPdTFB

These are a combination of/p2p/.

Now, you should be able to get objects from the network. Try:

1
ipfs cat /ipfs/QmSgvgwxZGaBLqkGyWemEDqikCqU52XxsYLKtdy3vGZ8uq > ~/Desktop/spaceship-launch.jpg

Using the above command, IPFS searches the network for the CID QmSgv… and writes the data into a file called spaceship-launch.jpg on your Desktop.

Next, try sending objects to the network, and then viewing it in your favorite browser. The example below uses curl as the browser, but you can open the IPFS URL in other browsers as well:

1
2
3
4
hash=`echo "I <3 IPFS -$(whoami)" | ipfs add -q`
curl "https://ipfs.io/ipfs/$hash"

> I <3 IPFS -<your username>

Cool, huh? The gateway served a file from your computer. The gateway queried the Distributed hash table (DHT), found your machine, requested the file, your computer sent it to the gateway, and the gateway sent it to your browser.

Depending on the state of the network, curl may take a while. The public gateways may be overloaded or having a hard time reaching you.

You can also check it out at your own local gateway:

1
curl "http://127.0.0.1:8080/ipfs/$hash"
1
> I <3 IPFS -<your username>

By default, your gateway is not exposed to the world. It only works locally.

Web console

You can view the web console on your local node by going to localhost:5001/webui.

This post is licensed under CC BY 4.0 by the author.