{"id":377,"date":"2019-04-19T23:27:07","date_gmt":"2019-04-19T15:27:07","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=377"},"modified":"2022-05-08T16:12:48","modified_gmt":"2022-05-08T08:12:48","slug":"useradd","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/useradd","title":{"rendered":"useradd\u547d\u4ee4 – \u521b\u5efa\u5e76\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f"},"content":{"rendered":"\n

useradd\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cUser add\u201d\u7684\u5168\u62fc\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u521b\u5efa\u5e76\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\u3002\u4f7f\u7528useradd\u547d\u4ee4\u53ef\u4ee5\u81ea\u52a8\u7684\u5b8c\u6210\u521b\u5efa\u7528\u6237\u7684\u4fe1\u606f\u3001\u57fa\u672c\u7ec4\u3001\u5bb6\u76ee\u5f55\u7b49\u5de5\u4f5c\uff0c\u5e76\u5728\u521b\u5efa\u7684\u8fc7\u7a0b\u4e2d\u5bf9\u7528\u6237\u521d\u59cb\u4fe1\u606f\u8fdb\u884c\u5b9a\u5236\u3002<\/p>\n\n\n\n

\u5df2\u521b\u5efa\u7684\u7528\u6237\u5219\u9700\u4f7f\u7528chmod\u547d\u4ee4\u4fee\u6539\u8d26\u6237\u4fe1\u606f\uff0cpasswd\u547d\u4ee4\u4fee\u6539\u5bc6\u7801\u4fe1\u606f\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>useradd [\u53c2\u6570] \u7528\u6237\u540d<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-D<\/td>\u6539\u53d8\u65b0\u5efa\u7528\u6237\u7684\u9884\u8bbe\u503c <\/td><\/tr>
-c<\/td>\u6dfb\u52a0\u5907\u6ce8\u6587\u5b57 <\/td><\/tr>
-d<\/td>\u65b0\u7528\u6237\u6bcf\u6b21\u767b\u9646\u65f6\u6240\u4f7f\u7528\u7684\u5bb6\u76ee\u5f55<\/td><\/tr>
-e<\/td>\u7528\u6237\u7ec8\u6b62\u65e5\u671f\uff0c\u65e5\u671f\u7684\u683c\u5f0f\u4e3aYYYY-MM-DD<\/td><\/tr>
-f<\/td>\u7528\u6237\u8fc7\u671f\u51e0\u65e5\u540e\u6c38\u4e45\u505c\u6743\u3002\u5f53\u503c\u4e3a0\u65f6\u7528\u6237\u7acb\u5373\u88ab\u505c\u6743\uff0c\u800c\u503c\u4e3a-1\u65f6\u5219\u5173\u95ed\u6b64\u529f\u80fd\uff0c\u9884\u8bbe\u503c\u4e3a-1<\/td><\/tr>
-g<\/td>\u6307\u5b9a\u7528\u6237\u5bf9\u5e94\u7684\u7528\u6237\u7ec4<\/td><\/tr>
-G<\/td>\u5b9a\u4e49\u6b64\u7528\u6237\u4e3a\u591a\u4e2a\u4e0d\u540c\u7ec4\u7684\u6210\u5458<\/td><\/tr>
-m<\/td>\u7528\u6237\u76ee\u5f55\u4e0d\u5b58\u5728\u65f6\u5219\u81ea\u52a8\u521b\u5efa<\/td><\/tr>
-M<\/td>\u4e0d\u5efa\u7acb\u7528\u6237\u5bb6\u76ee\u5f55\uff0c\u4f18\u5148\u4e8e\/etc\/login.defs\u6587\u4ef6\u8bbe\u5b9a<\/td><\/tr>
-n<\/td>\u53d6\u6d88\u5efa\u7acb\u4ee5\u7528\u6237\u540d\u79f0\u4e3a\u540d\u7684\u7fa4\u7ec4 <\/td><\/tr>
-r<\/td>\u5efa\u7acb\u7cfb\u7edf\u5e10\u53f7 <\/td><\/tr>
-u<\/td>\u6307\u5b9a\u7528\u6237id <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u521b\u5efa\u6307\u5b9a\u7684\u7528\u6237\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# useradd user1<\/strong><\/pre>\n\n\n\n

\u521b\u5efa\u6307\u5b9a\u7684\u7528\u6237\u4fe1\u606f\uff0c\u4f46\u4e0d\u521b\u5efa\u5bb6\u76ee\u5f55\uff0c\u4ea6\u4e0d\u8ba9\u767b\u5f55\u7cfb\u7edf\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# useradd -M -s \/sbin\/nologin user2<\/strong><\/pre>\n\n\n\n

\u521b\u5efa\u6307\u5b9a\u7684\u7528\u6237\u4fe1\u606f\uff0c\u5e76\u81ea\u5b9a\u4e49UID\u503c\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# useradd -u 6688 user3<\/strong><\/pre>\n\n\n\n

\u521b\u5efa\u6307\u5b9a\u7684\u7528\u6237\u4fe1\u606f\uff0c\u5e76\u8ffd\u52a0\u6307\u5b9a\u7ec4\u4e3a\u8be5\u8d26\u6237\u7684\u6269\u5c55\u7ec4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# useradd -G root user4<\/strong><\/pre>\n\n\n\n

\u521b\u5efa\u6307\u5b9a\u7684\u7528\u6237\u4fe1\u606f\uff0c\u5e76\u6307\u5b9a\u8fc7\u671f\u65f6\u95f4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# useradd -e \"2023\/01\/01\" user5<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"

useradd\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cUser add\u201d\u7684\u5168\u62fc\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u521b\u5efa\u5e76\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\u3002\u4f7f\u7528useradd […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/377"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":10,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"predecessor-version":[{"id":9351,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/377\/revisions\/9351"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}