<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Giving sudo access to whole directory, some files and start &amp;amp; stop the service in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6076805#M54299</link>
    <description>Hi Matt,&lt;BR /&gt;&lt;BR /&gt;I have done following:&lt;BR /&gt;&lt;BR /&gt;Host_Alias xyz = xyz1, xyz2&lt;BR /&gt;&lt;BR /&gt;Cmnd_Alias abc = /etc/init.d/httpd start, \&lt;BR /&gt;/etc/init.d/httpd restart, \&lt;BR /&gt;/etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;john xyz = (root) NOPASSWD: abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But it is giving following error.&lt;BR /&gt;&lt;BR /&gt;xyz1# su - john&lt;BR /&gt;su: warning: cannot change directory to /home/john: No such file or directory&lt;BR /&gt;&lt;BR /&gt;-bash-3.2$ sudo /etc/init.d/httpd restart&lt;BR /&gt;Sorry, user john is not allowed to execute '/etc/init.d/httpd restart' as john on xyz1.&lt;BR /&gt;</description>
    <pubDate>Wed, 22 May 2013 22:14:05 GMT</pubDate>
    <dc:creator>Senthil_N</dc:creator>
    <dc:date>2013-05-22T22:14:05Z</dc:date>
    <item>
      <title>Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6073489#M54287</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to give sudo access but it is not working successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirements are&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)How to give sudo access for particular directory like the user who is having sudo can modify / delete / create new files / sub-directory with in given directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)How to give modify (edit) permission through sudo for particular file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3)How to give sudo access for star and stop the service. for say. /etc/init.d/httpd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4)How to give sudo access for installing one software.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2013 15:23:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6073489#M54287</guid>
      <dc:creator>Senthil_N</dc:creator>
      <dc:date>2013-05-20T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6073667#M54288</link>
      <description>&lt;P&gt;1) For this, sudo is not the right tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is much easier to use directory permissions (and, if necessary, ACLs) for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If exactly one user needs to access the directory, use chown to give him/her the ownership of the directory.&lt;/P&gt;&lt;P&gt;If more than one user needs access, create a group, use chgrp to assign the group ownership of the directory to that group, set permissions to chmod 2770 or 2775. If there are any existing sub-directories, do the same for them too. Then add the required users to that group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need all changes to the files to be logged, use a version control system (like cvs, svn, or git): that is exactly the kind of task version control systems are designed for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) If your sudo version supports the "sudoedit" or "sudo -e" command, then this can be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, to allow user userX to edit /some/file as userY on all hosts that have this sudoers file, the sudoers file entry would be:&lt;/P&gt;&lt;PRE&gt;userX    ALL = (userY) sudoedit /some/file&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If you omit the "(userY)" part, then userX will be allowed to edit the file with root-like access.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To edit the file, userX should first set the SUDO_EDITOR, VISUAL, or EDITOR environment variable to indicate his/her preferred text editor (e.g. "export SUDO_EDITOR=/usr/bin/vim"), and then run "sudoedit /some/file" or "sudo -e /some/file".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.) To allow userX to start and stop httpd (which must be run as root, since it uses ports 80 and/or 443), the sudoers file syntax would be:&lt;/P&gt;&lt;PRE&gt;userX    ALL = (root) /etc/init.d/httpd start, /etc/init.d/httpd stop&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4.) You'll need to find the exact commands required to install that software, and allow them as in 3.)&lt;/P&gt;&lt;P&gt;You'll need to think about things like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Is the software going to be installed using standard package management tools, like yum or apt-get, or does it have its own installer (like Oracle products almost always do)?&lt;/LI&gt;&lt;LI&gt;If the software has its own installer, does it need to run as root at all? If not, you might want to create a user account (for example, userAPP) for the purpose of running the application, create a directory in a suitable location (e.g. /opt/app, or /usr/local/app, or /srv/app) and make the new user own it, then allow the user that is going to install the software full access through sudo to that user account only:&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;userX    ALL =(userAPP) ALL&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Then userX can switch to userAPP with "sudo -u userAPP -i", or run individual commands as userAPP with "sudo -u userAPP &amp;lt;command&amp;gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2013 17:33:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6073667#M54288</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2013-05-20T17:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6074861#M54289</link>
      <description>Hi Matti,&lt;BR /&gt;&lt;BR /&gt;I have tried the option you mentioned by I am getting error.&lt;BR /&gt;&lt;BR /&gt;I am using RHEL 5.7&lt;BR /&gt;&lt;BR /&gt;Host_Alias xyx = xyz1,xyz2&lt;BR /&gt;&lt;BR /&gt;1)Method 1 (current):&lt;BR /&gt;&lt;BR /&gt;Cmnd_Alias abc = /etc/init.d/httpd start, \&lt;BR /&gt;/etc/init.d/httpd restart, \&lt;BR /&gt;/etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;user WASS_HOSTS = NOPASSWD: WASS_CMDS&lt;BR /&gt;&lt;BR /&gt;I am not getting any error while save and exit visudo. But getting following error while restarting the service by the user.&lt;BR /&gt;&lt;BR /&gt;-bash-3.2$ /etc/init.d/httpd restart&lt;BR /&gt;Stopping httpd: [FAILED]&lt;BR /&gt;Starting httpd: (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80&lt;BR /&gt;no listening sockets available, shutting down&lt;BR /&gt;Unable to open logs&lt;BR /&gt;[FAILED]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Method 2:&lt;BR /&gt;&lt;BR /&gt;Host_Alias xyx = xyz1,xyz2&lt;BR /&gt;&lt;BR /&gt;Cmnd_Alias abc = (root)/etc/init.d/httpd start, \&lt;BR /&gt;(root)/etc/init.d/httpd restart, \&lt;BR /&gt;(root)/etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;user xyz = NOPASSWD: abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Getting error while save and exit.&lt;BR /&gt;&lt;BR /&gt;visudo: Warning: Cmnd_Alias `abc' referenced but not defined&lt;BR /&gt;&lt;BR /&gt;Method 3:&lt;BR /&gt;&lt;BR /&gt;Host_Alias xyx = xyz1,xyz2&lt;BR /&gt;&lt;BR /&gt;Cmnd_Alias abc = (root) /etc/init.d/httpd start, \&lt;BR /&gt;(root) /etc/init.d/httpd restart, \&lt;BR /&gt;(root) /etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;user xyz = NOPASSWD: abc&lt;BR /&gt;&lt;BR /&gt;Getting following error while save and exit visudo&lt;BR /&gt;&lt;BR /&gt;visudo: Warning: Cmnd_Alias `abc' referenced but not defined&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Method 4:&lt;BR /&gt;&lt;BR /&gt;user xyz = NOPASSWD (root): abc&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; /etc/sudoers: syntax error near line 1050 &amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;user xyz = NOPASSWD: (root) abc&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; /etc/sudoers: syntax error near line 1050 &amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#Host_Alias xyx = xyz1,xyz2&lt;BR /&gt;&lt;BR /&gt;#Cmnd_Alias abc = (root) /etc/init.d/httpd start, \&lt;BR /&gt;(root) /etc/init.d/httpd restart, \&lt;BR /&gt;(root) /etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;user ALL = NOPASSWD:(root)/etc/init.d/httpd restart&lt;BR /&gt;&lt;BR /&gt;Getting syntax error.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 May 2013 15:19:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6074861#M54289</guid>
      <dc:creator>Senthil_N</dc:creator>
      <dc:date>2013-05-21T15:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6076167#M54294</link>
      <description>&lt;P&gt;Method 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; -bash-3.2$ /etc/init.d/httpd restart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If httpd requires root permissions to run (e.g. because it is configured to use ports &amp;lt;1024), then you must prefix "sudo" to the command:&lt;/P&gt;&lt;PRE&gt;-bash-3.2$ sudo /etc/init.d/httpd restart&lt;/PRE&gt;&lt;P&gt;Without the "sudo" prefix, the non-root user will run the command as himself, without root permissions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without root permissions, httpd will not be able to open port 80 nor its log files, and it will fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 2 and 3: (I see no difference between the two???)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; Cmnd_Alias abc = (root)/etc/init.d/httpd start, \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not a correct Cmnd_Alias syntax.&lt;/P&gt;&lt;P&gt;With Cmnd_Alias, you can only specify commands, not the username to run them as.&lt;/P&gt;&lt;P&gt;For the username, there is a separate Runas_Alias.&lt;/P&gt;&lt;P&gt;Also, you are defining Host_Alias xyx but referring to Host_Alias xyz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Host_Alias xyz = xyz1,xyz2

Cmnd_Alias abc = /etc/init.d/httpd start, \
/etc/init.d/httpd restart, \
/etc/init.d/httpd stop

user xyz = (root) NOPASSWD: abc&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;or if you want to use Runas_Alias:&lt;/P&gt;&lt;PRE&gt;Host_Alias xyz = xyz1,xyz2

Cmnd_Alias abc = /etc/init.d/httpd start, \
/etc/init.d/httpd restart, \
/etc/init.d/httpd stop

Runas_Alias HTTPDUSER = root

user xyz = (HTTPDUSER) NOPASSWD: abc&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method 4:&lt;/P&gt;&lt;P&gt;Assuming that this is line 1050 of your sudoers file:&lt;/P&gt;&lt;P&gt;&amp;gt; user xyz = NOPASSWD: (root) abc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have the last three elements in the wrong order.&lt;/P&gt;&lt;P&gt;It should be:&lt;/P&gt;&lt;PRE&gt;user xyz = (root) NOPASSWD: abc&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Tags like "NOPASSWD:" come after the run-as specification and before the command specification.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2013 11:59:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6076167#M54294</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2013-05-22T11:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6076805#M54299</link>
      <description>Hi Matt,&lt;BR /&gt;&lt;BR /&gt;I have done following:&lt;BR /&gt;&lt;BR /&gt;Host_Alias xyz = xyz1, xyz2&lt;BR /&gt;&lt;BR /&gt;Cmnd_Alias abc = /etc/init.d/httpd start, \&lt;BR /&gt;/etc/init.d/httpd restart, \&lt;BR /&gt;/etc/init.d/httpd stop&lt;BR /&gt;&lt;BR /&gt;john xyz = (root) NOPASSWD: abc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But it is giving following error.&lt;BR /&gt;&lt;BR /&gt;xyz1# su - john&lt;BR /&gt;su: warning: cannot change directory to /home/john: No such file or directory&lt;BR /&gt;&lt;BR /&gt;-bash-3.2$ sudo /etc/init.d/httpd restart&lt;BR /&gt;Sorry, user john is not allowed to execute '/etc/init.d/httpd restart' as john on xyz1.&lt;BR /&gt;</description>
      <pubDate>Wed, 22 May 2013 22:14:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6076805#M54299</guid>
      <dc:creator>Senthil_N</dc:creator>
      <dc:date>2013-05-22T22:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Giving sudo access to whole directory, some files and start &amp; stop the service</title>
      <link>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6077129#M54303</link>
      <description>&lt;P&gt;&amp;gt; xyz1# su - john&lt;BR /&gt;&amp;gt; su: warning: cannot change directory to /home/john: No such file or directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This means the home directory of user "john" has not been created, i.e. the user set-up is not complete. But that should not be a problem for sudo...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; -bash-3.2$ sudo /etc/init.d/httpd restart&lt;BR /&gt;&amp;gt; Sorry, user john is not allowed to execute '/etc/init.d/httpd restart' as john on xyz1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The message says sudo is trying to execute the command as user "john", not as user "root".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hmm, your previous message indicated your sudoers file has at least 1050 lines, so this is probably caused by something else in your configuration you have not shown me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have the "runas_default" configuration option specified? For example, do you have something like this in your sudoers file:&lt;/P&gt;&lt;PRE&gt;Defaults runas_default = john&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have the runas_default specified as some user other than root, then user john needs to explicitly specify that he wants to run the command as root:&lt;/P&gt;&lt;PRE&gt;-bash-3.2$ sudo -u root /etc/init.d/httpd restart&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that each user can use "sudo -l" to list what commands s/he is allowed to run through sudo. The root user can list any user's allowed commands with "sudo -l -U &amp;lt;username&amp;gt;". If your sudoers configuration is very complex (1050 lines can be very complex indeed!), this can be helpful: it allows you to see the result of your current sudoers configuration as it applies to a particular user.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2013 04:24:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/giving-sudo-access-to-whole-directory-some-files-and-start-amp/m-p/6077129#M54303</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2013-05-23T04:24:21Z</dc:date>
    </item>
  </channel>
</rss>

