2

On Linux, I am logged in as another user, I have added myself to wheel.

wheel:x:10:root,allan

I have uncommented the lines of /etc/sudoers

## Allow root to run any commands anywhere 
root    ALL=(ALL)   ALL

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)   ALL

## Same thing without a password
%wheel  ALL=(ALL)   NOPASSWD: ALL

However, when I create a file e.g.

touch test

the owner and group of file 'test' are:

-rw-r--r-- 1 root  root     0 Jul 28 09:05 test

It seems like I have to run sudo in front of every command, otherwise I get permission denied errors.

How do I go about resolving this?

  • What's the permissions of that directory where you do touch test? – ott-- Jul 28 '12 at 17:40
  • Are you in a root shell when you touch test? – Daniel Beck Jul 28 '12 at 18:26
3

You can't resolve it; the system is behaving as expected. The sudoers file controls the sudo command, it does not change the way the kernel interprets file and directory permissions. In order to get the effects of sudo, you must run sudo. What sudo does is run commands as root, so naturally files created by a sudo-run command are owned by root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.