Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Windows user on my network who has Samba access to our linux development server. Occasionally permissions or ownership will become confused for reasons unknown and he will no longer be able to edit files.

To get round this I have given him access through PuTTY and in the sudoers file (sudo visudo) I have added a line like this:

username ALL = /bin/chmod, /bin/chown

Now obviously he could now just chown everything to himself and delete the entire drive. He is trustworthy, but I worry if someone were to compromise his account or he accidentally got out of his depth and did it.

Is there a way I can restrict his account so it can only chmod or chown in /home/username and /specified/directory?

I am running Ubuntu 10.10 on the server.

share|improve this question
Sounds like another option would be to fix the permissions problems in Samba. – Alex Holst Feb 2 '11 at 20:01
The settings are currently set to 775 so I am not sure what more I could do to fix the problems in Samba. Any ideas? It might not even be Samba that is causing the problem. – Treffynnon Feb 2 '11 at 20:08
@grawity What do you mean? sudo chown changes the ownership. – Treffynnon Feb 3 '11 at 8:43
up vote 5 down vote accepted

You could write a script /usr/local/bin/permchange


chown -R youruser:yourgroup /home/username 
chmod -R u+rw /home/username
... etc

and allow him to run only this with sudo after making sure he can't edit it.

share|improve this answer
sudo will also restrict arguments, so the sudoers file could have the specific arguments listed in this script, and all would be well. – beans Feb 2 '11 at 18:55
This was my next course of action, but I thought I might have missed a simple trick in a config somewhere and didn't want to reinvent the wheel if I could avoid it! :) But thinking about it now this would make it easier for him as well because he doesn't have to learn any linux commands. – Treffynnon Feb 2 '11 at 18:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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