{"id":2187,"date":"2019-04-25T16:24:12","date_gmt":"2019-04-25T08:24:12","guid":{"rendered":"http:\/\/akidea.cn\/wordpress\/?p=2187"},"modified":"2019-04-25T16:24:12","modified_gmt":"2019-04-25T08:24:12","slug":"01110","status":"publish","type":"post","link":"https:\/\/www.akidea.cn\/?p=2187","title":{"rendered":"\u5982\u4f55\u5728 Debian \u4e0a\u521b\u5efa sudo \u7528\u6237"},"content":{"rendered":"<p>sudo \u547d\u4ee4 (Super-user do \u7684\u7f29\u5199) \u662f\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u88ab\u8bbe\u8ba1\u7528\u6765\u5141\u8bb8\u7528\u6237\u4f7f\u7528\u53e6\u4e00\u4e2a\u7528\u6237\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f root \u7528\u6237\uff09\u7684\u5b89\u5168\u6743\u9650\u6267\u884c\u547d\u4ee4\u3002<\/p>\n<p>\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728 Debian \u7cfb\u7edf\u4e0a\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u63d0\u4f9b sudo \u8bbf\u95ee\u6743\u9650\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u6b64\u7528\u6237\u5e10\u6237\u6267\u884c\u7ba1\u7406\u547d\u4ee4\uff0c\u800c\u65e0\u9700\u4ee5 root \u7528\u6237\u8eab\u4efd\u767b\u5f55 Debian \u670d\u52a1\u5668\u3002<!--more--><\/p>\n<h2 id=\"\u521b\u5efa\u4e00\u4e2a-sudo-\u7528\u6237\">\u521b\u5efa\u4e00\u4e2a sudo \u7528\u6237<\/h2>\n<p>\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa\u65b0\u7684\u7528\u6237\u5e10\u6237\u5e76\u4e3a\u5176\u63d0\u4f9b sudo \u8bbf\u95ee\u6743\u9650\u3002\u5982\u679c\u8981\u4e3a\u73b0\u6709\u7528\u6237\u914d\u7f6e sudo \uff0c\u8bf7\u8df3\u81f3\u7b2c 3 \u6b65\u3002<\/p>\n<ol>\n<li>\u767b\u5f55\u60a8\u7684\u670d\u52a1\u5668\u3002\u9996\u5148\uff0c\u4ee5 root \u7528\u6237\u8eab\u4efd\u767b\u5f55\u7cfb\u7edf\uff1a<br \/>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">ssh root@server_ip_address<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7528\u6237\u5e10\u6237\u3002\u4f7f\u7528\u00a0<code>adduser<\/code>\u00a0\u547d\u4ee4<a href=\"https:\/\/buzheng.org\/linux\/how-to-add-and-delete-users-on-debian-9.html\">\u521b\u5efa\u65b0\u7528\u6237\u5e10\u6237<\/a>\u3002\u4e0d\u8981\u5fd8\u8bb0\u628a\u00a0<code>username<\/code>\u00a0\u66ff\u6362\u4e3a\u60a8\u60f3\u8981\u7684\u7528\u6237\u540d\uff1a<br \/>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">adduser username<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u8be5\u547d\u4ee4\u5c06\u63d0\u793a\u60a8\u8bbe\u7f6e\u5e76\u786e\u8ba4\u65b0\u7684\u7528\u6237\u5bc6\u7801\u3002\u786e\u4fdd\u65b0\u5e10\u6237\u7684\u5bc6\u7801\u5c3d\u53ef\u80fd\u5b89\u5168\uff08\u5b57\u6bcd\uff0c\u6570\u5b57\u548c\u7279\u6b8a\u5b57\u7b26\u7684\u7ec4\u5408) \u3002<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span>\n<span class=\"line\">2<\/span>\n<span class=\"line\">3<\/span>\n<span class=\"line\">4<\/span>\n<span class=\"line\">5<\/span>\n<span class=\"line\">6<\/span>\n<span class=\"line\">7<\/span>\n<span class=\"line\">8<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">Adding user `username<span class=\"string\">' ...<\/span><\/span>\n<span class=\"line\"><span class=\"string\">Adding new group `username'<\/span> (1001) ...<\/span>\n<span class=\"line\">Adding new user `username<span class=\"string\">' (1001) with group `username'<\/span> ...<\/span>\n<span class=\"line\">Creating home directory `\/home\/username<span class=\"string\">' ...<\/span><\/span>\n<span class=\"line\"><span class=\"string\">Copying files from `\/etc\/skel'<\/span> ...<\/span>\n<span class=\"line\">New password:<\/span>\n<span class=\"line\">Retype new password:<\/span>\n<span class=\"line\">passwd: password updated successfully<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u8bbe\u7f6e\u7528\u6237\u5bc6\u7801\u540e\uff0c\u8be5\u547d\u4ee4\u5c06\u4e3a\u7528\u6237\u521b\u5efa\u4e3b\u76ee\u5f55\uff0c\u590d\u5236\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\u5230\u4e3b\u76ee\u5f55\u4e2d\uff0c\u5e76\u63d0\u793a\u60a8\u8bbe\u7f6e\u65b0\u7528\u6237\u7684\u4fe1\u606f\u3002\u5982\u679c\u60a8\u60f3\u5c06\u6240\u6709\u8fd9\u4e9b\u4fe1\u606f\u7559\u7a7a\uff0c\u53ea\u9700\u6309\u00a0<code>ENTER<\/code>\u00a0\u5373\u53ef\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span>\n<span class=\"line\">2<\/span>\n<span class=\"line\">3<\/span>\n<span class=\"line\">4<\/span>\n<span class=\"line\">5<\/span>\n<span class=\"line\">6<\/span>\n<span class=\"line\">7<\/span>\n<span class=\"line\">8<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">Changing the user information <span class=\"keyword\">for<\/span> username<\/span>\n<span class=\"line\">Enter the new value, or press ENTER <span class=\"keyword\">for<\/span> the default<\/span>\n<span class=\"line\">    Full Name []:<\/span>\n<span class=\"line\">    Room Number []:<\/span>\n<span class=\"line\">    Work Phone []:<\/span>\n<span class=\"line\">    Home Phone []:<\/span>\n<span class=\"line\">    Other []:<\/span>\n<span class=\"line\">Is the information correct? [Y\/n]<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<\/li>\n<li>\u5c06\u7528\u6237\u6dfb\u52a0\u5230\u00a0<code>sudo<\/code>\u00a0\u7ec4\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5728 Debian \u7cfb\u7edf\u4e0a\uff0c\u00a0<code>sudo<\/code>\u00a0\u7ec4\u7684\u6210\u5458\u88ab\u6388\u4e88 sudo \u8bbf\u95ee\u6743\u9650\u3002\u8981\u5c06\u7528\u6237\u6dfb\u52a0\u5230 sudo \u7ec4\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u00a0<code>usermod<\/code>\u00a0\u547d\u4ee4\uff1a<br \/>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">usermod -aG sudo username<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<\/li>\n<\/ol>\n<h2 id=\"\u6d4b\u8bd5-sudo-\u8bbf\u95ee\u6743\u9650\">\u6d4b\u8bd5 sudo \u8bbf\u95ee\u6743\u9650<\/h2>\n<p>\u5207\u6362\u5230\u65b0\u521b\u5efa\u7684\u7528\u6237\uff1a<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">su - username<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u4f7f\u7528 sudo \u547d\u4ee4\u8fd0\u884c\u00a0<code>whoami<\/code>\u00a0\u547d\u4ee4\uff1a<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">sudo whoami<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u5982\u679c\u7528\u6237\u5177\u6709 sudo \u8bbf\u95ee\u6743\u9650\uff0c\u5219\u00a0<code>whoami<\/code>\u00a0\u547d\u4ee4\u4f1a\u8f93\u51fa\u00a0<code>root<\/code>\u00a0\uff1a<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">root<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2 id=\"\u5982\u4f55\u4f7f\u7528-sudo\">\u5982\u4f55\u4f7f\u7528 sudo<\/h2>\n<p>\u8981\u4f7f\u7528 sudo \uff0c\u53ea\u9700\u5728\u547d\u4ee4\u524d\u52a0\u4e0a\u00a0<code>sudo<\/code>\u00a0\u524d\u7f00\u548c\u7a7a\u683c\uff1a<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">sudo ls -l \/root<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>\u7b2c\u4e00\u6b21\u5728\u4f1a\u8bdd\u4e2d\u4f7f\u7528 sudo \u65f6\uff0c\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u7528\u6237\u5bc6\u7801\uff1a<\/p>\n<figure class=\"highlight bash\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter\">\n<pre><span class=\"line\">1<\/span><\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"line\">[sudo] password <span class=\"keyword\">for<\/span> username:<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2 id=\"\u7ed3\u8bba\">\u7ed3\u8bba<\/h2>\n<p>\u60a8\u5df2\u7ecf\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528 sudo \u6743\u9650\u521b\u5efa\u7528\u6237\u3002\u60a8\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528\u6b64\u7528\u6237\u5e10\u6237\u767b\u5f55 Debian \u670d\u52a1\u5668\u5e76\u4f7f\u7528 sudo \u8fd0\u884c\u7ba1\u7406\u547d\u4ee4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sudo \u547d\u4ee4 (Super-user do \u7684\u7f29 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/www.akidea.cn\/index.php?rest_route=\/wp\/v2\/posts\/2187"}],"collection":[{"href":"https:\/\/www.akidea.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.akidea.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.akidea.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.akidea.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2187"}],"version-history":[{"count":0,"href":"https:\/\/www.akidea.cn\/index.php?rest_route=\/wp\/v2\/posts\/2187\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.akidea.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.akidea.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.akidea.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}