{"id":49524,"date":"2023-05-20T06:06:38","date_gmt":"2023-05-19T22:06:38","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=49524"},"modified":"2023-05-20T06:06:38","modified_gmt":"2023-05-19T22:06:38","slug":"ln-command-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ln-command-linux.html","title":{"rendered":"\u4f7f\u7528ln\u547d\u4ee4\u5728Linux\u7cfb\u7edf\u4e2d\u521b\u5efa\u8fde\u63a5\u6587\u4ef6"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728Linux\u4e2dln\u547d\u4ee4\u7528\u6765\u4e3a\u6587\u4ef6\u521b\u5efa\u8fde\u63a5\uff0c\u8fde\u63a5\u7c7b\u578b\u5206\u4e3a\u786c\u8fde\u63a5\uff08Hard Link\uff09\u548c\u7b26\u53f7\u8fde\u63a5\uff08Symbolic Link\uff09\u4e24\u79cd\uff0c\u9ed8\u8ba4\u7684\u8fde\u63a5\u7c7b\u578b\u662f\u786c\u8fde\u63a5\u3002\u5982\u679c\u8981\u521b\u5efa\u7b26\u53f7\u8fde\u63a5\u5fc5\u987b\u4f7f\u7528\"-s\"\u9009\u9879\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5173\u4e8e\u8f6f\u786c\u8fde\u63a5\u89e3\u91ca<\/b><\/div>\n
\u786c\u8fde\u63a5<\/strong><\/span><\/div>\n

\u786c\u8fde\u63a5\u662f\u6307\u901a\u8fc7\u7d22\u5f15\u8282\u70b9\u6765\u8fdb\u884c\u8fde\u63a5\u3002\u5728Linux\u7684\u6587\u4ef6\u7cfb\u7edf\u4e2d\uff0c\u4fdd\u5b58\u5728\u78c1\u76d8\u5206\u533a\u4e2d\u7684\u6587\u4ef6\u4e0d\u7ba1\u662f\u4ec0\u4e48\u7c7b\u578b\u7cfb\u7edf\u90fd\u4f1a\u7ed9\u5b83\u5206\u914d\u4e00\u4e2a\u7f16\u53f7\uff0c\u79f0\u4e3a\u7d22\u5f15\u8282\u70b9\u53f7(Inode Index)\u3002\u5728Linux\u4e2d\uff0c\u591a\u4e2a\u6587\u4ef6\u540d\u6307\u5411\u540c\u4e00\u7d22\u5f15\u8282\u70b9\u662f\u5b58\u5728\u7684\uff0c\u4e00\u822c\u8fd9\u79cd\u8fde\u63a5\u5c31\u662f\u786c\u8fde\u63a5\u3002\u786c\u8fde\u63a5\u7684\u4f5c\u7528\u662f\u5141\u8bb8\u4e00\u4e2a\u6587\u4ef6\u62e5\u6709\u591a\u4e2a\u6709\u6548\u8def\u5f84\u540d\uff0c\u8fd9\u6837\u7528\u6237\u5c31\u53ef\u4ee5\u5efa\u7acb\u786c\u8fde\u63a5\u5230\u91cd\u8981\u6587\u4ef6\uff0c\u4ee5\u9632\u6b62\u201c\u8bef\u5220\u201d\u7684\u529f\u80fd\u3002\u5176\u539f\u56e0\u5982\u4e0a\u6240\u8ff0\uff0c\u56e0\u4e3a\u5bf9\u5e94\u8be5\u76ee\u5f55\u7684\u7d22\u5f15\u8282\u70b9\u6709\u4e00\u4e2a\u4ee5\u4e0a\u7684\u8fde\u63a5\uff0c\u6240\u4ee5\u53ea\u5220\u9664\u4e00\u4e2a\u8fde\u63a5\u5e76\u4e0d\u5f71\u54cd\u7d22\u5f15\u8282\u70b9\u672c\u8eab\u548c\u5176\u5b83\u7684\u8fde\u63a5\uff0c\u53ea\u6709\u5f53\u6700\u540e\u4e00\u4e2a\u786c\u8fde\u63a5\u88ab\u5220\u9664\u540e\uff0c\u6587\u4ef6\u7684\u6570\u636e\u5757\u53ca\u76ee\u5f55\u7684\u8fde\u63a5\u624d\u4f1a\u88ab\u91ca\u653e\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6587\u4ef6\u771f\u6b63\u5220\u9664\u7684\u6761\u4ef6\u662f\u4e0e\u4e4b\u76f8\u5173\u7684\u6240\u6709\u786c\u8fde\u63a5\u6587\u4ef6\u5747\u88ab\u5220\u9664\u3002<\/p>\n

\u8f6f\u8fde\u63a5<\/strong><\/span><\/div>\n

\u7b26\u53f7\u8fde\u63a5\uff08Symbolic Link\uff09\uff0c\u4e5f\u53eb\u8f6f\u8fde\u63a5\u3002\u8f6f\u94fe\u63a5\u6587\u4ef6\u53c8\u7c7b\u4f3c\u4e8eWindows\u7684\u5feb\u6377\u65b9\u5f0f\u3002\u5b83\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u6587\u4ef6\u3002\u5728\u7b26\u53f7\u8fde\u63a5\u4e2d\uff0c\u8be5\u6587\u4ef6\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u7740\u53e6\u4e00\u6587\u4ef6\u7684\u4f4d\u7f6e\u4fe1\u606f\u3002<\/p>\n

\u901a\u8fc7\u5b9e\u9a8c\u52a0\u6df1\u7406\u89e3<\/strong><\/div>\n
\u521b\u5efa\u4e0d\u540c\u7684\u7c7b\u578b\u7684\u6587\u4ef6\u8fde\u63a5<\/strong><\/span><\/div>\n
root@Orangepi:~\/test# touch file1 \u00a0 \u00a0 \u00a0 \u00a0#\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u6587\u4ef6\r\nroot@Orangepi:~\/test# ln file1 file2 \u00a0 \u00a0 #\u521b\u5efafile\u7684\u4e00\u4e2a\u786c\u8fde\u63a5\u6587\u4ef6file2\r\nroot@Orangepi:~\/test# ln -s file1 file3  #\u521b\u5efafile\u7684\u4e00\u4e2a\u7b26\u53f7\u8fde\u63a5\u6587\u4ef6file3\r\nroot@Orangepi:~\/test# ls -li \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u00a0#-l\u53c2\u6570\u4ee5\u5355\u5217\u683c\u5f0f\u8f93\u51fa\u6587\u4ef6\u4fe1\u606f\uff0c-i\u53c2\u6570\u8f93\u51fa\u6587\u4ef6\u7684inode\u8282\u70b9\u4fe1\u606f\r\ntotal 0\r\n28125 -rw-r--r-- 2 root root 0 Feb 16 08:29 file1\r\n28125 -rw-r--r-- 2 root root 0 Feb 16 08:29 file2\r\n31463 lrwxrwxrwx 1 root root 5 Feb 16 08:30 file3 -> file1<\/pre>\n

\u4ece\u4e0a\u9762\u7684\u7ed3\u679c\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0c\u786c\u8fde\u63a5\u6587\u4ef6file2\u4e0e\u539f\u6587\u4ef6file1\u7684inode\u8282\u70b9\u76f8\u540c\uff0c\u5747\u4e3a28125\uff0c\u7136\u800c\u7b26\u53f7\u8fde\u63a5\u6587\u4ef6\u7684inode\u8282\u70b9\u4e0d\u540c\u3002<\/p>\n

\u5206\u522b\u5bf9\u6587\u4ef6\u8fdb\u884c\u64cd\u4f5c<\/strong><\/span><\/div>\n
root@Orangepi:~\/test# cat >>file1 <<EOF \u00a0 \u00a0 \u00a0 \u00a0    \u00a0#\u5411\u6587\u4ef6file1\u8ffd\u52a0\u5185\u5bb9\r\n> 12345\r\n> EOF\r\nroot@Orangepi:~\/test# cat file1 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0    \u00a0  #\u8f93\u51fa\u6587\u4ef6file1\u5185\u5bb9\r\n12345\r\nroot@Orangepi:~\/test# cat file2 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0     #\u8f93\u51fa\u6587\u4ef6file2\u5185\u5bb9\r\n12345\r\nroot@Orangepi:~\/test# cat file3 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0     \u00a0 #\u8f93\u51fa\u6587\u4ef6file3\u5185\u5bb9\r\n12345\r\nroot@Orangepi:~\/test# rm file1 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \u00a0     #\u5220\u9664\u6587\u4ef6file1\r\nroot@Orangepi:~\/test# cat file2\r\n12345\r\nroot@Orangepi:~\/test# cat file3\r\ncat: file3: No such file or directory<\/pre>\n

\u901a\u8fc7\u4e0a\u9762\u7684\u6d4b\u8bd5\u53ef\u4ee5\u770b\u51fa\uff1a\u5f53\u5220\u9664\u539f\u59cb\u6587\u4ef6file1\u540e\uff0c\u786c\u8fde\u63a5\u6587\u4ef6file2\u4e0d\u53d7\u5f71\u54cd\uff0c\u4f46\u662f\u7b26\u53f7\u8fde\u63a5\u6587\u4ef6file1\u65e0\u6548\u3002<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u4f9d\u6b64\u4f60\u53ef\u4ee5\u505a\u4e00\u4e9b\u76f8\u5173\u7684\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u5f97\u5230\u4ee5\u4e0b\u5168\u90e8\u7ed3\u8bba\uff1a
\n1. \u5220\u9664\u7b26\u53f7\u8fde\u63a5file3\uff0c\u5bf9\u6587\u4ef6file1\uff0cfile2\u65e0\u5f71\u54cd\uff1b
\n2. \u5220\u9664\u786c\u8fde\u63a5file2\uff0c\u5bf9\u6587\u4ef6file1\uff0cfile3\u4e5f\u65e0\u5f71\u54cd\uff1b
\n3. \u5220\u9664\u539f\u6587\u4ef6file1\uff0c\u5bf9\u786c\u8fde\u63a5\u6587\u4ef6file2\u6ca1\u6709\u5f71\u54cd\uff0c\u4f46\u662f\u4f1a\u5bfc\u81f4\u7b26\u53f7\u8fde\u63a5file3\u5931\u6548\uff1b
\n4. \u540c\u65f6\u5220\u9664\u539f\u6587\u4ef6file1\u4ee5\u53ca\u786c\u8fde\u63a5\u6587\u4ef6file2\uff0c\u6574\u4e2a\u6587\u4ef6\u624d\u4f1a\u771f\u6b63\u7684\u88ab\u5220\u9664\u3002<\/p>\n

\n

\u672c\u6587\u539f\u521b\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/ln-command-linux.html<\/a><\/span> \u200e\u4f5c\u8005\uff1a\u90ed\u9a8f\u6770\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u5728Linux\u4e2dln\u547d\u4ee4\u7528\u6765\u4e3a\u6587\u4ef6\u521b\u5efa\u8fde\u63a5\uff0c\u8fde\u63a5\u7c7b\u578b\u5206\u4e3a\u786c\u8fde\u63a5\uff08Hard Link\uff09\u548c\u7b26\u53f7\u8fde\u63a5\uff08Symbo […]<\/p>\n","protected":false},"author":652,"featured_media":49529,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-49524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/49524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/652"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=49524"}],"version-history":[{"count":16,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/49524\/revisions"}],"predecessor-version":[{"id":49546,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/49524\/revisions\/49546"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/49529"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=49524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=49524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=49524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}