{"id":255604,"date":"2022-11-01T09:35:17","date_gmt":"2022-11-01T01:35:17","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=255604"},"modified":"2022-10-23T09:36:27","modified_gmt":"2022-10-23T01:36:27","slug":"useradd-adduser","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/useradd-adduser.html","title":{"rendered":"useradd \u547d\u4ee4\u548c adduser \u547d\u4ee4\u4e8c\u8005\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728 Linux \u4e2d\u521b\u5efa\u65b0\u7528\u6237\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 adduser \u6216 useradd \u547d\u4ee4\u3002\u90a3\u4e48\uff0cuseradd \u548c adduser \u7684\u533a\u522b\u662f\u4ec0\u4e48\u5462\uff1f\u5b9e\u9645\u4f7f\u7528\u7684\u65f6\u5019\u5e94\u8be5\u7528\u54ea\u4e00\u4e2a\u6bd4\u8f83\u597d\u5462\uff1f\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u770b\u4e00\u4e0b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\"\"<\/p>\n

2AHMRJ4 futuristic sci-fi space war ship hangar tunnel corridor with reflective glass windows 3d illustration background wallpaper<\/p>\n<\/div>\n

adduser \u548cuseradd \u547d\u4ee4\u7684\u533a\u522b<\/strong><\/div>\n

useradd \u547d\u4ee4\u662f\u5185\u7f6e\u7684 Linux \u547d\u4ee4\uff0c\u5728\u4efb\u4f55 Linux \u7cfb\u7edf\u4e2d\u90fd\u53ef\u7528\u3002\u7136\u800c\uff0c\u4f7f\u7528\u8fd9\u79cd\u4f4e\u7ea7\u522b\u7684\u5de5\u5177\u521b\u5efa\u7528\u6237\u662f\u6bd4\u8f83\u7e41\u7410\u7684\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4e0d\u4f1a\u521b\u5efa\u4e3b\u76ee\u5f55\u548c\u7528\u6237\u5bc6\u7801\u3002<\/p>\n

adduser \u4e0d\u662f\u6807\u51c6\u7684 Linux \u547d\u4ee4\uff0c\u5b83\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a perl \u811a\u672c\uff0c\u5728\u540e\u53f0\u8c03\u7528 useradd \u547d\u4ee4\u3002\u8fd9\u4e2a\u9ad8\u7ea7\u5b9e\u7528\u7a0b\u5e8f\u5728 Linux \u4e2d\u521b\u5efa\u7528\u6237\u7684\u65f6\u5019\u6548\u7387\u66f4\u9ad8\uff0c\u5b83\u63d0\u4f9b\u4e86\u521b\u5efa\u4e3b\u76ee\u5f55\u3001\u8bbe\u7f6e\u5bc6\u7801\u4ee5\u53ca\u5176\u4ed6\u4e00\u4e9b\u53c2\u6570\u7684\u9009\u9879\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u770b\u4e00\u4e0b\u3002<\/p>\n

useradd \u547d\u4ee4<\/strong><\/div>\n

\u6211\u4eec\u5728\u300a\u4f7f\u7528 useradd \u547d\u4ee4\u5728 Linux \u4e2d\u6dfb\u52a0\u65b0\u7528\u6237\u300b\u4e2d\u4ecb\u7ecd\u8fc7useradd\u7684\u7528\u6cd5\uff0c\u5927\u5bb6\u611f\u5174\u8da3\u7684\u53ef\u4ee5\u770b\u4e00\u4e0b\u3002\u73b0\u5728\u6211\u4eec\u518d\u6765\u770b\u4e0b\u5176 useradd \u7684\u9ed8\u8ba4\u7528\u6cd5\uff0c\u4f60\u4f7f\u7528\u8fc7\u5982\u4e0b\u547d\u4ee4\u5417\uff1f<\/p>\n

useradd new_user\r\n<\/pre>\n

\u8fd9\u4e2a\u547d\u4ee4\u9ed8\u8ba4\u4e0d\u662f\u521b\u5efa\u4e00\u4e2a\u5b8c\u6574\u7684\u7528\u6237\uff0c\u5373\u4f7f\u4e3a\u5176\u8bbe\u7f6e\u4e86\u5bc6\u7801\uff0c\u4f46\u8fd8\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u9009\u9879\u3002\u5b83\u4f1a\u5728 \/etc\/passwd \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n

\"\"<\/p>\n

\u6211\u4eec\u5728\u300aLinux \u4e2d\u67e5\u770b\u6240\u6709\u7528\u6237\u7684\u4e09\u79cd\u65b9\u6cd5\u300b\u63d0\u5230\u8fc7 \/etc\/passwd \u6587\u4ef6\uff08\u5982\u679c\u4e0d\u6e05\u695a\u7684\u8bdd\u5927\u5bb6\u53ef\u4ee5\u518d\u770b\u4e00\u4e0b\uff09\u3002\u8fd9\u6837\u770b\u8d77\u6765\uff0c\u7528\u6237\u4f3c\u4e4e\u662f\u521b\u5efa\u6210\u529f\u4e86\uff0c\u4f46\u5b9e\u9645\u7528\u7684\u8bdd\uff0c\u4f1a\u53d1\u73b0\u67d0\u4e9b\u5730\u65b9\u4e0d\u5bf9\u52b2\u3002<\/p>\n

\u9996\u5148\uff0c\u5728 \/etc\/passwd \u6587\u4ef6\u4e2d\uff0c\u8be5\u65b0\u5efa\u7528\u6237\u7684\u7b2c\u4e8c\u4e2a\u5b57\u6bb5\u4e2d\u5305\u542b \"x\"\uff0c\u8fd9\u610f\u5473\u7740\u5728 \/etc\/shadow \u4e2d\uff0c\u5bc6\u7801\u662f\u4e00\u4e2a\u5360\u4f4d\u7b26\uff0c\u7531\u4e8e\u8fd8\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\uff0c\u6240\u4ee5\u8fd9\u4e2a\u7528\u6237\u5c06\u65e0\u6cd5\u767b\u5f55\u3002<\/p>\n

\u7b2c\u4e8c\u4e2a\u95ee\u9898\uff0c\u8be5\u7528\u6237\u6ca1\u6709\u4e3b\u76ee\u5f55\uff0c\u5373 \/home\/test \u4e0d\u5b58\u5728\u3002\u5373\u4f7f\u8bbe\u7f6e\u4e86\u5bc6\u7801\uff0c\u5982\u679c\u7528\u6237\u767b\u5f55\u7684\u8bdd\uff0c\u4e5f\u4f1a\u53d1\u751f\u9519\u8bef\u3002\u56e0\u4e3a Linux \u53ef\u80fd\u4f1a\u963b\u6b62\u6ca1\u6709\u4e3b\u76ee\u5f55\u7684\u7528\u6237\u767b\u5f55\u3002\u6700\u6709\u53ef\u80fd\u7684\u60c5\u51b5\u662f\uff0c\u7528\u6237\u5373\u4f7f\u53ef\u4ee5\u767b\u5f55\u7cfb\u7edf\uff0c\u4e5f\u53ea\u662f\u5728\u6587\u672c\u6a21\u5f0f\u4e0b\uff0c\u4f46\u662f\u4e0d\u5141\u8bb8\u5176\u521b\u5efa\u4ed6\u7684\u4e3b\u76ee\u5f55\u3002<\/p>\n

\u7b2c\u4e09\u4e2a\u95ee\u9898\uff0c\u5176\u767b\u5f55\u7684\u9ed8\u8ba4 shell \u662f sh\uff0c\u800c\u4e0d\u662fbash\uff0cbash \u662f\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e0a\u7684\u9ed8\u8ba4 shell\u3002<\/p>\n

\u4ee5\u4e0a\u95ee\u9898\uff0c\u53ef\u4ee5\u5728 \/etc\/login.defs \u4e2d\u4fee\u6539\u3002<\/p>\n

adduser \u547d\u4ee4<\/strong><\/div>\n

adduser \u547d\u4ee4\u5728\u67d0\u4e9b Linux \u53d1\u884c\u7248\u4e0a\u4e0d\u53ef\u7528\uff0c\u5728\u67d0\u4e9b Linux \u4e2d\uff0c\u5b83\u662f useradd \u7684\u4e00\u4e2a\u8f6f\u8fde\u63a5\uff0c\u5728\u53e6\u5916\u4e00\u4e9b Linux \u7cfb\u7edf\u4e2d\uff0c\u5b83\u662f\u4e00\u4e2a perl \u811a\u672c\u3002<\/p>\n

adduser \u547d\u4ee4\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u9ad8\u7ea7\u5b9e\u7528\u7a0b\u5e8f\uff0c\u5b83\u4ee5 useradd \u4e3a\u540e\u53f0\uff0c\u4e14\u81ea\u52a8\u914d\u7f6e \/etc\/login.defs\u3002\u5728\u57fa\u4e8e Debian \u7684\u7cfb\u7edf\u4e2d\uff0cman \u624b\u518c\u4e2d\u90fd\u4f1a\u5efa\u8bae\u4f7f\u7528\u5b83\u800c\u4e0d\u662f useradd \u547d\u4ee4\u3002 \u4f7f\u7528 adduser \u547d\u4ee4\u521b\u5efa\u7528\u6237\uff0c\u5b83\u4f1a\u5f15\u5bfc\u4f60\u8f93\u5165\u4e00\u7cfb\u5217\u7684\u53c2\u6570\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

\u8f93\u5165\u53c2\u6570\uff0c\u56de\u8f66\uff0c\u4e4b\u540e\u7cfb\u7edf\u4f1a\u521b\u5efa\u4e00\u4e2a\u5b8c\u6574\u7684\u7528\u6237\u8d26\u6237\uff0c\u5305\u542b\u4e3b\u76ee\u5f55\u3002\u5982\u6b64\uff0c\u65b0\u7528\u6237\u5c31\u53ef\u4ee5\u6b63\u5e38\u767b\u5f55\u4e86\u3002 \u8981\u4f7f\u7528 useradd \u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\uff0c\u5176\u547d\u4ee4\u7c7b\u4f3c\u4e8e\uff1a<\/p>\n

sudo useradd -d \/home\/test -m -s\/bin\/bash \\ -c FullName,Phone,OtherInfo test && passwd test\r\n<\/pre>\n

\u4e0a\u8ff0\u547d\u4ee4\u4e2d\u7684 -c \u9009\u9879\u53ef\u4ee5\u5220\u6389\uff0c\u5176\u540e\u9762\u7528\u9017\u53f7\u5206\u5272\u7684\u5185\u5bb9\u662f\u8981\u6dfb\u52a0\u5230 \/etc\/passwd \u4e2d\u7684\u5185\u5bb9\u3002\u5373\u4fbf\u5982\u6b64\uff0cuseradd \u547d\u4ee4\u8fd8\u662f\u6bd4 adduser \u989d\u5916\u591a\u4e86\u4e24\u4e2a\u9009\u9879\u9700\u8981\u8f93\u5165\u3002 adduser \u547d\u4ee4\u6709\u4e00\u4e2a\u53ef\u7528\u7684\u9009\u9879\u5217\u8868\uff0c\u5982\u4e0b\u662f\u6211\u4eec\u5217\u51fa\u7684\u4e00\u4e9b\u6700\u5e38\u7528\u7684\uff08\u6709\u5173\u66f4\u591a\u7684\u4fe1\u606f\uff0c\u5927\u5bb6\u53ef\u53c2\u8003\u5e2e\u52a9\u4fe1\u606f\u6216\u8005 man \u624b\u518c\uff09\u3002<\/p>\n

    \n
  1. \n
      system\uff1a\u6dfb\u52a0\u7cfb\u7edf\u7528\u6237\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u7528\u6237\u4f4d\u4e8e nogroup \u7ec4\u4e2d\u3002\u8981\u5c06\u7cfb\u7edf\u7528\u6237\u6dfb\u52a0\u5230\u4e00\u4e2a\u73b0\u6709\u7ec4\u4e2d\uff0c\u9700\u8981\u4f7f\u7528 \u2013gid \u6216 \u2013ingroup \u9009\u9879\uff1b<\/ol>\n<\/li>\n<\/ol>\n

       <\/p>\n

        \n
      1. \n
          home DIR\uff1a\u4f7f\u7528 DIR \u4f5c\u4e3a\u4e3b\u76ee\u5f55\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684\u76ee\u5f55\u3002\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u521b\u5efa\u76ee\u5f55\uff0c\u5e76\u590d\u5236\u7cfb\u7edf\u6846\u67b6\u6587\u4ef6\uff1b<\/ol>\n<\/li>\n<\/ol>\n

           <\/p>\n

            \n
          1. \n
              shell SHELL\uff1a\u4f7f\u7528 SHELL \u6765\u4ee3\u66ff\u9ed8\u8ba4\u7684\uff1b<\/ol>\n<\/li>\n<\/ol>\n

               <\/p>\n

                \n
              1. \n
                  ingroup GROUP\uff1a\u5c06\u7528\u6237\u7684\u6240\u5c5e\u7ec4\u8bbe\u7f6e\u4e3a GROUP\uff1b<\/ol>\n<\/li>\n<\/ol>\n

                   <\/p>\n

                    add_extra_groups\uff1a\u5c06\u65b0\u7528\u6237\u6dfb\u52a0\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u989d\u5916\u7ec4\u3002<\/ol>\n

                    adduser \u7684\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u5141\u8bb8\u6211\u4eec\u8bbe\u7f6e\u4e00\u4e9b\u521b\u5efa\u7528\u6237\u65f6\u6240\u8981\u4f7f\u7528\u7684\u9ed8\u8ba4\u503c\uff0c\u6bd4\u5982\uff1a<\/p>\n

                      \n
                    1. \n
                        \u9ed8\u8ba4 shell<\/ol>\n<\/li>\n<\/ol>\n

                         <\/p>\n

                          \n
                        1. \n
                            \u4e3b\u76ee\u5f55<\/ol>\n<\/li>\n<\/ol>\n

                             <\/p>\n

                              \n
                            1. \n
                                \u6240\u5c5e\u7ec4<\/ol>\n<\/li>\n<\/ol>\n

                                 <\/p>\n

                                  \u6dfb\u52a0\u989d\u5916\u7ec4<\/ol>\n","protected":false},"excerpt":{"rendered":"

                                  useradd \u547d\u4ee4\u662f\u5185\u7f6e\u7684 Linux \u547d\u4ee4\uff0c\u5728\u4efb\u4f55 Linux \u7cfb\u7edf\u4e2d\u90fd\u53ef\u7528\u3002\u7136\u800c\uff0c\u4f7f\u7528\u8fd9\u79cd\u4f4e\u7ea7\u522b\u7684\u5de5\u5177\u521b […]<\/p>\n","protected":false},"author":370,"featured_media":213423,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-255604","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\/255604","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\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=255604"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/255604\/revisions"}],"predecessor-version":[{"id":255828,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/255604\/revisions\/255828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/213423"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=255604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=255604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=255604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}