Summary of command knowledge about/etc/passwd,/etc/shadow,/etc/group, as well as user management and viewing of user information

Source: Internet
Author: User
Tags gopher


Summary of command knowledge about/etc/passwd,/etc/shadow,/etc/group, as well as user management and viewing of user information


/etc/passwd file

passwd files are user-related information, package contains user name, password, belongs to the main UID, group GID, annotation related, home directory, the user's shell

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

There are 7 fields, each of which represents:
1. User Name
2. Password, denoted by an x, is stored in an encrypted form under/etc/shadow
3. Master ID
4. Genus Group ID
5. Comment Information to the user for later viewing
6. User home Directory
7. The shell used by the user, a class of users are not logged in, that is, the shell is not used at all
Daemon:x:2:2:daemon:/sbin:/sbin/nologin

System users:
Mysql:x:27:27:mysql Server:/var/lib/mysql:/bin/bash

Custom User:
Fedora:x:2003:2003:fedora community:/home/fedora:/bin/tcsh

**

System UID under 500 (1-499), user-defined account GID at more than 500 (500-6000)

**

Add Users:

Useradd

-C: Note description, equivalent to fifth field
-D: Specifies the home directory, if not specified, a home directory with the name of the current user is created

-G: Group name must exist beforehand

-G: Additional groups

-M: Do not set up home directory

-R: Build system users

-S Shell: Specify the shell for user login

-u uid: Specify UID

/etc/login.defs: This has the default setting when setting up the user

Example: Add a user named Test,uid to 5500 and an additional group of Testone

#添加一个组

#groupadd Testone

#添加一个用户

#useradd test-u 5500-g Testone

Delete User: Userdel
-R: Even home directory deleted together

Modify user information: Usermod, there is not much option parameter and Useradd


Group:
User Group Category:
1. Private group: When a user is created, a group with the same name as the user is automatically created if no group is assigned to it

2. Additional groups

/etc/group

To add a group:
Groupadd

-R: Establishing a system group
-G GID: Specify Group ID

root:x:0:
test11:x:12366:test122

1. Group name
2. Managing passwords for Groups
3. Group ID
4. Additional groups, additional groups can have multiple

To delete a group:
Groupdel
You can only delete groups that are added using Groupadd, and you cannot delete groups that were created when a user was created by using Useradd
-N group_name: Change group name
-G GID: Change Group ID

Password file:/etc/shadow

root:$6$h7hzfcmaaohsyxto$i6ish8ddgj.fmmcqxrqe2ekjs7kyee8ciwmoxmbygb9uchywiws0uf0y3kndyyfkbvw2sufh2nbgd/ qwb9g8g.:16449:0:99999:7:::ubuntu:!! : 16682:0:99999:7:::

The meaning of each field represents:
1. Login
2. Encrypt password
3. Last password change since 1970.1.1
4. Minimum number of days for password duration
5. The maximum number of days the password lasts
6. The time the password will expire (warning in case of fast expiry)
7. The number of days after the password expires (after the password expires, the user is locked out if the password is not changed)
8. Password expiry time

Set password for user: passwd

passwd username
      If you do not specify a user name, change the password for the current user

     You can also use the following method to change the
    echo "Redhat" | passwd-- stdin username

    -l: Lock
    -u: Unlock
    -d: Remove user password
    
Other commands related to user account:
    
pwck Check user account integrity, incoming passwd file     

# pwck/etc/passwduser ' adm ': Directory '/var/adm ' does not Existuser ' UUCP ': directory '/VAR/SPOOL/UUCP ' does not existus Er ' gopher ': directory '/var/gopher ' does not Existuser ' oprofile ': directory '/home/oprofile ' does not existuser ' avahi-a UTOIPD ': directory '/VAR/LIB/AVAHI-AUTOIPD ' does not Existuser ' Saslauth ': directory '/var/empty/saslauth ' does not exist User ' pulse ': directory '/var/run/pulse ' does not exist

PWCK: No change ID: View user account usage information
-U: Display UID
-G: Show GID
-G: Show GID

# ID ubuntuuid=12362 (Ubuntu) gid=12367 (Ubuntu) group =12367 (Ubuntu)

CHSH: Changing the user's login shell
-S: Specify a shell

# tail/etc/passwd ubuntu:x:12362:12367::/home/ubuntu:/bin/bash# chsh-s/bin/tcsh ubuntuChanging shell for Ubuntu. Shell changed.# tail/etc/passwd ubuntu:x:12362:12367::/home/ubuntu:/bin/tcsh


This article is from the "Small City Studio" blog, please be sure to keep this source http://xcroom.blog.51cto.com/7941996/1711210

Summary of command knowledge about/etc/passwd,/etc/shadow,/etc/group, as well as user management and viewing of user information

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.