Set the root password for ubuntu and add users

Source: Internet
Author: User

Set the root user password

Note:

After installing Ubuntu, I suddenly realized that I didn't set the root password. Without knowing the password, I could not access the root user.

Implementation:

The original Ubuntu root password is random by default, that is, a new root password is generated every time you start the system. Enter the sudo passwd command on the terminal, enter the password of the current user, enter, and confirm. The new password is the new root password. After the modification is successful, enter the command su root and then enter the new password.

You can set the ROOT password as follows:

Start the terminal and enter the following command:
Sudo passwd root
Enter the password and press "OK.
 
The root account in Ubuntu is disabled by default. In this case, if you want to use the root permission to do something, you need the sudo command. For some friends, they may need to activate the root account in Ubuntu.

The process of activating the root account in Ubuntu is as follows:

1. After executing the sudo passwd root command on the terminal, the system will prompt you to set a new root account password.
2. Click System-> Preferences-> Login Window menu, switch to the Security option page, and select the "Allow local system administrator login" option.

After performing the preceding two steps, you can use the root account to log on to the Ubuntu system.

If you want to disable the root account again, run sudo passwd-l root.

Appendix:

Unlike centos, ubuntu requires you to set the root and common user passwords during installation.

Set user password in ubuntu

There are two ways to add users in batches:

First, use the useradd + passwd command with the script to add

It is mainly used to add different users on different machines, or to add a large number of users named by rules on the same machine.

The second is to use newusers + chpasswd to add.

It can be used to add A large number of user names on the same machine. For example, you can add all the users on machine A to Machine B.

You can use cat/etc/shells to view the shell supported by your machine.

Newusers + chpasswd add user

Standard input is required for both methods.

(1) edit a text user file. Each line is written in the format of the/etc/passwd password file. Note that the user name, UID, and home directory of each user cannot be the same, in the password column, enter the x number. Here, the initial password of the account to be created is entered in the password column. You can use this password to log on to the system.

The content of user.txt in a sample file is as follows:

User001: x: 600: 100: user:/home/user001:/bin/bash

User002: x: 601: 100: user:/home/user002:/bin/bash

User003: x: 602: 100: user:/home/user003:/bin/bash

User004: x: 603: 100: user:/home/user004:/bin/bash

User005: x: 604: 100: user:/home/user005:/bin/bash

User006: x: 605: 100: user:/home/user006:/bin/bash

(2) # newusers <user.txt

Then you can run cat/etc/passwd to check whether the data of these users is displayed in the/etc/passwd file and whether the user's home directory has been created. In this case, a password is generated for the new user in/etc/shadow.

(3) edit the password comparison file for each user,

The content of the passwd.txt file is as follows:

User001: password

User002: password

User003: password

User004: password

User005: password

User006: password

(4) # chpasswd <passwd.txt

In this way, a large number of users are created. Then, you can go to/home to check whether the permission settings of these users in the home directory are correct, and log on to verify that the user password is correct.

Note: All tests are carried out in ubuntu, version 12.04Ts, without pwunconv and pwconv

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.