{"id":17505,"date":"2024-11-27T13:40:50","date_gmt":"2024-11-27T05:40:50","guid":{"rendered":"https:\/\/icop-shop.com\/?p=17505"},"modified":"2024-11-27T14:41:19","modified_gmt":"2024-11-27T06:41:19","slug":"run-sudo-command-without-a-password-on-linux","status":"publish","type":"post","link":"https:\/\/icop-shop.com\/zh\/technical-tips\/run-sudo-command-without-a-password-on-linux\/","title":{"rendered":"\u5728 Linux \u4e0a\u57f7\u884c sudo \u6307\u4ee4\u6642\u4e0d\u9700\u8981\u8f38\u5165\u5bc6\u78bc"},"content":{"rendered":"<p>\u82e5\u8981\u5728 Linux \u4e0a\u57f7\u884c sudo \u6307\u4ee4\u6642\u4e0d\u9700\u8981\u8f38\u5165\u5bc6\u78bc\uff0c\u53ef\u4ee5\u4fee\u6539 sudoers \u6a94\u6848\uff0c\u70ba\u7279\u5b9a\u4f7f\u7528\u8005\u6216\u4f7f\u7528\u8005\u7fa4\u7d44\u6388\u4e88\u6b64\u6b0a\u9650\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7de8\u8f2f sudoers \u6a94\u6848<\/h2>\n\n\n\n<p>1. \u958b\u555f\u7d42\u7aef\u6a5f\u3002<\/p>\n\n\n\n<p>2. \u4f7f\u7528 visudo \u6307\u4ee4\u7de8\u8f2f sudoers \u6a94\u6848\u3002\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u6a94\u6848\u88ab\u9396\u5b9a\uff0c\u9632\u6b62\u540c\u6642\u9032\u884c\u591a\u91cd\u7de8\u8f2f\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>sudo visudo<\/code><\/p>\n\n\n\n<p>3. \u65b0\u589e\u4e00\u884c\u8a2d\u5b9a\uff0c\u6388\u4e88\u7121\u9700\u5bc6\u78bc\u7684 sudo \u6b0a\u9650\u3002<\/p>\n\n\n\n<p>\u91dd\u5c0d\u7279\u5b9a\u4f7f\u7528\u8005\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>username ALL=(ALL) NOPASSWD: ALL<\/code><\/p>\n\n\n\n<p>\u91dd\u5c0d\u7279\u5b9a\u7fa4\u7d44\uff08\u5c07 groupname \u66ff\u63db\u70ba\u5be6\u969b\u7684\u7fa4\u7d44\u540d\u7a31\uff09\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>%groupname ALL=(ALL) NOPASSWD: ALL<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-ast-global-color-4-color has-alpha-channel-opacity has-ast-global-color-4-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\uff1a\u6388\u4e88\u4f7f\u7528\u8005\u7121\u9700\u5bc6\u78bc\u7684 sudo \u6b0a\u9650<\/h2>\n\n\n\n<p>\u5982\u679c\u4f60\u7684\u4f7f\u7528\u8005\u540d\u7a31\u662f john\uff0c\u4f60\u61c9\u8a72\u65b0\u589e\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>john ALL=(ALL) NOPASSWD: ALL<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5132\u5b58\u4e26\u9000\u51fa<\/h3>\n\n\n\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f nano \u7de8\u8f2f\u5668\uff08\u5728\u67d0\u4e9b\u7cfb\u7d71\u4e2d\u5b83\u662f visudo \u7684\u9810\u8a2d\u7de8\u8f2f\u5668\uff09\uff0c\u8acb\u6309\u4e0b Ctrl+X\uff0c\u7136\u5f8c\u8f38\u5165 Y\uff0c\u518d\u6309\u4e0b Enter \u4ee5\u5132\u5b58\u4e26\u9000\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9a57\u8b49<\/h3>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u900f\u904e\u57f7\u884c\u4e00\u689d sudo \u6307\u4ee4\u4f86\u9032\u884c\u6e2c\u8a66\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>sudo ls \/root<\/code><\/p>\n\n\n\n<p>\u5982\u679c\u8a2d\u5b9a\u6b63\u78ba\uff0c\u7cfb\u7d71\u5c07\u4e0d\u6703\u518d\u8981\u6c42\u4f60\u8f38\u5165\u5bc6\u78bc\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"How to run sudo command without a password on Linux\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/I4wT2DtNA6k?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--20)\">\u5c07\u7cfb\u7d71\u6642\u9418\u8207 RTC\uff08\u5be6\u6642\u6642\u9418\uff09\u540c\u6b65\uff1a<\/h2>\n\n\n\n<p><strong>\u2022 \u5b89\u5168\u98a8\u96aa\uff1a<\/strong>&nbsp;\u6388\u4e88\u7121\u9700\u5bc6\u78bc\u7684 sudo \u6b0a\u9650\u53ef\u80fd\u6703\u5e36\u4f86\u5b89\u5168\u98a8\u96aa\uff0c\u7279\u5225\u662f\u5728\u5e33\u865f\u906d\u5165\u4fb5\u7684\u60c5\u6cc1\u4e0b\u3002\u8acb\u8b39\u614e\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><strong>\u2022  Scope:<\/strong>&nbsp;\u4f60\u53ef\u4ee5\u900f\u904e\u6307\u5b9a\u7279\u5b9a\u6307\u4ee4\u4f86\u9650\u5236\u7121\u9700\u5bc6\u78bc\u7684 sudo \u6b0a\u9650\u7bc4\u570d\uff0c\u800c\u4e0d\u662f\u4f7f\u7528 ALL\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<p class=\"has-ast-global-color-1-color has-text-color\"><code>john ALL=(ALL) NOPASSWD: \/usr\/bin\/apt-get, \/usr\/bin\/systemctl<\/code><\/p>\n\n\n\n<p>\u6b64\u8a2d\u5b9a\u5141\u8a31\u4f7f\u7528\u8005 john \u5728\u57f7\u884c apt-get \u548c systemctl \u6307\u4ee4\u6642\u7121\u9700\u8f38\u5165\u5bc6\u78bc\uff0c\u4f46\u5176\u4ed6 sudo \u6307\u4ee4\u4ecd\u9700\u5bc6\u78bc\u3002<br>\u900f\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7684 Linux \u7cfb\u7d71\u4e0a\u8a2d\u5b9a\u7121\u9700\u5bc6\u78bc\u7684 sudo \u6b0a\u9650\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-ast-global-color-4-color has-alpha-channel-opacity has-ast-global-color-4-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\">\u7e7c\u7e8c\u95b1\u8b80\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li style=\"margin-top:var(--wp--preset--spacing--20)\"><a href=\"https:\/\/www.compactpc.com.tw\/datas\/upload\/files\/video\/Technical%20video\/EB-58%20Series%20Lubuntu%2022.04.4%20LTS%20installation%20guide.mp4\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">\u5982\u4f55\u5728EBOX-58E\u4e0a\u5b89\u88ddUbuntu<\/mark><\/a><\/li>\n\n\n\n<li style=\"line-height:1.5\"><a href=\"https:\/\/icop-shop.com\/zh\/technical-tips\/install-docker-on-ubuntu-22-04-lts\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">\u5728 Ubuntu \u4e0a\u5b89\u88dd Docker<\/mark><\/a><\/li>\n\n\n\n<li style=\"line-height:1.5\"><a href=\"https:\/\/icop-shop.com\/zh\/technical-tips\/running-linux-containers-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">\u5728 Ubuntu \u4e0a\u904b\u884c Linux Containers<\/mark><\/a><\/li>\n\n\n\n<li style=\"line-height:1.5\"><a href=\"https:\/\/icop-shop.com\/zh\/technical-tips\/ebox-mini-pc-ubuntu-12-04-non-pae-installation-guide\/\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">EBOX Mini PC \u5b89\u88dd Ubuntu 12.04 \u975e PAE \u6307\u5357<\/mark><\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-ast-global-color-4-color has-alpha-channel-opacity has-ast-global-color-4-background-color has-background is-style-wide\" style=\"margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)\"\/>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p class=\"has-text-align-left\" style=\"margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)\"><img decoding=\"async\" class=\"wp-image-5603\" style=\"width: 500px;\" src=\"https:\/\/icop-shop.com\/wp-content\/uploads\/2024\/11\/EB-3362-L2C2_article.png\" alt=\"EBOX-58N f\" title=\"\"><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p class=\"has-medium-font-size\" style=\"margin-top:var(--wp--preset--spacing--40);margin-bottom:var(--wp--preset--spacing--40);line-height:1.5\"><strong>\u4e3b\u8981\u7279\u9ede&nbsp;<a href=\"https:\/\/icop-shop.com\/zh\/product\/eb-3362-l2c2\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">EB-3362-L2C2<\/mark><\/a>:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li style=\"line-height:1.5\">DM&amp;P 32-bit x86 Vortex86DX3 \u96d9\u6838 1.0GHz SoC<\/li>\n\n\n\n<li style=\"line-height:1.5\">2GB DDR3-1600MHz \u677f\u8f09<\/li>\n\n\n\n<li style=\"line-height:1.5\">SD \u5361\u63d2\u69fd x1 (SD\u3001SDXC)\u30011 Gbps LAN x1\u300110 \/ 100 Mbps LAN x1\u3001USB x4 (\u524d\u7f6e x2\u3001\u5f8c\u7f6e x1\u3001\u5167\u7f6e x1)\u3001\u6709\u7dda\u8f38\u51fa x1\u3001RS-232 x2<\/li>\n\n\n\n<li style=\"line-height:1.5\">\u652f\u63f4 Auto Power On \u81ea\u52d5\u958b\u6a5f<\/li>\n\n\n\n<li style=\"line-height:1.5\">PXE \u7db2\u8def\u958b\u6a5f<\/li>\n\n\n\n<li style=\"line-height:1.5\">DC +8V ~ +24V<\/li>\n\n\n\n<li style=\"line-height:1.5\">Operation Temperature: 0\u00b0C~+60\u00b0C<\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator alignwide has-text-color has-ast-global-color-4-color has-alpha-channel-opacity has-ast-global-color-4-background-color has-background is-style-wide\" style=\"margin-bottom:var(--wp--preset--spacing--30)\"\/>\n\n\n\n<p style=\"margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20)\">\u5982\u9700\u66f4\u591a\u8cc7\u8a0a\u548c\u6a23\u54c1\u9700\u6c42\uff0c\u8acb\u5beb\u4fe1\u81f3&nbsp;<a href=\"mailto:info@icop.com.tw\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">info@icop.com.tw<\/mark><\/a>\uff0c\u6216\u81f4\u96fb\u96e2\u60a8\u6700\u8fd1\u7684&nbsp;<a href=\"https:\/\/www.icop.com.tw\/branches\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">ICOP \u5206\u516c\u53f8<\/mark><\/a>\uff0c\u6216\u806f\u7e6b\u6211\u5011\u7684&nbsp;<a href=\"https:\/\/www.icop.com.tw\/distributors\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-1-color\">\u5168\u7403\u6388\u6b0a\u7d93\u92b7\u5546<\/mark>.<\/a><\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>To run sudo commands without being prompted for a password on Linux, you can modify the sudoers file to grant this permission to a specific user or group. Edit the sudoers File 1. Open a terminal. 2. Edit the sudoers file using the visudo command. This ensures that the file [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":17507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[284],"tags":[278],"class_list":["post-17505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-tips","tag-ebox-mini-pc"],"_links":{"self":[{"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/posts\/17505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/comments?post=17505"}],"version-history":[{"count":0,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/posts\/17505\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/media\/17507"}],"wp:attachment":[{"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/media?parent=17505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/categories?post=17505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icop-shop.com\/zh\/wp-json\/wp\/v2\/tags?post=17505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}