Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Local IPFS Daemon Basic Usage

Herman Junge edited this page Nov 18, 2016 · 1 revision

Getting The list of IPFS commands

To get a general list of commands, run ipfs help

$ ipfs help
USAGE
  ipfs - Global p2p merkle-dag filesystem.

  ipfs [--config=<config> | -c] [--debug=<debug> | -D] [--help=<help>] [-h=<h>] [--local=<local> | -L] [--api=<api>] <command> ...

SUBCOMMANDS
  BASIC COMMANDS
    init          Initialize ipfs local configuration
    add <path>    Add a file to ipfs
    cat <ref>     Show ipfs object data
    get <ref>     Download ipfs objects
    ls <ref>      List links from an object
    refs <ref>    List hashes of links from an object

  DATA STRUCTURE COMMANDS
    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes
    files         Interact with objects as if they were a unix filesystem

  ADVANCED COMMANDS
    daemon        Start a long-running daemon process
    mount         Mount an ipfs read-only mountpoint
    resolve       Resolve any type of name
    name          Publish or resolve IPNS names
    dns           Resolve DNS links
    pin           Pin objects to local storage
    repo          Manipulate the IPFS repository

  NETWORK COMMANDS
    id            Show info about ipfs peers
    bootstrap     Add or remove bootstrap peers
    swarm         Manage connections to the p2p network
    dht           Query the DHT for values or peers
    ping          Measure the latency of a connection
    diag          Print diagnostics

  TOOL COMMANDS
    config        Manage configuration
    version       Show ipfs version information
    update        Download and apply go-ipfs updates
    commands      List all available commands

  Use 'ipfs <command> --help' to learn more about each command.

  ipfs uses a repository in the local file system. By default, the repo is located
  at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable:

    export IPFS_PATH=/path/to/ipfsrepo

If you want the comprehensive list with explanation per command, visit this link

Init

If you haven't done so, you need to init your ipfs node, run ipfs init

$ ipfs init
initializing ipfs node at /data/ipfs
generating 2048-bit RSA keypair...done
peer identity: QmTF2vSfCBSYwA4c49aYKC2dTmi589e6GNMtyawu4173KR
to get started, enter:

	ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme

This will create the basic directories of your node. Let's take a peek

$ find /data/ipfs
/data/ipfs
/data/ipfs/config
/data/ipfs/version
/data/ipfs/blocks
/data/ipfs/blocks/CIQKK
/data/ipfs/blocks/CIQKK/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data
/data/ipfs/blocks/CIQBE
/data/ipfs/blocks/CIQBE/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data
/data/ipfs/blocks/CIQJ2
/data/ipfs/blocks/CIQJ2/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data
/data/ipfs/blocks/CIQOH
/data/ipfs/blocks/CIQOH/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data
/data/ipfs/blocks/CIQFF
/data/ipfs/blocks/CIQFF/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data
/data/ipfs/blocks/CIQII
/data/ipfs/blocks/CIQII/CIQIIB4QKMUK7JGD7KQWR6PULKQXKMUGMTODFNGSOPTPDDIK7HFLHNQ.data
/data/ipfs/blocks/CIQOZ
/data/ipfs/blocks/CIQOZ/CIQOZWVCEPB36XC36LJFIIN5L6PROTGKLLD356QXFTCQKOADH5SNP3I.data
/data/ipfs/blocks/CIQLS
/data/ipfs/blocks/CIQLS/CIQLSLFL22RXZF475I2T32YQS5AWFVQ6WA53KV2FEDRENXGQD3JWS2Q.data
/data/ipfs/blocks/CIQOY
/data/ipfs/blocks/CIQOY/CIQOYTOXB6FCZNIKH5KCVIRY5FKF2E4WJZ6FK4HTRZFCCUMMS347UGA.data
/data/ipfs/blocks/CIQOL
/data/ipfs/blocks/CIQOL/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data
/data/ipfs/blocks/CIQNP
/data/ipfs/blocks/CIQNP/CIQNPAT3XWQ3C22BDO3WDKV6JGD5YDZVNVZWB24EUZTQKXRW2DJUDWQ.data
/data/ipfs/blocks/CIQJF
/data/ipfs/blocks/CIQJF/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data
/data/ipfs/blocks/CIQJB
/data/ipfs/blocks/CIQJB/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data
/data/ipfs/blocks/CIQFT
/data/ipfs/blocks/CIQFT/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data
/data/ipfs/blocks/CIQNF
/data/ipfs/blocks/CIQNF/CIQNFAOBFUEMIDC4DIYMA7F2LX64IK5YD2WWXSG2ZYBPAPEFAJUZBQA.data
/data/ipfs/datastore
/data/ipfs/datastore/LOCK
/data/ipfs/datastore/CURRENT
/data/ipfs/datastore/LOG
/data/ipfs/datastore/000002.ldb
/data/ipfs/datastore/MANIFEST-000004
/data/ipfs/datastore/000003.log

