To set the root password for initial Linux use

Source: Internet
Author: User

Original post by wee0618 on 2007-3-2 19:10 posted on 4 floor
Installation of a new user and password, but did not prompt for the root user's password, SU when using the installation of the user's password to report the wrong password, in addition, change the monitor driver is in the Device Manager operation?


Please log in with the first user that was created, and use sudo passwd root to modify the root password. PS: To enter a password, the password is to execute sudo for that user's password.

Or sudo Su-can become a manager, not very convenient to call?

Ubuntu is similar to a Mac, and you can look at Ubuntu manual for instructions that include the use of sudo.

I am using redhat5.4, under the general user, execute the sudo command prompt llhtiger is not in the sudoers file. This incident would be reported. Workaround:

First, $whereis sudoers-Find out where the file is located, by default,/etc/sudoers
Second, #chmod u+w/etc/sudoers to the superuser login su-root, modify the file permissions to add the file has the Write permission limit, ls-al/etc/sudoers can view the original file permissions.
Vim/etc/sudoers Edit the file, add the xxx all= (All) all,xxx to your username under root all= (all) all line. Add method: Find the root line, press "I" key to enter the editing mode to add! After editing the ESC key into the general mode, ": Wq" Save exit!
Finally, #chmod U-w/etc/sudoers back to the original permissions of the file!

Here's a little more detail:

In Ubuntu, because the root user is disabled, users who are established when the system is installed are added to Sudoers by default. In Redhat and CentOS, however, no user other than the root user is added to the sudoers by default. This will cause us to execute the sudo command with the sudoers file XXX. This incident would be reported. Such an error output. Now, for the sake of safety, it is recommended to use the ordinary user for daily operation, and use sudo when the superuser is needed, so we need to add some users to sudoers.
Actually adding the user to the sudoers is simple.
First use the Whereis command to find the directory of the Sudoers configuration file (default is/etc/sudoers)
[Email protected] xiaofei]# Whereis sudoers
Sudoers:/etc/sudoers/etc/sudoers.bak/usr/share/man/man5/sudoers.5.gz
Then you need to switch to the root user and change the/etc/sudoers permissions
[Email protected] xiaofei]# chmod u+w/etc/sudoers
You can then use the VI Editor to add users to the Sudoers
[Email protected] xiaofei]# vi/etc/sudoers
Then find the location of root all= (all), add the user you want to add to the file,

By the way, the use of the VI editor. Just enter the VI editor when the card command line mode, you can use the arrow keys to move the cursor, find the location to edit and then press "I", and then into the insertion mode, you can enter or delete characters. After editing, press "ESC" key to exit Insert mode, enter command line mode, press ":" to enter the last line mode, enter "Wq" to save and exit.

The following is the result of the addition.
# allow ROOT to run any commands anywhere
Root all= (All) all
Xiaofei all= (All) all (this line is the added content, Xiaofei is my user name)
Then you need to remove the Write permission of the sudoers (otherwise the system does not allow the Suoders file to execute):
[Email protected] xiaofei]# chmod u-w/etc/sudoers
At this point, after exiting the root user, you can use the sudo command to perform superuser privileges.

To set the root password for initial Linux use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.