In Linux, when we need to execute a command with the root permission, every time we have to Su to the root, is it always inconvenient? We can replace it with sudo. Fedora
10 by default, the new user is not in The sudo group, but the/etc/sudoers file can be edited to add normal users
Sudo Group
. Note that only the mongodo command can be used to modify the file:
1. First switch to root
# Su
-
(Note that-
This is different from Su. When the "Su" command is used, it only switches to root, but does not pass the root environment variable to the current user's environment variable, the "Su" with the horizontal line parameter is used.
-"The command also converts the environment variables together, just like using root login)
2. Then
# Mongodo
In the same way as VI, move the cursor to the last line, press a to enter append mode, and enter the following line of content.
Username
All = (all)
Then Press ESC and enter: WQ to save the file and exit, so that you can add yourself to the sudo group. You can use the sudo command.
If you do not want to enter the password during sudo, simply replace the above line with the following line:
Username
All = (all) nopasswd: All
3,
Test
Sudo
Test whether sudo is configured correctly.
, You only need to enter
$ Sudo
Whoami
If the configuration is correct, the command returns "root ".
Method 2:
FC 10 imposes strict permission management on users. Although it is convenient to use the root account for logon, It is not secure to the system. Generally, users can use sudo to obtain the execution right when the permission is exceeded.
After sudo is used in FC 10, the system prompts "user" is not in the sudoers file. This incident will be reported.
The prompt content shows that the current user does not belong to sudoers.
This file is stored in/etc. Of course, the current user has no access permission.
Su Root
Modify file attributes to make the file writable
Chmod U + w/etc/sudoers
VI/etc/sudoers
You can see a record.
# Allow root to run any commands anywhere
Root all = (all) All
Cspark all = (all) All
That is to say, adding the current user name is sudoers and all commands can be executed.
After being saved, the user's life can be legally used by sudo.
Restore file attributes
Chmod U-W/etc/sudoers