{"id":2194,"date":"2015-08-07T14:57:17","date_gmt":"2015-08-07T14:57:17","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2194"},"modified":"2015-08-07T14:57:17","modified_gmt":"2015-08-07T14:57:17","slug":"sudo-file-explained","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2194","title":{"rendered":"Sudo file explained"},"content":{"rendered":"<p>In the following\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo<\/div><\/div>\n<p>\u00a0entry:<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">superadm &nbsp;ALL=(ALL) &nbsp; ALL<\/div><\/div>\n\n<\/pre>\n<p>there are four fields:<\/p>\n<ul>\n<li>The first one specifies a user that will be granted privileges for some command(s).<\/li>\n<li>The second one is rarely used. It&#8217;s a list of hostnames on which this sudo entry will be effective. On standard setups only one host is relevant (localhost) so this field is usually left as\u00a0\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ALL<\/div><\/div>\n<p>.<\/li>\n<li>The\u00a0<em>fourth<\/em>\u00a0field is the list of commands\u00a0\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">superadm<\/div><\/div>\n<p>\u00a0will be able to run with elevated privileges.\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ALL<\/div><\/div>\n<p>\u00a0means all commands. Otherwise use a comma-separated list of commands.<\/li>\n<li>The third field (the one written\u00a0\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">(\u2026)<\/div><\/div>\n<p>\u00a0that is optional) specifies which users (and groups) the\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">superadm<\/div><\/div>\n<p>\u00a0user will be able to run the following commands as.\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ALL<\/div><\/div>\n<p>\u00a0means they can chose anything (unrestricted). It this field is omitted, it means the same as\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">(root)<\/div><\/div>\n<p>.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">alan &nbsp; ALL = (root, bin : operator, system) \/bin\/ls, \/bin\/kill<\/div><\/div>\n\n<\/pre>\n<p>Here,\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">alan<\/div><\/div>\n<p>\u00a0is allowed to run the two commands\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">\/bin\/ls<\/div><\/div>\n<p>\u00a0and\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">\/bin\/kill<\/div><\/div>\n<p>\u00a0as\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">root<\/div><\/div>\n<p>\u00a0(or\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">bin<\/div><\/div>\n<p>), possibly with additional\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">operator<\/div><\/div>\n<p>\u00a0or\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">system<\/div><\/div>\n<p>\u00a0groups privileges.<\/p>\n<p>So\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">alan<\/div><\/div>\n<p>\u00a0may chose to run\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ls<\/div><\/div>\n<p>\u00a0as the\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">bin<\/div><\/div>\n<p>\u00a0user and with\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">operator<\/div><\/div>\n<p>&#8216;s group privileges like this:<\/p>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">sudo -u bin -g operator \/bin\/ls \/whatever\/directory<\/div><\/div>\n\n<\/pre>\n<p>If\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">-u<\/div><\/div>\n<p>\u00a0is omitted, it&#8217;s the same as\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">-u root<\/div><\/div>\n<p>. If\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">-g<\/div><\/div>\n<p>\u00a0is omitted, no additional group privileges are granted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the following\u00a0 sudo \u00a0entry: superadm &nbsp;ALL=(ALL) &nbsp; ALL there are four fields: The first one specifies a user that will be [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2194","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2194"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2194\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}