We can see an old friend: LevelDB. Also the blocks there, are the default files' ones.

Let's check a default file, using the command ipfs cat given after the initialization

$ ipfs cat /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
Hello and Welcome to IPFS!

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

If you're seeing 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

Check configuration

We want to take a peek at the configuration. For that purpose we can just read the config file, or use ipfs config.

Reading the config file

The straightforward way: Dumps the whole config json

$ cat /data/ipfs/config ; echo
{
  "Identity": {
    "PeerID": "QmYAzVfQU33zW7N8Qsws12yF63NiMAVujVGGXdCxxVWzxw",
    "PrivKey": "CAASpwkwggSjAgEAAoIBAQCmqhQfWiK1HXRTgguBUN4Fl8U8g7ScctzqplinV0RDwkogqkEyUh7sqUthyemNAa5eq5MVAEWjwVWT7AfqsxC6n/TSigLCjCdi4YOqWet7qearj2zxIOPm42yXrM4C4rfVCOJWu7917KDl7CT2WvVMbNLQQyzbHf9w/12vY3KKtNg6c6pC3+6FqRox3IQY08igoajvrdBbDcNg/57xT1PT1d/JNybe1eNfDFgnj7kLU5s2KFvGjGL1/sd3XiwtHQc6G6HDf133zjyk7b3lihZDNyZep7oUT6Cvx0uU6wQmalh7iIxuTgvigcOxYJ21j7ymSKvXbl3RMMenEj/HJd3XAgMBAAECggEATDHxpSvGNltS9WK889AO0SvD5pioF+aDjVujqE3DTd8jmK99ww28SaJUbk6rUeX03B9AzRckv2sCPvBn5isbeNbsTNz/ygXdc916HoWhnRXd+Y1G1y6cQtCyst00Cimwtdqr789CBx25qaQ+ecq33srZzpEHjt22DOkS4b5rfXHXkp8uwnbbgvnZ4ZM83ZdJakJRGMntxSN5bMC22V7YYIkf2JaTsBCSa2EwyPA9drxnWuZr9pm6yVq8DasJDNyJPzCaLPH1+pgDQAH6eL25p990XYb4Mnzs7lZdWcjTV20O3rzQ0kJMihaEY2XEMuZYYEPdHL+IRGPeU5onVxS6wQKBgQDOOzdgKUOtVRwheXVZP8sdSg8KVJ4MFzFNnCqAh0PW9LUAPhZWDqzPEZZ5sbRMKsJ4i/YqK/oFMcOicM4/28zT1sGSfRl2IkHkzAeYhi9w+IVXBhZjgfeTvcdZo9nAS4pSWzXc2Zh3VW+7nY7SVBPaJV3mgkpJWv4IpdHlmHKrUQKBgQDO4nPMLeXAbj6zJEE+oQRfHHDKSoP/IAzvTIvzNtnU0DbuU8rpDlNVphEQSe5w75a0ln7CVUOg6hGS5mjnhEYvoYmWcok4IJ4DiIoNj/OZidfukzQSkJdig0YG5AKt2gRrZLIt2rXl7BtKEr3bGKp9pKWNKHdx89jw34PTcpdcpwKBgAXjPOZ65xq4tk/iVs5Qeu0AI0PJPKXdt6OelLwMoIwvekdifmLAkoBq4R/iSeJuyhSE8mcr0Dx7ujkV/V1nWgamN+qFtcdgnP76MDFTi2EvRyc/3j3DBR1rqphNjDboMS++uN/wOmEVyFXT3rL0gYiVzoN5LsO/XEdE7KQgYQ2xAoGAZ3JwOI5Sra/yhh0AytI0n2JXO6+a5P0fuqBp8klhDrq2XOFlOrfBD7ikG6L8KViD4PTHmWCNGm8wLmYr2mgXuEVryOCooHoeyOGDNljek82LPW45wXavW8EMSPHGLSwwvYpyVd9gyQEQfC9245En3v9vEHBFmaM2vOrmvdo0uU0CgYEAmLqs9eiIDehbJwgij7ElNxRkfJXkZ2rIZHfg3O91Ot/p5gtX0PYeK8AyDKGsTFDpsrEpC3Xa+IMiSrRScnQzhQG0AgUS1bMcdlDVQYrTXYKXsqFe173IxnGOrl/oIYOL8vIcFqkzg80Rsa95GsMxSDlCWd2A/BPH6kEmYZSZEUQ="
  },
  "Datastore": {
    "Type": "leveldb",
    "Path": "/data/ipfs/datastore",
    "StorageMax": "10GB",
    "StorageGCWatermark": 90,
    "GCPeriod": "1h",
    "Params": null,
    "NoSync": false,
    "HashOnRead": false,
    "BloomFilterSize": 0
  },
  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001"
    ],
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Gateway": "/ip4/127.0.0.1/tcp/8080"
  },
  "Mounts": {
    "IPFS": "/ipfs",
    "IPNS": "/ipns",
    "FuseAllowOther": false
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true,
      "Interval": 10
    }
  },
  "Ipns": {
    "RepublishPeriod": "",
    "RecordLifetime": "",
    "ResolveCacheSize": 128
  },
  "Bootstrap": [
    "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
    "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z",
    "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
    "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
    "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
    "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
    "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
    "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
    "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"
  ],
  "Tour": {
    "Last": ""
  },
  "Gateway": {
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "RootRedirect": "",
    "Writable": false,
    "PathPrefixes": []
  },
  "SupernodeRouting": {
    "Servers": null
  },
  "API": {
    "HTTPHeaders": null
  },
  "Swarm": {
    "AddrFilters": null
  }
}

