Linux Create/delete/modify/password/user knowledge learning

Source: Internet
Author: User

Common commands: 1. Create user useradd Common parameters:-C notes, plus note text, note text will be saved in the passwd Memo field-D directory specified with the home directory, if this directory does not exist, then use the-M option, you can create the main directory----do not automatically establish the user's login directory-D Change Preset-e Specify the expiration date of the account-F specify the number of days after which the password expires to close the account-G user group to specify the user group to which the user belongs. -G user Group, user group specifies the additional group to which the user belongs. -S Shell file specifies the user's login shell. -N cancels the establishment of a group with the name of the user-R establishes the SYSTEM account-u user number specifies the user's number, and if you have the-o option, you can reuse the other user's identification number.


Root2:x:0:0::/home/root2:/bin/bash
[User name]:[password]:[uid]:[gid]:[identity description]:[home directory]:[login Shell]


Method 1: Create a normal user, modify the/etc/passwd/uid GID to 0

Useradd 123-p 123 Create 123 users and specify a password of 123

Method 2: Create an administrator user with direct parameters

Useradd-o-u 0-g 0-m-d/root-s/bin/bash username


2. Delete a user

Userdel

Common parameters:

-R function is to delete the user home directory together


3. Modify the user

Usermod

Common parameters:

Common options include-C,-D,-M,-G,-G,-S,-u, and-O, etc.

These options have the same meaning as the options in the Useradd command, and you can specify a new resource value for the user.

In addition, some systems can use the following options:


Code:

-L New User name


This option specifies a new account that will change the original user name to the new one.

For example:

Code:

# usermod-s/bin/ksh-d/home/z–g developer Sam

This command modifies the user Sam's login shell to Ksh, the home directory to/home/z, and the user group to developer.



4, the User password management

An important part of user management is the management of user passwords. The user account has just been created without a password, but is locked by the system, cannot be used, it must be given a password before it can be used, even if a blank password is specified.

The shell command that specifies and modifies the user's password is passwd. A superuser can specify a password for himself and another user, and a normal user can only use it to modify his or her password. The format of the command is:

Code:


passwd option User Name

Options available for use:


Code:

-L locks the password, which disables the account.

-u password to unlock.

-D make the account no password.

-F forces the user to modify the password the next time they log on.

If the default user name, the password for the current user is modified.


For example, assuming the current user is Sam, the following command modifies the user's own password:


Code:

$ passwd

Old password:******

New password:*******

Re-enter New password:*******


If you are a superuser, you can specify the password for any user in the following form:


Code:

# passwd Sam

New password:*******

Re-enter New password:*******


Ordinary users to modify their own password, the passwd command will first ask the original password, verify and then ask the user to enter two times the new password, if the password two times the same, the password is assigned to the user, and the superuser to specify a password for the user, you do not need to know the original password.


For system security, the user should choose a more complex password, for example, preferably with a 8-bit long password, the password contains uppercase, lowercase letters and numbers, and should be different from name, birthday, and so on.


When you specify an empty password for a user, the following forms of command are executed:


Code:

# passwd-d Sam



This command removes the password for the user Sam so that the next time the user Sam logs on, the system will no longer ask for the password.


The passwd command can also lock a user with the-l (lock) option so that it cannot log on, for example:


Code:

# passwd-l Sam


Linux Create/delete/modify/password/user knowledge learning

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.