LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Apache2 permissions for user (https://www.linuxquestions.org/questions/linux-general-1/apache2-permissions-for-user-832177/)

treznik 09-14-2010 05:58 PM

Apache2 permissions for user
 
Hi, this question is a bit stupid but I'm left clueless.

I want to let a regular user (not just root) restart apache on my Ubuntu machine.

I was using /etc/init.d/apache2 so I figured this is what I have to set permissions for. I set the owner group for this file a group to which that user also belongs. I set the chmod to 775 but it didn't work. I then even set it to 4775 thinking this would totally make it work but it still didn't.

I'm obviously giving permissions to the wrong file.

The error says:
Quote:

httpd not running, trying to start
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
But I didn't find httpd anywhere on my machine.

What am I missing? Thanks!

gilead 09-14-2010 06:35 PM

Are you familiar with sudo? You can add an entry for /etc/init.d/apache2 with visudo and the user would type:
Code:

sudo /etc/init.d/apache2 start

treznik 09-15-2010 04:53 AM

I know what it does, but I haven't worked much around it.

For starters I need this to be inside a script, so I would like it not to ask for a password. I'm not familiar with visudo though. I'll look it up but if it's something easy to explain or exemplify, please. Is it a file where I add file entries?

Also, how is sudo different from setting the suid bit? which from what I learned does the same: make a file run with the permissions of the executable's owner.

Thanks!

sag47 09-15-2010 05:07 AM

suid is for setting the userid to the owner when the executable is run by any user. If your user doesn't have administrative access to the directory then the suid is useless except for a root-like user (such as the sudo command) or by root itself.

The visudo command edits /etc/sudoers file. The sudoers file is what gives users administrative access or restricted access to certain parts of the system when the sudo command is used to execute a command with administrative privileges. You can set up the sudo command to be run by certain users or groups without a password if you add an entry within the /etc/sudoers files by executing the visudo command to edit it.

You may be interested in the following post...
http://www.linuxquestions.org/questi...ml#post4096968

Google man sudoers for more information on configuring the sudoers file.

treznik 09-15-2010 06:06 AM

Thanks for the clarification.

One question though, is it OK that is saves a file called sudoers.tmp? is tmp from temporary? :)

sag47 09-15-2010 11:20 AM

Yes tmp is temporary; It is only there when you're running the visudo command. If you computer crashes while you're editing the sudoers then you'll still definitely have a working copy of your sudoers. When you're done editing, save, and quit visudo then sudoers.tmp is discarded and the newly saved copy of your sudoers is used.

I prefer to just manually backup my sudoers and edit it using vim (visudo uses nano). However the visudo command is the standard for many people.


All times are GMT -5. The time now is 02:49 AM.