Using ipfs config

More friendly, in my opinion, we can check the fields individually

$ ipfs config Datastore
{
  "BloomFilterSize": 0,
  "GCPeriod": "1h",
  "HashOnRead": false,
  "NoSync": false,
  "Params": null,
  "Path": "/data/ipfs/datastore",
  "StorageGCWatermark": 90,
  "StorageMax": "10GB",
  "Type": "leveldb"
}
$ ipfs config Datastore.Path
/data/ipfs/datastore

Bootstrap nodes

These are the default nodes to join the IPFS network

$ ipfs config Bootstrap
[
  "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
  "/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z",
  "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
  "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
  "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
  "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
  "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
  "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
  "/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"
]

Which we can check with ipfs bootstrap

$ ipfs bootstrap
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3

Say, we want to delete them. If we'd want to have our private IPFS network, this step is useful

$ ipfs bootstrap rm --all
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3

$ ipfs bootstrap list

$ ipfs config Bootstrap
null

To restore to default state

$ ipfs bootstrap add --default
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3

$ ipfs bootstrap list
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx
/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64
/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu
/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3

To add your list of nodes from a file bootstrap-node-list

$ cat bootstrap-node-list | ipfs bootstrap add 

Run the ipfs daemon

OK. Let's open a different console and run

$ ipfs daemon
Initializing daemon...
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.17.0.2/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

You can set verbosity up

$ env IPFS_LOGGING=info ipfs daemon
13:39:44.732  INFO   cmd/ipfs: IPFS_PATH /data/ipfs main.go:301
Initializing daemon...
13:39:44.751  INFO       core: Swarm listening at: [/ip4/127.0.0.1/tcp/4001 /ip4/172.17.0.2/tcp/4001 /ip6/::1/tcp/4001] core.go:613
13:39:47.528  INFO       core: bootstrapped with <peer.ID SoLer2> bootstrap.go:184
13:39:47.743  INFO       core: bootstrapped with <peer.ID aCpDMG> bootstrap.go:184
13:39:48.195  INFO       core: bootstrapped with <peer.ID SoLnSG> bootstrap.go:184
13:39:48.236  INFO       core: bootstrapped with <peer.ID SoLMeW> bootstrap.go:184
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.17.0.2/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
13:39:48.242  INFO core/serve: Using API.HTTPHeaders:map[] commands.go:50
13:39:48.242  INFO core/serve: Using API.HTTPHeaders:map[] commands.go:50

If you are a masochist, you can set IPFS_LOGGING to debug. Go for it, try it ;-)

Check connected peers

We have the daemon running. So what? Well, let's check our connected peers

