"Linux" Linux/ubuntu system-new/modified/deleted user account and password modification useradd/usemod/userdel/passwd__linux

Source: Internet
Author: User

Reproduced from Bi Xiaobong blog (see map on the right):

In the Linux system, the files related to user management are mainly as follows:/etc/passwd,/etc/shadow,/etc/gfoup,/etc/gshadow, respectively. They are related to the user's account number, password, user group and user group password respectively. We create users that are dealing with these files.
1. How to create a new user.

This is mainly the following two steps:

One. Complete the initialization setup of a new user with the Useradd command

Two. Set a password for this new user through passwd


Add a user named Wirelessqa to the system with a password of 12345

1. Add user first WIRELESSQA [plain] view plain copy bixiaopeng@ubuntu:~$ useradd WIRELESSQA useradd:cannot lock/etc/ passwd Try again later.
#oh, my God, requires root permissions [plain] view plain copy bixiaopeng@ubuntu:~$ su Password:
Try again add user WIRELESSQA [plain] view plain copy root@ubuntu:/home/bixiaopeng# user add WIRELESSQA
No results, no mistakes.


2. Set a password for WIRELESSQA

[plain] view plain copy root@ubuntu:/home/bixiaopeng# passwd wirelessqa Enter new UNIX password:retype New UNIX Password:passwd:password updated successfully
The password setting is successful, of course, we can also change the password for the above user, the method is the same

At this point, although we've created a new account, we don't see it in the home directory.

[plain] view plain copy root@ubuntu:/home# pwd/home root@ubuntu:/home# ls-al Total drwxr-xr-x 3 R   Oot root 4096 8 17 00:31.   Drwxr-xr-x root root 4096 6 17 18:14. Drwxr-xr-x Bixiaopeng Bixiaopeng 4096 8 19:45 Bixiaopeng
3. If you want to create a user directory at the same time in the home directory (default), you need the-m parameter

[Plain]  View Plain  copy root@ubuntu:/home# useradd -m bilaoshi   root@ubuntu:/home#  passwd bilaoshi   enter new unix password:   retype new  unix password:   passwd: password updated successfully   root@ubuntu:/ home# ls -al   total 16   drwxr-xr-x  4 root        root       4096  8  17 00:38  .   drwxr-xr-x 23 root       root        4096  6  17 18:14     drwxr-xr-x  2 bilaoshi   bilaoshi   4096   8  17 00:38 bilaoshi   drwxr-xr-x 29 bixiaopeng bixiaopeng 4096   8  17 00:34 bixiaopeng  

2. Add User (Useradd) Common parameters



1. Useradd default in the/home directory for the new account to build a home directory, if you want to change the home directory storage location, you can use the Useradd parameter-D

Example: Create a new user alex3, the home directory in the/home/account

[plain] view plain copy useradd-d/home/account alex3
2. Useradd initialization also includes creating a separate group (Floatboat group) with the same name as the user name. This is called the mechanism of the user's private group, which corresponds to the default group mechanism.
Group One for users is easy to manage, and the second is to be able to express permissions. If you want this user to join an existing group, you can use the-g parameter.
Example: Let Alex join the Bilaoshi Group
[plain] view plain copy useradd-g Bilaoshi Alex can also use the-G parameter to join multiple groups at the same time
Example: Let Alex join the BILAOSHI1 and BILAOSHI2 groups:

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.