Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I prevent a none root user to executes e.g. the passwd command in terminal?

share|improve this question
    
The question is not well-posed. Do you want that the user shouldn't execute any command that needs sudo? Or just that specific command? –  dadexix86 Feb 26 '12 at 19:42
    
@dadexix86 It's fine. The OP wants to keep users from changing their passwords. –  hexafraction Aug 16 '12 at 19:03
add comment

2 Answers 2

up vote 1 down vote accepted

To avoid a user from running the passwd command, just make it non-executable for everyone but root.

sudo chmod o-x /usr/bin/passwd

An odd request though. You usually want users to be able to change their password, and to do it regularly. Also, the passwd command isn't the only way a user can change their own password...

share|improve this answer
    
Thanks. It was more a general question on how to prevent a none root user to execute a shell command. –  Paradiesstaub Feb 26 '12 at 21:11
add comment

With sudo you most certainly know that the default setup will require the user running sudo to enter a password (by default the password of the user running sudo and not the root password). In Ubuntu, if you wish to remove a user from the admin group, run this command in a terminal:

gpasswd -d username admin

Check it out:

id -Gn username

You should see something like that:

username adm dialout cdrom plugdev lpadmin sambashare

without the admin privilege.

share|improve this answer
1  
you most certainly know that the default setup will require the user running sudo to enter a password this is not true, every user can change their pw by typing 'passwd'. I would like to know how to prevent a normal user to execute that command. –  Paradiesstaub Feb 26 '12 at 20:07
add comment

Your Answer

 
discard

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.