- 第 1 章 区块链
- 第 2 章 以太坊
- 第 3 章 以太坊私链入门
- 第 4 章 以太坊网络
- 第 5 章 geth v1.8.16 命令详解
- 第 6 章 Wallet
- 第 7 章 Token
- 第 8 章 智能合约语言 Solidity v0.5.0
- 第 9 章 Truffle v4.1.8 开发框架
- 第 10 章 web3.js - 1.0.0
- 第 11 章 web3j v3.4.0 - Jave Client
- 11.2. 启动以太坊
- 11.3. Maven pom.xml 文件
- 11.4. Java 与 Solidity 数据类型映射关系
- 11.5. 常量
- 11.6. 连接到服务器获取版本号
- 11.7. 获得以太坊状态信息
- 11.8. 单位转换
- 11.9. 账号管理
- 11.10. Credentials
- 11.11. 交易
- 11.12. 钱包
- 11.13. 智能合约
- 11.14. ERC20合约
- 11.15. Infura
- 11.16. 助记词
- 11.17. 过滤器 (Filter)
- 11.18. Subscription
- 11.19. 解锁账号
- 11.20. IBAN (International Bank Account Number)
- 11.21. Springboot with Ethereum (web3j)
- 第 12 章 web3.py - A python interface for interacting with the Ethereum blockchain and ecosystem.
- 第 14 章 Ethereum Developer APIs
- 第 15 章 infura
- 第 16 章 以太坊案例
- 第 17 章 FAQ
- 17.3. Error: authentication needed: password or unlock
- 17.4. 新增节点后不生效
- 17.5. Unhandled rejection Error: Returned error: The method personal_unlockAccount does not exist/is not available
- 17.6. Error: exceeds block gas limit
- 17.7. Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(…) { … }" instead.
- 17.8. Exception in thread "main" rx.exceptions.OnErrorNotImplementedException: Invalid response received: okhttp3.internal.http.RealResponseBody@6c25e6c4
- 17.9. 旧版本 Remix(browser-solidity) 本地安装
- 第 18 章 Hyperledger Fabric v2.0.0
- 第 19 章 Hyperledger Fabric 运维
- 第 20 章 Chaincode 链码(智能合约)
- 第 21 章 Hyperledger Fabric Client SDK for Node.js
- 第 22 章 fabric-sdk-java
- 第 24 章 已知 Hyperledger 落地案例
- 第 25 章 Fabric Command
- 第 26 章 Fabric FAQ
- 第 27 章 IPFS(InterPlanetary File System,星际文件系统)
- 第 28 章 IPFS 命令
- 第 29 章 IPFS WebUI
- 第 30 章 IPFS 集群配置
- 第 31 章 IPFS API
- 第 32 章 IPFS Faq
- 第 33 章 EOS
- 第 34 章 EOS 安装
- 第 35 章 CLEOS
- 第 36 章 智能合约开发
- 第 37 章 EOS Dapp 开发
- 第 38 章 FAQ
- 第 39 章 BaaS (Blockchain as a Service) 平台
- 第 40 章 BitCoin
- 第 41 章 其他区块链相关
- 附录 1. 附录
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
28.3. 基本命令
28.3. 基本命令
28.3.1. 初始化节点
[ipfs@netkiller ~]$ ipfs init initializing IPFS node at /home/ipfs/.ipfs generating 2048-bit RSA keypair...done peer identity: QmZakCF5czhP53KPvMi8XQcYtVrQohw5N71Xce4eC1rWz3 to get started, enter: ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
目录结构
[ipfs@netkiller ~]$ ls .ipfs/ blocks config datastore datastore_spec keystore version
28.3.2. 添加文件或文本到 IPFS
28.3.2.1. 添加文件
[ipfs@netkiller ~]$ echo Helloworld > helloworld.txt [ipfs@netkiller ~]$ ipfs add helloworld.txt added QmS8R3nSbDHjQ7WRTjtX1pkiQ6BUpti9qTjweZkBgGPKiN helloworld.txt [ipfs@netkiller ~]$ ipfs cat QmS8R3nSbDHjQ7WRTjtX1pkiQ6BUpti9qTjweZkBgGPKiN Helloworld [ipfs@netkiller ~]$ ipfs cat /ipfs/QmS8R3nSbDHjQ7WRTjtX1pkiQ6BUpti9qTjweZkBgGPKiN Helloworld
28.3.2.2. 添加文本
添加一段字符串到 IPFS
[ipfs@netkiller ~]$ echo 'Look! Things have changed!' | ipfs add added QmSb8DSVmu4Qip56jcqPVz1Cx9RJ3vTf3d1Gf9ixaG2tWg QmSb8DSVmu4Qip56jcqPVz1Cx9RJ3vTf3d1Gf9ixaG2tWg [ipfs@netkiller ~]$ ipfs cat QmSb8DSVmu4Qip56jcqPVz1Cx9RJ3vTf3d1Gf9ixaG2tWg Look! Things have changed!
28.3.2.3. 安静模式,仅返回 Hash
安静模式
[ipfs@netkiller ~]$ ipfs add -q /tmp/1536896811406807.mp4 QmcA1Fsrt6jGTVqAUNZBqaprMEdFaFkmkzA5s2M6mF85UC
28.3.2.4. 尝试修改内容
修改内容后 Hash 变化
[root@netkiller ~]# echo "version 1 of my text" | ipfs add added QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy [root@netkiller ~]# echo "version 2 of my text" | ipfs add added QmTudJSaoKxtbEnTddJ9vh8hbN84ZLVvD5pNpUaSbxwGoa QmTudJSaoKxtbEnTddJ9vh8hbN84ZLVvD5pNpUaSbxwGoa [root@netkiller ~]# ipfs cat QmZtmD2qt6fJot32nabSP3CUjicnypEBz7bHVDhPQt9aAy version 1 of my text [root@netkiller ~]# ipfs cat QmTudJSaoKxtbEnTddJ9vh8hbN84ZLVvD5pNpUaSbxwGoa version 2 of my text [root@netkiller ~]# echo "version 1" > version.txt [root@netkiller ~]# ipfs add version.txt added QmQBcXurY2QBpv7sg8zyS4UXQeHGCqx4DBp86kBLPDzS18 version.txt [root@netkiller ~]# echo "version 2" > version.txt [root@netkiller ~]# ipfs add version.txt added QmWzK72EZJJhW96x1tgaz8yU3G6okJ9MfMxbLianzFLhY2 version.txt [root@netkiller ~]# ipfs cat QmQBcXurY2QBpv7sg8zyS4UXQeHGCqx4DBp86kBLPDzS18 version 1 [root@netkiller ~]# ipfs cat QmWzK72EZJJhW96x1tgaz8yU3G6okJ9MfMxbLianzFLhY2 version 2
28.3.2.5. 递归添加一个目录
[ipfs@netkiller ~]$ ipfs add -r /etc/nginx/ added QmTa5RvPS9GEgbR8KUy36Fkx7y8Z7LpFM47pbAWJ89tUoi nginx/conf.d/default.conf added QmSGZtdGvLd64eYqXNyDraegz5Tm5evyTrX7GMAhE4L1KB nginx/conf.d/default.conf.backup added Qmbh35NHRNYfpaXaj1bQF4gcVYKRjjBvD7eys4dK4iwNrY nginx/fastcgi_params added QmaHUhxr4NPTsxc2iubLAVGAvJ6hRKfZsbDPYZDT6Bdcb1 nginx/koi-utf added QmRpsaigHjE4udpVDXZ8T4YtA477M7YTox6xxxkbYjisgN nginx/koi-win added QmbJThNSiHPy1bDTkLq2Rp8uU4cDLbX8Nzgxrf79ujQ6D9 nginx/mime.types added QmWDHS75NyRXZZxe3ZYAaETE4Z4mPx1htahBZBYx4cAYEM nginx/modules added QmNjAKtPe3AoUSSiLF1onA8fVbogcQ4cJHD2bvj38udpJQ nginx/nginx.conf added QmPXqmW4jpg5HbqqToJnzpqamSSNwHEkSxcGqiGmE9UaGM nginx/nginx.conf.original added QmTiu69XGzh1iqK6JuJNzoTiQ4SJEeQSso3uCHRwbXFba8 nginx/scgi_params added QmW2nvZqf6fwmcgBeeUEv2UyePizsFjjkNCubqRjmCZHNV nginx/uwsgi_params added Qmen15DKJhF5ngxiBEzmpMyPA3HpMfXNqgogeyeati2sEx nginx/win-utf added QmZ1cs8uxMSRcd2UX6ei4a2DYanQSBNV8PieRWcKzXbKXY nginx/conf.d added Qmbw5SZyAKkccUTq5N5jLTXzRk21jZThmmMGsX5Fh2BPic nginx 19.35 KiB / 27.35 KiB [======================================================>-----------] 70.75%
注意最后面的 nginx 是目录 Hash,我们可以使用这个 Hash 访问文件
http://ipfs.netkiller.cn/ipfs/Qmbw5SZyAKkccUTq5N5jLTXzRk21jZThmmMGsX5Fh2BPic/conf.d/default.conf
你也可以直接访问 Hash 值
http://ipfs.netkiller.cn/ipfs/QmSGZtdGvLd64eYqXNyDraegz5Tm5evyTrX7GMAhE4L1KB
28.3.3. 查看文件
[ipfs@netkiller ~]$ ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/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
28.3.4. 下载文件
[root@netkiller ~]# ipfs get /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme Saving file(s) to readme 1.08 KB / 1.08 KB [======================================================================] 100.00% 0s [root@netkiller ~]# ls readme
[root@netkiller ~]# ipfs add readme.txt added QmdoPoadYA5HYvSzgUrgXYdEVRNL1T7pY38GaWabZ3KLgn readme.txt [root@netkiller ~]# ipfs cat QmdoPoadYA5HYvSzgUrgXYdEVRNL1T7pY38GaWabZ3KLgn Helloworld [root@netkiller ~]# ipfs get QmdoPoadYA5HYvSzgUrgXYdEVRNL1T7pY38GaWabZ3KLgn Saving file(s) to QmdoPoadYA5HYvSzgUrgXYdEVRNL1T7pY38GaWabZ3KLgn 880 B / 880 B [=========================================================================] 100.00% 0s [root@netkiller ~]# ls QmdoPoadYA5HYvSzgUrgXYdEVRNL1T7pY38GaWabZ3KLgn readme.txt
28.3.5. 列出文件或目录
[root@netkiller ~]# ipfs ls /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/ QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V 1688 about QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y 200 contact QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 322 help QmejvEPop4D7YUadeGqYWmZxHhLc4JBUCzJJHWMzdcMe2y 12 ping QmXgqKTbzdh83pQtKFb19SpMCpDDcKR2ujqk3pKph9aCNF 1692 quick-start QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB 1102 readme QmQ5vhrL7uv6tuoN9KeVBwd4PwfQkXdVVmDLUZuTNxqgvm 1173 security-notes
[root@netkiller ~]# ipfs add -r /etc/rc.d added QmP4m7YRN25kcRgoJgn95yFR4GsVgbQppnpMGh3AxPzUbc rc.d/init.d/README added QmemkmPhud9hBWhTDgnYfascZcXjX4H6j4oyqhKdSvFq8G rc.d/init.d/aegis added QmR2zvwDZYQPw4arpaJQwGESPhmz6qBt8MqyrV5UR72JUy rc.d/init.d/agentwatch added QmevSkKJVSF4amfHux7bMZCvaQQjuFsDxU1j7j7uvvJzBh rc.d/init.d/functions added QmXCmPYb1wWcmAWk8tm1jgYsFgF16mTe2PsnNebw1gzWDw rc.d/init.d/jexec added QmeQZxv7Fui5Ah9w9E9QuiyTrbm4XMKyJMthGLvbbtd5q4 rc.d/init.d/netconsole added QmeDfRGHoLuSTZqk4zcwGKJQ1NUk9VhEYxFy1HC5d9hKxH rc.d/init.d/network added QmYWStNUPtn9TgUT39D7vXMjXc5y917W7SsjPTZvCMK136 rc.d/rc.local added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc0.d/K01agentwatch added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc0.d/K05jexec added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc0.d/K50aegis added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc0.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc0.d/K90network added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc1.d/K01agentwatch added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc1.d/K50aegis added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc1.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc1.d/K90network added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc1.d/S95jexec added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc2.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc2.d/S10network added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc2.d/S50aegis added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc2.d/S95jexec added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc2.d/S98agentwatch added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc3.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc3.d/S10network added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc3.d/S50aegis added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc3.d/S95jexec added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc3.d/S98agentwatch added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc4.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc4.d/S10network added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc4.d/S50aegis added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc4.d/S95jexec added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc4.d/S98agentwatch added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc5.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc5.d/S10network added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc5.d/S50aegis added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc5.d/S95jexec added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc5.d/S98agentwatch added QmS92vH7JY9CnP3DVZiQcHxqyi9FQXc1RTcyQvhCJnTCon rc.d/rc6.d/K01agentwatch added QmabzShX1WxbdMfLmNK16M1edR5TP95iM5FBURSFwfdj4t rc.d/rc6.d/K05jexec added QmcuWaJdg5JCckgdh5BomTwYjrn3ChrC2xa3yY61jQ1pGV rc.d/rc6.d/K50aegis added QmYnJ5yxouhrbu81Nod3o1ZWKuwdHYYsbr7z4BgLCxxR2P rc.d/rc6.d/K50netconsole added QmPNCeB2yS9EZ3cG3ousMtPkLNemkQaDfKt63S4NTBJg3z rc.d/rc6.d/K90network added QmUy33heBFE59gc6PB2sevQ88gB7Lv3NDASFJF3S8f1qHK rc.d/init.d added QmaDZHSDdtNyryWNwtxuMtJ8NduQdfhMMHk7JuTpNW5sTs rc.d/rc0.d added QmX6D9eP1oHMg92rrVYarGAe4w3HQ9vURcncBRvPqtXSyG rc.d/rc1.d added QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 rc.d/rc2.d added QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 rc.d/rc3.d added QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 rc.d/rc4.d added QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 rc.d/rc5.d added QmaDZHSDdtNyryWNwtxuMtJ8NduQdfhMMHk7JuTpNW5sTs rc.d/rc6.d added QmRYPNdKdyCr6R7fE63g2u3sMD8SQh8TW6yQNAk9mT9Pay rc.d [root@netkiller ~]# ipfs ls -v QmRYPNdKdyCr6R7fE63g2u3sMD8SQh8TW6yQNAk9mT9Pay Hash Size Name QmUy33heBFE59gc6PB2sevQ88gB7Lv3NDASFJF3S8f1qHK 36013 init.d/ QmYWStNUPtn9TgUT39D7vXMjXc5y917W7SsjPTZvCMK136 484 rc.local QmaDZHSDdtNyryWNwtxuMtJ8NduQdfhMMHk7JuTpNW5sTs 383 rc0.d/ QmX6D9eP1oHMg92rrVYarGAe4w3HQ9vURcncBRvPqtXSyG 383 rc1.d/ QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 383 rc2.d/ QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 383 rc3.d/ QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 383 rc4.d/ QmTEuKk4acWJcsCDYJViMNoKZ2BQDY8NSHraV9gB9nAWm8 383 rc5.d/ QmaDZHSDdtNyryWNwtxuMtJ8NduQdfhMMHk7JuTpNW5sTs 383 rc6.d/ [root@netkiller ~]# ipfs ls -v QmUy33heBFE59gc6PB2sevQ88gB7Lv3NDASFJF3S8f1qHK Hash Size Name QmP4m7YRN25kcRgoJgn95yFR4GsVgbQppnpMGh3AxPzUbc 1171 README QmemkmPhud9hBWhTDgnYfascZcXjX4H6j4oyqhKdSvFq8G 2266 aegis QmR2zvwDZYQPw4arpaJQwGESPhmz6qBt8MqyrV5UR72JUy 3015 agentwatch QmevSkKJVSF4amfHux7bMZCvaQQjuFsDxU1j7j7uvvJzBh 17514 functions QmXCmPYb1wWcmAWk8tm1jgYsFgF16mTe2PsnNebw1gzWDw 41 jexec QmeQZxv7Fui5Ah9w9E9QuiyTrbm4XMKyJMthGLvbbtd5q4 4345 netconsole QmeDfRGHoLuSTZqk4zcwGKJQ1NUk9VhEYxFy1HC5d9hKxH 7304 network
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论