Linux user-related and group

Source: Internet
Author: User

User-related files

Create User User1

Each user is created, a message is added to the passwd file

passwd files: Storing user information

Root:x:0:0:root:/root:/bin/bash

User name: Password placeholder (blank means no password): UID (User ID number): GID (group ID): User description Information: User home directory: Login Shell (1./bin/bash (user can log in, after execution is equivalent to open a terminal) 2./sbin/ Nologin (login not allowed))

Shadow file: Store user password

User name: ciphertext password no password with exclamation marks

root:$6$mqtfu8db$9ml0o5wzbvfpho5ipaovqda8ag7gbmdqgafwukz5ycajzsxtt.0pibegoc9jxnuv2sqgzsc6wuybnawchevcp/ : 17608:0:99999:7:::

ser1:!! : 17618:0:99999:7:::

Group File: Store groups Information

Group name: group Password stand character: Group ID: Group member

root:x:0:

Wheel:x:10:shuai

Gshadow file: Store group password

Group name: Group Password: ....

Root::

User home directory: /home/user1 user name-named folder with initial configuration file in it

UID GID (Primary group) additional group

Add a member of the group root

Additional groups are more root

user mailbox: /vra/spool/mail/user1 user name-named document

Create a user manually

1.PASSWD file

[Email protected] ~]# VIM/ETC/PASSWD

Shortcut G: Jump to the last line; yy:p; copy

2.shadow file

[Email protected] ~]# Vim/etc/shadow

wq! Force Save exit

3.group file

[Email protected] ~]# Vim/etc/group

4.gshadow file

[Email protected] ~]# Vim/etc/gshadow

5. Create home directory (there is no configuration file in home directory)

[Email protected] ~]# Mkdir/home/user2

6. Copy the configuration file (template in Skel)

[Email protected] ~]# cp-r/etc/skel/. [!.] */home/user2

7. Create a mailbox file

[Email protected] ~]# Touch/var/spool/mail/user2

8. View account, create success

Delete User

Userdel-r User2

User1 successfully deleted

User2 hint: These two files are not deleted

You can find that both the User2 file and the User2 folder under mail exist

View more information

Ls-l equivalent to ll view directory subdirectory and file details

The Ls-ld directory is identical to the ll-d directory to see the details of the directory itself

User2 belongs to the root group and is not part of the User2

Similarly, the User2 file under Mail is also owned by the root user, the root group

So user2 can not delete these two files (different from the normal creation situation)

Modify owner

Modify these two files

Modify the user profile (recursively modify all)(so after creating the user to modify the owner and the group, this is the complete creation of the user, as the adduser default)

Cp-r/etc/skel/. [!.] */home/user2

Chown-r User2:user2/home/user2

Create a user command supplement

Useradd user3-s-u-g-c-d-G

-S: User shell

-u:uid

-g:gid when the primary group does not specify GID, the GID is created with username, and the specified group must be present

-C: Description information

-D: Home directory

-G: Additional groups

Modify User Information command

Usermod user3-s-u-g-c-d

parameter is the same as creating a user

Create a group

Groupadd group1

Add User2 to additional groups group1

Usermod user2-g group1

Add User2 Additional group group2 (will overwrite group1)

Usermod user2-g group2

Add additional group-A in Append mode

Usermod User1-a-G group2

Delete a group

Groupdel

Linux user-related and group

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.