$ ipfs swarm peers
/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ
/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z
/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
/ip4/104.236.229.101/tcp/4001/ipfs/QmNgrpuEzFXfGmRXcXLxPZf1vZdaFjgGnNPQ15cvgHb2Si
/ip4/139.198.2.16/tcp/4001/ipfs/QmcCNWSabBhCBiqU5EoGcWsMc3weUEHiFpZ3nKTKHjJPJc
/ip4/144.76.172.110/tcp/4001/ipfs/QmVTbKWCp7p8RTgp2jh1wbSfUAEdo5sWPSteUiSts35VJW
/ip4/163.172.155.45/tcp/4001/ipfs/Qmakazk9ZqDRtAkoRFtoeiCmnwRPBJ1DgNVZNog9zCnKp9
/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd
/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3
/ip4/185.21.216.182/tcp/4001/ipfs/QmXhdpwYaskZKR4znvaftTUXzREp4H3i9zwWLfCuvHwAsR
/ip4/185.32.221.138/tcp/4001/ipfs/QmXEA7k2ik6gXTSDRGxTwaAm9r1H6gMCnPKa4bx4h7pNUi
/ip4/185.35.184.12/tcp/4001/ipfs/QmVgLEM2o96fnrLZK3Tzr7w1qid7gPw3npJXYQMKyRssSc
/ip4/188.165.249.210/tcp/4001/ipfs/QmQZic978SS1i35BckSLzzKotXdRTac4LNcwQ1SxTc6HZe
/ip4/188.40.114.11/tcp/4001/ipfs/QmZY7MtK8ZbG1suwrxc7xEYZ2hQLf1dAWPRHhjxC8rjq8E
/ip4/192.81.218.29/tcp/4001/ipfs/QmU355SfH2H2RdkQXQciLucFKMnpQBvpFnzUd9LFyEHxYi
/ip4/198.211.118.157/tcp/4001/ipfs/QmXWEhAyd5N3g9aAziRWR6q6gjaoU328yZzPWub4iVNeCC
/ip4/37.187.116.23/tcp/4001/ipfs/QmbqE6UfCJaXST3i65zbr649s8cJCUoP9m3UFUrXcNgeDn
/ip4/67.84.161.250/tcp/4001/ipfs/QmRfvckFHNSTHFrVwRCd8svQ6mRm7dFXLYBwbUJVQQXHbY
/ip4/75.127.23.122/tcp/37479/ipfs/QmeQGvYhXZC4Kt3TGeNUfbXGq5XWdgipyF6nSdNkcRLaaE
/ip4/84.22.115.40/tcp/4001/ipfs/QmfPZcnVAEjXABiA7StETRUKkS8FzNt968Z8HynbJR7oci

If you've been paying attention, you can recognise some of the bootstrap nodes in this list.

So, we are connected! That means two things:

  • If we add a file, we can retrieve it (provided we know its hash) from any node connected to the network.
  • We can retrieve any file from the network using ipfs cat.

Add a file

We have this file we just created

$ cd /tmp

$ date > my-file

$ cat my-file
Thu Nov 17 14:07:28 UTC 2016

Let's add it using ipfs add

$ ipfs add my-file
added QmfJ1ezKNPefT1Edqb6vMapqjZGjvv2WeYA5SNDGCXumy4 my-file
```

It was successfully added, and the daemon returned us a hash.
In this case is `QmfJ1ezKNPefT1Edqb6vMapqjZGjvv2WeYA5SNDGCXumy4`

Let's ask the daemon for this file

$ ipfs cat QmfJ1ezKNPefT1Edqb6vMapqjZGjvv2WeYA5SNDGCXumy4 Thu Nov 17 14:07:28 UTC 2016


Cool, is there. Let's see if we can retrieve this file from the IPFS Network.
(Which is the whole point of this system).

We could open up a browser and ask for the route
`https://ipfs.io/ipfs/QmfJ1ezKNPefT1Edqb6vMapqjZGjvv2WeYA5SNDGCXumy4`,
But, since we are on the console, let's use `curl`

```
$ curl https://ipfs.io/ipfs/QmfJ1ezKNPefT1Edqb6vMapqjZGjvv2WeYA5SNDGCXumy4
Thu Nov 17 14:07:28 UTC 2016
```

Works!

### Some observations after `add`ing a file

* We asked the file to `ipfs.io`. This gateway won't store the file, only relay it.
* You `add`ed the file, however, if you turn the daemon off, since nobody else stored it, this file will be unavailable. Files need to be `pin`ned ([see this link](https://ipfs.io/docs/commands/#ipfs-pin), in order to be persisted and be resilient to unavailable nodes.
* Last, but not least. If your daemon has garbage collection enabled `--enable-gc`, you risk losing this very file from your machine (rendering unavailable). You need to `pin` it to persist it forever.

### That's it!

This basic run leaves you armed with the necessary knowledge to keep going forward. Check the documents, try to play with every command, and enjoy, helping making the web to be really decentralized!