Sudo password-free and sudo Password
Sometimes we only need to execute a command with the root permission to su to the root, isn't it inconvenient? In this case, sudo can be used instead. By default, the new user is not in The sudo group. You need to edit the/etc/sudoers file to add the user. The file can only use the mongodo command,
1) first switch to root, su-(Note that there is-, which is different from su. When using the "su" command, it only switches to root, however, if the root environment variable is not passed, it is still the currently used environment variable. Use the "su-" command to bring the environment variable together, just like root login)
2) then perform do, vi/etc/sudoers, And do. This is the same as that of vi. Some may be unfamiliar with vi, so let's take a brief look at the steps.
Move the cursor to the next line of root ALL = (ALL) ALL, press a to enter append mode, and enter your_user_name ALL = (ALL) ALL
Press Esc, enter w to save the file, and then exit q.
In this way, you can add yourself to the sudo group and use the sudo command.
3) by default, the sodo password just entered five minutes later expires. Next time, sudo needs to re-enter the password. If it is difficult to enter the password during sudo, replace the entered one with the following: your_user_name ALL = (ALL) NOPASSWD: ALL
As for security issues, I think this is also acceptable for individual users.
4) if you want to set only some commands that can be sudo, your_user_name ALL = (root) NOPASSWD:/sbin/mount, (root) NOPASSWD:/bin/umount, (root) NOPASSWD:/mnt/mount, (root) NOPASSWD:/bin/rm, (root) NOPASSWD:/usr/bin/make, (root) NOPASSWD:/bin/ln, (root) NOPASSWD:/bin/sh, (root) NOPASSWD:/bin/mv, (root) NOPASSWD:/bin/chown, (root) NOPASSWD:/bin/chgrp, (root) NOPASSWD:/bin/cp, (root) NOPASSWD:/bin/chmod
Note: Sometimes you set nopasswd for the user, but it does not work because it is overwritten by the later group settings. You need to change the group settings to nopasswd.
Joe ALL = (ALL) NOPASSWD: ALL
% Admin ALL = (ALL) NOPASSWD: ALL
Refer:
Http://blog.163.com/love-love-l/blog/static/21078304201071232234518/
Second, set su to no passwordIf you do not need to enter a password for a user's su command, you need to modify the following:
1) switch to the root permission; 2) create a group as wheel and run the command groupadd wheel; 3) Add the user to the wheel group and run the command usermod-G wheel joe; 4) modify the su configuration file/etc/pam. d/su: Add the following items: auth required pam_wheel.so group = wheel # Uncomment this if you want wheel members to be able to # su without a password. auth sufficient pam_wheel.so trust use_uid
Now you can use the following command without entering the password: su joe-c command. Enable root in ubuntu
sudo -i
sudo passwd root
disable by below:
sudo passwd -dl root
Refer:
Http://cosminswiki.com/index.php/How_to_let_users_su_without_passwordhttp://ag-up.com? P = 457