{"id":880,"date":"2019-04-25T11:41:01","date_gmt":"2019-04-25T03:41:01","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=880"},"modified":"2022-05-10T18:42:24","modified_gmt":"2022-05-10T10:42:24","slug":"sudo","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/sudo","title":{"rendered":"sudo\u547d\u4ee4 – \u6388\u6743\u666e\u901a\u7528\u6237\u6267\u884c\u7ba1\u7406\u5458\u547d\u4ee4"},"content":{"rendered":"\n

sudo\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201csuper user do\u201d\u7684\u7f29\u5199\uff0c\u4e2d\u6587\u8bd1\u4e3a\u201c\u8d85\u7ea7\u7528\u6237\u624d\u80fd\u5e72\u7684\u4e8b\u201d\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u6388\u6743\u666e\u901a\u7528\u6237\u6267\u884c\u7ba1\u7406\u5458\u547d\u4ee4\u3002\u4f7f\u7528su\u547d\u4ee4\u53d8\u66f4\u7528\u6237\u8eab\u4efd\u867d\u7136\u597d\u7528\uff0c\u4f46\u662f\u9700\u8981\u5c06\u7ba1\u7406\u5458\u7684\u8d26\u6237\u5bc6\u7801\u544a\u8bc9\u4ed6\u4eba\uff0c\u603b\u611f\u89c9\u5fc3\u91cc\u4e0d\u8e0f\u5b9e\uff0c\u5e78\u597d\u6709\u4e86sudo\u670d\u52a1\u3002<\/p>\n\n\n\n

\u4f7f\u7528sudo\u670d\u52a1\u53ef\u4ee5\u6388\u6743\u67d0\u4e2a\u6307\u5b9a\u7684\u7528\u6237\u53bb\u6267\u884c\u67d0\u4e9b\u6307\u5b9a\u7684\u547d\u4ee4\uff0c\u5728\u6ee1\u8db3\u5de5\u4f5c\u9700\u6c42\u7684\u524d\u63d0\u4e0b\u5c3d\u53ef\u80fd\u5c11\u7684\u653e\u6743\uff0c\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u5b89\u5168\u3002\u914d\u7f6esudo\u670d\u52a1\u53ef\u4ee5\u76f4\u63a5\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\/etc\/sudoers\uff0c\u4ea6\u53ef\u4ee5\u6267\u884cvisudo\u547d\u4ee4\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4e00\u5207\u59a5\u5f53\u540e\u666e\u901a\u7528\u6237\u4fbf\u80fd\u591f\u4f7f\u7528sudo\u547d\u4ee4\u8fdb\u884c\u64cd\u4f5c\u4e86\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>sudo [\u53c2\u6570] \u547d\u4ee4<\/p>\n\n\n\n

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

-v<\/td>\u672c\u6b21\u9700\u8981\u9a8c\u8bc1\u5f53\u524d\u7528\u6237\u7684\u5bc6\u7801<\/td><\/tr>
-k<\/td>\u4e0b\u6b21\u5f3a\u5236\u9a8c\u8bc1\u5f53\u524d\u7528\u6237\u7684\u5bc6\u7801<\/td><\/tr>
-b<\/td>\u5c06\u8981\u6267\u884c\u7684\u6307\u4ee4\u653e\u5728\u540e\u53f0\u6267\u884c <\/td><\/tr>
-p<\/td>\u66f4\u6539\u9700\u8981\u5bc6\u7801\u9a8c\u8bc1\u65f6\u7684\u63d0\u793a\u8bed<\/td><\/tr>
-s<\/td>\u6307\u5b9a\u9ed8\u8ba4\u8c03\u7528\u7684SHELL\u89e3\u91ca\u5668<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

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

\u67e5\u770b\u5f53\u524d\u7528\u6237\u6709\u54ea\u4e9b\u88absudo\u670d\u52a1\u6388\u6743\u7684\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[linuxprobe@linuxcool ~]$ sudo -l<\/strong>\r\nWe trust you have received the usual lecture from the local System\r\nAdministrator. It usually boils down to these three things:\r\n\r\n    #1) Respect the privacy of others.\r\n    #2) Think before you type.\r\n    #3) With great power comes great responsibility.\r\n\r\n[sudo] password for linuxprobe: \u6b64\u5904\u8f93\u5165\u5f53\u524d\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\nMatching Defaults entries for linuxprobe on localhost:\r\n    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin,\r\n    env_reset, env_keep=\"COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS\",\r\n    env_keep+=\"MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE\",\r\n    env_keep+=\"LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES\",\r\n    env_keep+=\"LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE\",\r\n    env_keep+=\"LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY\",\r\n    secure_path=\/sbin\\:\/bin\\:\/usr\/sbin\\:\/usr\/bin\r\n\r\nUser linuxprobe may run the following commands on localhost:\r\n    (ALL) ALL<\/pre>\n\n\n\n

\u4f7f\u7528\u67d0\u4e2a\u88absudo\u670d\u52a1\u5141\u8bb8\u7684\u7528\u6237\u8eab\u4efd\u6765\u6267\u884c\u7ba1\u7406\u5458\u7684\u91cd\u542f\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# sudo -u linuxprobe \"reboot\"<\/strong><\/pre>\n\n\n\n

\u4f7f\u7528\u5f53\u524d\u7528\u6237\u8eab\u4efd\uff0c\u57fa\u4e8esudo\u547d\u4ee4\u6765\u6267\u884c\u7ba1\u7406\u5458\u7684\u91cd\u542f\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# sudo reboot<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"

sudo\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201csuper user do\u201d\u7684\u7f29\u5199\uff0c\u4e2d\u6587\u8bd1\u4e3a\u201c\u8d85\u7ea7\u7528\u6237\u624d\u80fd\u5e72\u7684\u4e8b\u201d\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u6388 […]<\/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\/880"}],"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=880"}],"version-history":[{"count":11,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/880\/revisions"}],"predecessor-version":[{"id":9489,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/880\/revisions\/9489"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}