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|--recursive]] [path/to/directory]
copy

Save a remote file and give it a name but not pin it
$ ipfs get [hash] [[-o|--output]] [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> [<command-options>] [<arguments>]

PARAMETERS

-c, --config=<path>
    Path to configuration file

-D, --debug
    Enable debug logging

-h, --help
    Show help message

-L, --local
    Use only local node (no network)

-a, --api=<address>
    API multiaddr (default: /ip4/127.0.0.1/tcp/5001)

--encoding=<enc>
    Set output encoding (default: json)

--offline
    Do not connect to network

--repo=<path>
    Override path to repo

-t, --timeout=<duration>
    Timeout for remote operations

DESCRIPTION

The ipfs command is the primary command-line interface for interacting with IPFS (InterPlanetary File System), a peer-to-peer protocol for storing, sharing, and accessing files via content-addressed hashes. IPFS enables decentralized data distribution, making content available worldwide through a network of nodes without relying on central servers.

Key functionalities include adding files to IPFS (ipfs add), retrieving content (ipfs cat or ipfs get), listing directories (ipfs ls), managing peers via the swarm (ipfs swarm), and running the background daemon (ipfs daemon). Users can pin content locally to ensure availability, configure node settings, generate keys for encryption, and perform diagnostics.

The CLI supports offline modes for local operations and online modes for network interactions like DHT queries and pubsub messaging. It's essential for developers building decentralized apps (dApps), archiving data, or hosting websites via IPFS gateways. Installation typically via go-ipfs package provides this versatile tool for P2P file operations.

CAVEATS

Most networked commands require ipfs daemon running.
Performance depends on peer availability and bandwidth.
Content hashes are deterministic; changes alter CID.
Use gateways like ipfs.io for browser access.

COMMON SUBCOMMANDS

add: Add file/dir to IPFS.
cat: Show IPFS object content.
daemon: Run IPFS daemon.
ls: List IPFS dir.
pin add: Pin for local persistence.
version: Show IPFS version.

DAEMON USAGE

Start with ipfs daemon for full functionality.
Stop with Ctrl+C or kill. Logs via ipfs log.

HISTORY

Developed by Protocol Labs as part of go-ipfs; first CLI release in 2015 (v0.1.0). Evolved through versions, with major updates in Kubo (IPFS 0.8+, 2021) adding FIL integration, better Bitswap, and modular commands. Widely used in Web3, NFTs, and decentralized storage.

SEE ALSO

go-ipfs(1), ipfs-cluster-ctl(1)

Copied to clipboard