Linux Beginner's note seven: Linux User management, password and group commands in detail! (Video serial number: 04_1)

Source: Internet
Author: User
Tags stdin

Commands to learn in this section:

User Management commands: USERADD,USERDEL,ID,FINGER,USERMOD,CHSH,CHFN,PASSWD,PWCK,

Group Management commands: Groupadd,groupmod,groupdel,gpasswd,newgrp,chage

Skills learned in this section:

User Management commands

Password management commands

Group Management Commands

User Management commands:

Useradd, Userdel, Usermod, passwd, Chsh, CHFN, finger, id, chage

useradd [Options] USERNAME : Add a user (only three files are involved: Passwd,shadow,group)

-u:uid (greater than or equal to 500, non-repeatable by default)

-g:gid (Basic Group) (group must exist beforehand)

-g:gid,... (additional groups) (can have multiple, group prior to existence)

-C "COMMENT": (note information)

-d/path/to/directory: (Specify home directory)

-S Shell (specifies the user's default shell, preferably a shell present in the "/etc/shells" file)

(/etc/shells: Specifies the security shell that is available for the current system)

(See what your SHELL is:echo $SHELL)

-m–k: (Forced to create home directory, and copy files from/etc/skel home directory

-M: Do not create home directory for users, even if /etc/login.defs set user should have home directory we also do not create it for him)

-R: Adding system users

Environment variables:

PATH

Histsize

SHELL

userdel [option] USERNAME: Delete User

-r: Delete User's home directory at the same time

ID: View user's account attribute information

-U: View UID (user ID) of the user

-G: View the user's GID (Base group ID)

-G: View group IDs for all groups (including additional groups and all groups)

-N: (can be used in combination with the above three to display the name)

finger USERNAME: View user account information (not installed by default, installation method:yum install finger)

usermod: Modify user account properties

-U UID: Modifies the user's user ID

-G GID: Modifies the user's base group ID (the base group is pre-existing)

-a-g GID: Changes the user's additional group (without using the-a option, overwriting the previous additional group)

-C: Modify annotation information

-D-M: Specify a new home directory for the user and move all files under the home directory to the new home directory)

(-D: Specify a new home directory for the user, the files used in the previous home directory can no longer be accessed)

-S: Modify the user's shell

-L: Modify the user's login name (is lowercase l)

-e: Define the user's expiration time (when disabled, format "YYYY-MM-DD")

-F: Specifies the user's inactivity time (the time that the password expires and is not disabled)

-L: Lock account

-U: Unlock Account

Chsh: Modifying the user's default shell

CHFN: Modify comment information (can be viewed with finger username and tail-1/etc/passwd)

Password Management commands:

passwd [USERNAME] ( The default is only to modify its own password, only the administrator can specify the user name, to modify the other user's password)

--stdin: read password from standard input (ex: echo "Redhat" | Passwd–stdin user2)

-L: Lock user account (lowercase l)

-N: Minimum password usage period

-X: Maximum password lifetime

-W: Password warning period

-U: Unlock user account

-D: Remove user password

pwck: Checking user account Integrity

Group Management Commands:

Groupadd: creating groups

-G GID: Specify user base Group ID

-R: Added as System group

  groupmod: Modifying Group Property information

-G GID: Modify user base Group ID

-N GRPNAME: Modify Group name

Groupdel: Deleting a group

gpasswd: Set password for group (newgrp GRPNAME: Temporarily switch base Group to another group, password required)

Newgrp GRPNAME <--> Exit

chage: change user password expiration information. (not familiar with)

-D: Last modification time

-E: Expiration time (0 means immediate expiration, 1 means never expires)

-I: Inactive time (I in uppercase) (number of days after password expiration, locked account)

-L: Lists the user's and password's expiration date (lowercase l)

-M: Minimum period of use

-M: Maximum lifespan

-W: Warning time

Practice:

1, create a user Mandriva, whose ID number is 2002, the basic Group is distro (group ID 3003), the additional group is Linux;

# groupadd-g 3003 distro

# Groupadd Linux

# useradd-u 2002-g distro-g Linux Mandriva

2, create a user fedora, whose full name is Fedora Community, the default shell is tcsh;

# useradd-c "Fedora Community"-s/bin/tcsh Fedora

3, the change Mandriva ID number is 4004, the basic group is Linux, the additional group is distro and fedora;

# usermod-u 4004-g linux-g Distro,fedora Mandriva

4, to Fedora Plus password, and set its minimum password period of 2 days, the longest is 50 days;

# passwd-n 2-x Fedora

5. Change the default shell of Mandriva to/bin/bash;

Usermod-s/bin/bash Mandirva

6, add the system user HBase, and do not allow its login system;

# useradd-r-s/sbin/nologin HBase

Linux Beginner's note seven: Linux User management, password and group commands in detail! (Video serial number: 04_1)

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.