{"id":2452,"date":"2016-01-20T11:17:58","date_gmt":"2016-01-20T11:17:58","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=2452"},"modified":"2025-04-26T13:49:49","modified_gmt":"2025-04-26T12:49:49","slug":"sudo","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/command-line\/sudo","title":{"rendered":"sudo"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Becoming the root user<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Which users are allowed to use sudo<\/h4>\n\n\n\n<p>\nYou can use this command to open the sudoers file:\n<\/p>\n\n\n\n<p>\nsudo nano \/etc\/sudoers\n<\/p>\n\n\n\n<p>\nBE VERY CAREFUL TO COPY THIS FILE BEFORE YOU CHANGE IT &#8211; IF YOU MAKE AN ERROR YOU CAN STOP YOURSELF BEING ABLE TO OPEN THE FILE USING&nbsp;SUDO (changes to it are instant)!\n<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Grandting\u00a0permission for specific\u00a0uses of sudo<\/h5>\n\n\n\n<p>\nThese&nbsp;example let&nbsp;Apache use sudo&nbsp;within web pages to access particular named files (to avoid giving the apache user account www-data global sudo access which would be a security risk)\n<\/p>\n\n\n\n<p>\nAn example enabling it to run a single executible, add this to the end of the file:\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>www-data ALL=NOPASSWD: \/home\/pi\/some_executable_name<\/code><\/pre>\n\n\n\n<p>\nAn example enabling it to run several different&nbsp;executables, add this to the end of the file:\n<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>www-data ALL=NOPASSWD: \/home\/pi\/some_executable_name, \/home\/pi\/some_executable_name some_option, \/home\/pi\/some_other_executable_name<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Becoming root on the command time for a few commands<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -i\n\n&#91;User is now root, you can use any commands without needing sudo]\n\nexit<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Becoming the root user Which users are allowed to use sudo You can use this command to open the sudoers file: sudo nano \/etc\/sudoers BE VERY CAREFUL TO COPY THIS FILE BEFORE YOU CHANGE IT &#8211; IF YOU MAKE AN ERROR YOU CAN STOP YOURSELF BEING ABLE TO OPEN THE FILE USING&nbsp;SUDO (changes to it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-2452","post","type-post","status-publish","format-standard","hentry","category-command-line"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=2452"}],"version-history":[{"count":3,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2452\/revisions"}],"predecessor-version":[{"id":3895,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2452\/revisions\/3895"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=2452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=2452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=2452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}