Linux User and User group management

Source: Internet
Author: User

One, the user account includes (view the existing account | Add user account | Modify User Account | Delete user account)

To view an existing account:

more/etc/-F':'{print $}' /etc/passwd

Add user account command: Useradd

useradd-d/home/uhome-m ikphp

Created a ikphp user account

Parameter options:

Useradd--help
Usage: useradd [options] Login
Useradd-d
useradd-d [Options]

Options:
-B,--base-dir base_dir The base directory of the new account's home directory
-C,--comment comment new account GECOS field
-D,--home-dir home_dir the home directory of the new account
-D,--defaults display or change the default Useradd configuration
-E,--expiredate expire_date expiration date for new account
-F,--inactive inactive new account password inactivity period
-G, the name or ID of the--gid group's new account owner
-G,--groups groups additional group list for new account
-H,--help displays this help information and launches
-K,--skel Skel_dir Use this directory as the skeleton directory
-K,--key key=value do not use default values in/etc/login.defs
-L,--no-log-init do not add this user to the most recent logon and logon failure database
-M,--create-home create the user's home directory
-M,--no-create-home does not create a user's home directory
-N,--no-user-group does not create a group with the same name
-O,--non-unique allows users to be created with duplicate UID
-p,--password password new account password after encryption
-R,--system create a System account
-R,--root Chroot_dir CHROOT to the directory
-S,--shell Shell login shell for new account
-U,--uid uid user ID of new account
-U,--user-group create a group with the same name as the user
-Z,--selinux-user Seuser uses the specified seuser for SELinux user mappings
--extrausers use the Extra users database

1, after the creation with MORE/ETC/PASSWD view

DAOKR:X:1000:1000:DAOKR,,,:/home/daokr:/bin/bash
Sshd:x:121:65534::/var/run/sshd:/usr/sbin/nologin
Ikphp:x:1001:1001::/home/uhome:

---------------------------------
User name: Password: User id: Group identification number: Annotative Description: Home directory: Login Shell

2. Use More/etc/group to view all user groups

daokr:x:1000:
Sambashare:x:128:daokr
IKPHP:X:1001:

---------------------------------
Group Name: password: Group identification number: List of users in the group

And then see the above; The identifier for the group name and the password group, respectively, and the list of users in the group

Ikphp is the user who was just created she belongs to the 1001 user group his user represents is 1001

3, use the More/etc/shadow command line to view the user ikphp password file

Usbmux:*:16911:0:99999:7:::
daokr:$6$5wfbwzid$qzf3/lmwl/2qtjgs./dyk7lziqrzc/mxeeybmzgtv21co9jtgm6jjz/bmiuzk0ugfqof175umcguo4tjqwckm/ : 17617:0:99999:7:
::
Sshd:*:17617:0:99999:7:::
Ikphp:!:17617:0:99999:7:::

All of the above are password text:
---------------------------------
Login: Encrypted password: Last modified: Minimum time interval: Maximum time interval: Warning Time: Inactivity time: Expiry time: Flag

Login Name: DAOKR

Encrypted string: $6$5wfbwzid$qzf3/lmwl/2qtjgs./dyk7lziqrzc/mxeeybmzgtv21co9jtgm6jjz/bmiuzk0ugfqof175umcguo4tjqwckm/

Last modified: 17617

Other....

    1. "Login Name" is a user account that matches the login name in the/etc/passwd file
    2. The password field holds the encrypted user password Word with a length of 13 characters. If null, the corresponding user does not have a password, the password is not required at logon, and if it contains characters that are not part of the collection {./0-9a-za-z}, the corresponding user cannot log on.
    3. Last modified time represents the number of days from the time the user last modified the password. The beginning of time may not be the same for different systems. For example, in SCO Linux, the starting point for this time is January 1, 1970.
    4. "Minimum time interval" refers to the minimum number of days required between changing the password two times.
    5. Maximum time interval refers to the maximum number of days that a password remains valid.
    6. The warning Time field represents the number of days from the beginning of the system warning user to the official expiration of the user's password.
    7. "Inactivity Time" represents the maximum number of days that a user does not have a login activity but the account remains valid.
    8. The "Expiration Time" field gives an absolute number of days, and if this field is used, the lifetime of the corresponding account is given. After expiry, the account is no longer a legitimate account, and can no longer be used to log on.

Delete Account

Delete the ikphp account command you just created

  

Userdel-  R ikphp

As the command above will remove ikph's home directory/home/uhome

or with

Userdel ikphp

Delete only the account, do not delete the directory, and then use the more command just to see passwd and/etc/group and/etc/shadow inside there must be no ikphp information

Modify Account

and add the same parameters as the account

Common options include-C,-D,-M,-G,-G,-S,-u, and-O, etc., which have the same meaning as the options in the Useradd command, specifying a new resource value for the user.
In addition, some systems can use the option:-L New user name
This option specifies a new account that will change the original user name to the new one.
For example:

# usermod-s/bin/bash-d/home/ik–g mygroup ikphp

This command modifies the login shell of the user ikphp to bash, the home directory to/home/ik, and the user group to MyGroup.

The following command adds the user ikphp to the user group MyGroup and knows that the start directory of the launcher is uhome, and that the startup shell is bash

# useradd-d/home/uhome-s/bin/bash-g mygroup ikphp

If modified, change the Useradd to Usermod.

#usermod-D/home/uhome-s/bin/bash-g Daokr ikphp

Modify User Login Password

[Email protected]:/home# passwd ikphp Enter a new UNIX password: Re-enter the new UNIX password: passwd: The password was successfully updated

Use passwd to specify the user name modification, the specific parameters are as follows

    • Options available for use:
    • -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.

Ii. User Group Management (view existing user groups | Add user groups | Modify User Groups | Delete user groups)

1. Add a group

1001 MyGroup

The options you can use are:
-G GID Specifies the group identification number (GID) of the new user group.
-O is commonly used with the-G option, which means that the GID of the new user group can be the same as the GID of the user group already in the system.

This command adds a new group MyGroup to the system, specifying that the group identification number for the new group is 1001.

2. Delete a user group

Groupdel MyGroup

3. Modify user Groups

Groupmod Option User Group

10210000 -n group3 group2 This command changes the group group2 identification number to 10000 and the group name to Group3. 

Modify MyGroup name called ikphp new group name

Groupmod-n ikphp MyGroup

Linux User and User group management

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.