Thursday, October 29, 2009

Let non-root user can reboot linux box

There are one command called sudo could allow normal linux user execute root command. The configuration file or sudo command is /etc/sudoers and the configuration file should only be modified by using visudo command. For example we creat a group called shutdown. Following line will allow all shutdown group user can use sudo shutdown the linux box.

%shutdown ALL=(root) NOPASSWD: /sbin/reboot
%shutdown ALL=(root) NOPASSWD: /sbin/halt
%shutdown ALL=(root) NOPASSWD: /sbin/shutdown

usermod command can add user to other group.

Options:

* -d home directory
* -s starting program (shell)
* -p password
* -g (primary group assigned to the users)
* -G (Other groups the user belongs to)

Example: To add the group 'others' to the user roger

usermod -Gothers roger

chgrp, chown command can change the group. chgrp can be used by normal user

*

chgrp group target1

* chown [-R] newowner filenames


Example:Give permissions as owner to user test.
chown test files.log

No comments: