LinuxCommandLibrary

ipfs

Store and share content using IPFS

TLDR

Add a file from local to the filesystem, pin it and print the relative hash

$ ipfs add [path/to/file]
copy

Add a directory and its files recursively from local to the filesystem and print the relative hash
$ ipfs add -r [path/to/directory]
copy

Save a remote file and give it a name but not pin it
$ ipfs get [hash] -o [path/to/file]
copy

Pin a remote file locally
$ ipfs pin add [hash]
copy

Display pinned files
$ ipfs pin ls
copy

Unpin a file from the local storage
$ ipfs pin rm [hash]
copy

Remove unpinned files from local storage
$ ipfs repo gc
copy

SYNOPSIS

ipfs [global options] [command options] [arguments]
ipfs daemon [options]
ipfs init [options]

PARAMETERS

--api <address>
    Specifies the API server address to connect to (e.g., /ip4/127.0.0.1/tcp/5001).

--encoding <type>
    Sets the encoding type for API responses (e.g., json, xml, csv). Defaults to json.

--json
    Forces the output to be JSON format, overriding default encoding.

--timeout <duration>
    Sets a timeout for the command execution (e.g., 5s, 1m, 1h).
A global option that applies to all commands.

--debug
    Enables verbose debug messages for troubleshooting purposes.

--help
    Displays help information for the main ipfs command or a specific subcommand.

DESCRIPTION

The ipfs command-line interface provides tools to interact with the InterPlanetary File System (IPFS) daemon. IPFS is a peer-to-peer network and protocol designed to create a permanent, decentralized method of storing and sharing files. It utilizes content-addressing, meaning each file is uniquely identified by its cryptographic hash, rather than its location. This allows content to be retrieved from any node that stores it, enhancing resilience against censorship and improving efficiency for distributed content delivery.

The ipfs command enables users to perform a wide range of operations, including adding files to their local IPFS repository (e.g., ipfs add), retrieving content from the network (e.g., ipfs get, ipfs cat), managing their local IPFS node, interacting with other peers, and administering the IPFS daemon (e.g., ipfs daemon, ipfs init). It is a fundamental tool for engaging with the decentralized web.

CAVEATS

Most ipfs commands require a running IPFS daemon in the background, which can consume significant system resources (CPU, RAM, disk I/O, and network bandwidth). Content added to IPFS is not automatically made permanent across the network; it must be explicitly 'pinned' (e.g., with ipfs pin add) to ensure other nodes retain it and prevent garbage collection. The decentralized nature means performance can vary based on network conditions and the availability of peers hosting the desired content.

CONTENT ADDRESSING VS. LOCATION ADDRESSING

Traditional web protocols like HTTP address content by its location (where it's stored on a server). IPFS, conversely, addresses content by its cryptographic hash (what it is). This fundamental difference makes IPFS content immutable, verifiable, and enables distributed retrieval, as any node with the content can serve it.

DISTRIBUTED NETWORK

IPFS operates as a distributed peer-to-peer network. Data is fragmented and stored across multiple nodes, enhancing availability and resilience. When you request content, the network identifies which peers have the data and retrieves it directly from them, rather than from a single central server.

HISTORY

IPFS was conceptualized and designed by Juan Benet at Protocol Labs in 2014. The first Go implementation was released in 2015, quickly gaining traction within the decentralized web community. It aims to complement or potentially replace HTTP for certain use cases, offering a more resilient and censorship-resistant way to distribute content. Over the years, ipfs has become a foundational technology for many Web3 applications, decentralized storage solutions, and content delivery networks, continuously evolving with contributions from a global open-source community.

SEE ALSO

curl(1), wget(1), git(1)

Copied to clipboard