Ready to dive into the world of IPFS? This guide will walk you through installing an IPFS node on your system, initializing it, and using some fundamental commands to interact with the decentralized web. Whether you prefer a graphical interface or the command line, there's an option for you.
1. Installing IPFS
You have two primary ways to install and run IPFS on your computer:
- IPFS Desktop: A user-friendly application that bundles an IPFS node, file manager, peer manager, and a CID-aware browser companion. It's great for beginners and those who prefer a GUI.
- IPFS Kubo (formerly Go-IPFS): The command-line implementation of IPFS, written in Go. It provides full control and is often preferred by developers and power users. You can also explore version control concepts which are fundamental to many software projects, including IPFS itself.
You can find detailed installation instructions for your operating system on the official IPFS documentation website.
2. Initializing Your IPFS Node
Once IPFS is installed (especially if you chose Kubo/CLI), you need to initialize your IPFS node. This creates a local IPFS repository on your machine, which stores your node's settings, cryptographic keys, and cached data. Open your terminal and run:
ipfs init
This command will generate a unique Peer ID for your node – your address on the IPFS network. It will also provide some helpful hints to get you started.
3. Running Your IPFS Node (Daemon)
To connect your node to the IPFS network and start interacting with other peers, you need to run the IPFS daemon:
ipfs daemon
Keep this terminal window open. The daemon will print out status messages as it connects to peers and performs operations. If you're using IPFS Desktop, it typically handles running the daemon for you in the background.
4. Basic IPFS Commands (CLI)
With your daemon running, open another terminal window to execute these commands:
-
Adding Files:
ipfs addTo add a file to your IPFS node (and thus to the network, once others request it), use the
addcommand. For example, create a simple text file namedhello.txtwith some content.echo "Hello IPFS World!" > hello.txt ipfs add hello.txtThis command will output one or more lines. The last line is the Content Identifier (CID) for your file (e.g.,
QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB). This CID is crucial as it's the permanent, verifiable address of your content. -
Retrieving Files:
ipfs catTo retrieve and display the content of a file using its CID:
ipfs cat QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB(Replace the example CID with the one you got from
ipfs add). This will print the content ofhello.txt. -
Listing Directory Contents:
ipfs lsIf you add a directory, you can list its contents using
ipfs ls <CID_of_directory>. Each file and subdirectory within will have its own CID. -
Checking Your Node's ID:
ipfs idThis command displays your node's Peer ID, public key, and the network addresses it's listening on.
-
Listing Connected Peers:
ipfs swarm peersShows a list of other IPFS nodes your daemon is currently connected to.
5. Accessing IPFS Content via Gateways
While you can access content directly using your local IPFS node, public IPFS gateways allow anyone to access IPFS content through a standard web browser, even without running an IPFS node. The URL structure is typically:
https://<gateway-host>/ipfs/<CID>
For example, to view the hello.txt file added earlier (assuming its CID is QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB) via the ipfs.io gateway, you would use:
https://ipfs.io/ipfs/QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB
You're Now on the Decentralized Web!
Congratulations! You've installed IPFS, added your first file, and learned how to retrieve it. This is just the beginning. IPFS has a rich set of features and a growing ecosystem. Explore further, add more complex data, and experiment with building on this exciting technology.
Now that you have a basic grasp of using IPFS, you might be interested in a deeper comparison: IPFS vs. HTTP: A New Paradigm for Data or look towards The Future and Challenges of IPFS.