Management of Linux Users and groups (command join, manual join, join group, switch between users)

Source: Internet
Author: User
Tags md5

First, the user log on when the need to verify that the two files

Check username Login:root to this folder for/etc/passwd

Check/etc/shadow with password passwd:123456 to this folder

Fields under/ETC/PASSWD (one user per behavior)

Grammar:

root:x: 0:0:root:/root:/bin/bash (/etc/passwd)

x is a placeholder that represents password

Root:$1$nv0hq/3m$nkludcy6gzoj8wx/zadeu1:15321:0:99999:7::: (/etc/shadow)

Username: MD5: Password After encryption: The time difference from start to create the user: Two changes password minimum interval: Two change password maximum time interval: Warning TIME: Expires: Spare time

The maximum number of days to be exceeded does not change the user will expire

Encryption uses the default MD5

Dump the password inside the passwd into the shadow.

pwconv : convert passwd files to shadow

Return the encrypted password in shadow to the x position and run the command Pwunconv the same time/etc/shadow the file will not exist.

Second, the user's joining steps:

The first method, with the Useradd command

Useradd name (Lisi)

Assume that you run the following command:

#useradd Lisi

The effects are:

/etc/passwd add a row to save username

/etc/shadow Save Password

/home/lisi Creating a folder with the same name

[Email protected] root]# ls-a/home/lisi

.  .. . bash_history. bash_logout. Bash_profile. BASHRC Emacs File1. GTKRC

/etc/group adds a row, group.

When you join a user with Useradd, a row is added by default under Etc/group, which is the group that the user represents.

There are no members in the default group such as the following see:

LISI:X:500:

There are members of the

Lisi:x:503:zhy1,zhy

Another method; Manually join a user

1) #vi/etc/passwd

Zhy2::504:504:csdnphpstudent:/home/zhy2:/bin/bash

Cancel Shadow Pwunconv

Recovering Shadow Pwconv

Join under the Home

# Mkdir/home/lisi

/etc/skel folder where the folder holds the new user's script files (implied files in/home/u_name)

Copy the files under the/etc/skel folder to/home/lisi (the copy operation is self-initiated with the Useradd command)

/etc/login.defs---Settings for the user environment


Third, the difference between adding users manually and using Useradd

Users who joined with Useradd because they were joined by the system.

The scripts in Skel are assigned to each by a script file that is already defined.

Newly added user under/home/, here when read/etc/login.defs this file

The umask set here is 077, so the permissions for the last created folder are 700.

Instead of manually joining the user, under Home, add the user folder with the same name as above

#mkdir/home/zhy2, the permissions created for this folder will not be affected by/etc/login.defs

, it is based on the umask value of its parent folder, so the right to manually join the user is

777-home of the umask.


Iv. Join a group

#groupadd Group name (the group name must be a user)

Open: This folder/etc/group you can see:

Group Name: Password: The user in the GID reorganization (with, separate) for example the following

zhy4:x:503:zhy1,zhy


V. Editing of the Group

Add a member to a group

#gpasswd-A user group

Remove a member from a group

#gpasswd-D User Group

Add:

1, do not add-the switch user

[。。。。。 Lisi] Su Zhy

The currently replaced user is Zhy but the folder is the same

2, plus-the user switch

[。。。。。 Lisi] Su - zhy

The currently replaced user is Lisi but the folder becomes ~

[。。。。。 ~]

Here ~ Indicates the working folder of the host

Suppose it was root/root.

Suppose it was lisi/home/lisi.

If a folder does not have X permissions, then the CD cannot be used

If a folder does not have R permissions, LS cannot be used

Suppose a folder does not have W permissions, Touch mkdir ....


Management of Linux Users and groups (command join, manual join, join group, switch between users)

Related Article

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.