{"id":474,"date":"2019-06-10T11:25:03","date_gmt":"2019-06-10T03:25:03","guid":{"rendered":"http:\/\/www.laihp.top\/wordpress\/?p=474"},"modified":"2019-08-26T15:47:07","modified_gmt":"2019-08-26T07:47:07","slug":"ubuntu16-04%e7%b3%bb%e7%bb%9f%e4%b8%ad%e5%88%9b%e5%bb%ba%e6%96%b0%e7%94%a8%e6%88%b7","status":"publish","type":"post","link":"https:\/\/www.laihp.top\/zqb\/?p=474","title":{"rendered":"Ubuntu16.04\u7cfb\u7edf\u4e2d\u521b\u5efa\u65b0\u7528\u6237"},"content":{"rendered":"<p>\u672c\u6587\u57fa\u4e8eLinux\u7684Ubuntu\u7cfb\u7edf\u65b0\u5efa\u4e00\u4e2a\u666e\u901a\u7528\u6237\uff0clinux\u7cfb\u7edf\u7684\u7528\u6237\u540d\u4e3apeng, \u4e3b\u673a\u540d\u4e3aubuntu<\/p>\n<p>1. \u65b0\u5efa\u7528\u6237<br \/>\n2. \u5141\u8bb8\u8be5\u7528\u6237\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u6267\u884c\u6307\u4ee4<br \/>\n1. \u65b0\u5efa\u7528\u6237<br \/>\n1.1 \u65b0\u5efa\u53ea\u80fd\u5728\u63a7\u5236\u53f0\u4e0b\u767b\u5f55\u7684\u7528\u6237<br \/>\n1) \u5207\u6362\u4e3aroot\u7528\u6237\u4e3a\u4e86\u83b7\u53d6\u521b\u5efa\u7528\u6237\u7684\u6743\u9650<br \/>\npeng@ubuntu:~$ sudo su<br \/>\n1<br \/>\n2) \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7528\u6237\uff08\u5982\u7528\u6237\u540d\u4e3acsdn\uff09<br \/>\nroot@ubuntu:\/home\/peng# useradd csdn<br \/>\n1<br \/>\n3) \u4e3a\u8be5\u7528\u6237\u8bbe\u5b9a\u767b\u5f55\u5bc6\u7801<br \/>\nroot@ubuntu:\/home\/peng# passwd csdn<br \/>\n1<\/p>\n<p>&nbsp;<\/p>\n<p>4) \u4e3a\u8be5\u7528\u6237\u6307\u5b9a\u547d\u4ee4\u89e3\u91ca\u7a0b\u5e8f\uff08\u901a\u5e38\u4e3a\/bin\/bash\uff09<br \/>\nroot@ubuntu:\/home\/peng# usermod -s \/bin\/bash csdn<br \/>\n1<br \/>\n5) \u4e3a\u8be5\u7528\u6237\u6307\u5b9a\u7528\u6237\u4e3b\u76ee\u5f55<br \/>\nroot@ubuntu:\/home\/peng# usermod -d \/home\/csdn csdn<br \/>\n1<br \/>\n6\uff09 \u67e5\u770b\u7528\u6237\u7684\u5c5e\u6027<br \/>\nroot@ubuntu:\/home\/peng# cat \/etc\/passwd<br \/>\n1<\/p>\n<p>&nbsp;<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5df2\u7ecf\u5b58\u5728csdn\u8fd9\u4e2a\u7528\u6237\u3002\/etc\/passwd\u4e2d\u4e00\u884c\u8bb0\u5f55\u5bf9\u5e94\u7740\u4e00\u4e2a\u7528\u6237\uff0c\u6bcf\u884c\u8bb0\u5f55\u53c8\u88ab\u5192\u53f7(:)\u5206\u9694\u4e3a7\u4e2a\u5b57\u6bb5\uff0c\u5176\u683c\u5f0f\u548c\u5177\u4f53\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n<p>\u7528\u6237\u540d:\u53e3\u4ee4:\u7528\u6237\u6807\u8bc6\u53f7:\u7ec4\u6807\u8bc6\u53f7:\u6ce8\u91ca\u6027\u63cf\u8ff0:\u7528\u6237\u4e3b\u76ee\u5f55:\u547d\u4ee4\u89e3\u91ca\u7a0b\u5e8f<\/p>\n<p>7\uff09 \u5207\u6362\u5230\u7528\u6237csdn<br \/>\nroot@ubuntu:\/home\/peng# su csdn<br \/>\n1<br \/>\n\u5207\u6362\u540e\u5982\u4e0b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u767b\u9646\u4ee5\u540e\u7684\u7528\u6237csdn\u5f53\u524d\u6240\u5728\u76ee\u5f55\u4ecd\u4e3a\u201c\/home\/peng\u201d\uff0c\u5373\u7528\u6237peng\u7684\u4e3b\u76ee\u5f55\u3002<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ea\u80fd\u5728\u63a7\u5236\u53f0\u4e2d\u4e92\u76f8\u5207\u6362\u7528\u6237\uff0c\u4e00\u65e6\u91cd\u542f\u7cfb\u7edf\uff0c\u7528\u8be5\u7528\u6237\u8fd8\u662f\u65e0\u6cd5\u767b\u9646\uff08\u53ea\u80fd\u7528\u539f\u6765\u7684\u7528\u6237\u6216root\u767b\u9646\uff09\u3002<\/p>\n<p>1.2 \u65b0\u5efa\u53ef\u767b\u5f55\u56fe\u5f62\u7528\u6237\u754c\u9762\u7684\u7528\u6237<br \/>\n1) \u5207\u6362\u4e3aroot\u7528\u6237\u4e3a\u4e86\u83b7\u53d6\u521b\u5efa\u7528\u6237\u7684\u6743\u9650<br \/>\npeng@ubuntu:~$ sudo su<br \/>\n1<br \/>\n2\uff09\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7528\u6237\uff08\u5982\u7528\u6237\u540d\u4e3acsdn\uff09<br \/>\nroot@ubuntu:\/home\/peng# adduser csdn<br \/>\n1<br \/>\n\u7136\u540e\u6839\u636e\u7cfb\u7edf\u63d0\u793a\u8fdb\u884c\u5bc6\u7801\u548c\u6ce8\u91ca\u6027\u63cf\u8ff0\u7684\u914d\u7f6e\uff0c\u5168\u7a0b\u4e0d\u7528\u81ea\u5df1\u8f93\u5165\u5176\u4ed6\u547d\u4ee4\u5373\u53ef\u914d\u7f6e\u6210\u529f\uff0c\u7528\u6237\u4e3b\u76ee\u5f55\u548c\u547d\u4ee4\u89e3\u6790\u7a0b\u5e8f\u90fd\u662f\u7cfb\u7edf\u81ea\u52a8\u6307\u5b9a\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>3\uff09 \u67e5\u770b\u7528\u6237\u7684\u5c5e\u6027<br \/>\nroot@ubuntu:\/home\/peng# cat \/etc\/passwd<br \/>\n1<\/p>\n<p>&nbsp;<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u4e0e1.1\u76f8\u6bd4\uff0c\u8fd9\u91cc\u591a\u4e86\u6211\u4eec\u521a\u624d\u4e3a\u7528\u6237\u6307\u5b9a\u7684\u7528\u6237\u5168\u540dCSDN\u3002<\/p>\n<p>4\uff09 \u9000\u51fa\u5f53\u524d\u7528\u6237\uff0c\u4ee5\u7528\u6237csdn\u767b\u9646\u7cfb\u7edf<\/p>\n<p>&nbsp;<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u767b\u9646\u4ee5\u540e\u7684\u7528\u6237csdn\u5f53\u524d\u6240\u5728\u76ee\u5f55\u4e3a~\uff0c\u5373\u201c\/home\/csdn\u201d\u3002<\/p>\n<p>1.3 \u4e8c\u8005\u547d\u4ee4\u7684\u5dee\u522b<br \/>\n\u4e24\u79cd\u65b9\u5f0f\u6700\u5927\u7684\u5dee\u522b\u5728\u4e8e\u65b0\u5efa\u7528\u6237\u7684\u547d\u4ee4\u4e0d\u540c\uff0c\u7b2c\u4e00\u79cd\u662fuseradd, \u7b2c\u4e8c\u79cd\u662fadduser\u3002\u76f8\u5bf9\u5e94\u7684\uff0c\u5982\u679c\u8981\u5220\u9664\u7528\u6237\uff0c\u7b2c\u4e00\u79cd\u7684\u547d\u4ee4\u4e3auserdel, \u7b2c\u4e8c\u79cd\u662fdeluser.<\/p>\n<p>2. \u5141\u8bb8\u8be5\u7528\u6237\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u6267\u884c\u6307\u4ee4<br \/>\n\u5f53\u6211\u4eec\u5728\u6307\u4ee4\u524d\u52a0\u5165\u201csudo\u201d\u6267\u884c\u4e00\u4e9b\u6307\u4ee4\u65f6\uff08\u5982\u5207\u6362\u5230root\u7528\u6237\uff09\uff0c\u4f1a\u51fa\u73b0\u9519\u8bef\uff1a<\/p>\n<p>csdn is not in the sudoers file. This incident will be reported.<\/p>\n<p>&nbsp;<\/p>\n<p>1\uff09\u518d\u6b21\u5207\u6362\u5230root\u7528\u6237\uff08\u4e0d\u8981\u7528sudo su, \u800c\u7528su root\uff09<br \/>\ncsdn@ubuntu:\/home\/peng$ su root<br \/>\n1<br \/>\n\u5982\u679c\u8fd9\u91cc\u63d0\u793a\u201csu: Authentication failure\u201d\uff0c\u662f\u56e0\u4e3a\u6ca1\u6709\u7ed9root\u8bbe\u7f6e\u767b\u5f55\u5bc6\u7801\uff0c\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n1.\u5148\u5207\u6362\u56de\u7528\u6237peng: su peng<br \/>\n2.\u5728\u7ed9root\u8bbe\u7f6e\u767b\u5f55\u5bc6\u7801\uff1asudo passwd root<\/p>\n<p>2\uff09\u6267\u884cvisudo\u547d\u4ee4<br \/>\ncsdn@ubuntu:\/home\/peng$ visudo<br \/>\n1<br \/>\n3\uff09\u8be5\u547d\u4ee4\u5b9e\u9645\u4e0a\u6253\u5f00\u7684\u662f\/etc\/sudoers\u6587\u4ef6\uff0c\u4fee\u6539\u8be5\u6587\u4ef6\uff0c\u5728\u201croot ALL=(ALL:ALL) ALL\u201d\u8fd9\u4e00\u884c\u4e0b\u9762\u52a0\u5165\u4e00\u884c\uff1a<br \/>\ncsdn ALL=(ALL:ALL) ALL<\/p>\n<p>ctrl+o\uff08\u7136\u540e\u518d\u6309enter\uff09\u4fdd\u5b58\uff0cctrl+c\u53d6\u6d88\uff0cctrl+x\u9000\u51fa<\/p>\n<p>&nbsp;<\/p>\n<p>4\uff09\u5207\u6362\u56decsdn<br \/>\nroot@ubuntu:\/home\/peng# su csdn<br \/>\n1<br \/>\n5) \u7528sudo su\u518d\u6b21\u767b\u5f55root<br \/>\ncsdn@ubuntu:\/home\/peng$ sudo su<br \/>\n1<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u7528\u6237csdn\u5c31\u53ef\u4ee5\u7528\u7528sudo\u547d\u4ee4\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u6267\u884c\u6307\u4ee4\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u539f\u6587\uff1ahttps:\/\/blog.csdn.net\/timothy93bp\/article\/details\/77679000<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u57fa\u4e8eLinux\u7684Ubuntu\u7cfb\u7edf\u65b0\u5efa\u4e00\u4e2a\u666e\u901a\u7528\u6237\uff0clinux\u7cfb\u7edf\u7684\u7528\u6237\u540d\u4e3apeng, \u4e3b\u673a\u540d\u4e3aubuntu &#8230; <a title=\"Ubuntu16.04\u7cfb\u7edf\u4e2d\u521b\u5efa\u65b0\u7528\u6237\" class=\"read-more\" href=\"https:\/\/www.laihp.top\/zqb\/?p=474\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbUbuntu16.04\u7cfb\u7edf\u4e2d\u521b\u5efa\u65b0\u7528\u6237\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-474","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=474"}],"version-history":[{"count":1,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions\/475"}],"wp:attachment":[{"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laihp.top\/zqb\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}