Pages

Saturday, 14 April 2012

Add SUDO to User under ubuntu desktop os

Ubuntu don’t allow you to directly use “root” user in the safe’s sake.
Thus, you need use “SUDO” command, to act like operating with root rights. And don’t have to change to root user. This is definitely a brilliant idea. You can check the sudo list by using command :

1
less  /etc/sudoers
The file looks like following :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
 
Defaults        env_reset
 
# Host alias specification
 
# User alias specification
 
# Cmnd alias specification
 
# User privilege specification
root    ALL=(ALL) ALL
 
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
 
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
As the comment you can see,  must use visudo command as root user to modify this file :

1
sudo visudo
We can see following line, what does it mean?

1
2
# User privilege specification
root    ALL=(ALL) ALL
It means user root can execute from ALL terminals, acting as ALL (any) users, and run ALL (any) command.
So the format is :

1
[user]  [terminal that use sudo]= ( [as which user he may act] ) [commands he may run]
Some examples :

1
2
3
4
5
6
7
8
9
10
11
12
rhoneldo ALL=(OP) ALL
# The user rhoneldo can run any command from any terminal as any user in the OP group (root or operator).
 
zidane OFNET=(ALL) ALL
# user zidane may run any command from any machine in the
OFNET network, as any user.
 
backham ALL= PRINTING
# user backham may run lpc and lprm from any machine.
 
nakata ALL=(ALL) ALL NO PASSWD: ALL
# do not ask to fill password when user nakata using sudo

No comments:

Post a Comment