4-1 Linux User Management commands detailed

Source: Internet
Author: User

1./etc/passwd format

User name: Password: uid:gid: Comments: Home directory: Default Shell

useradd [Options] USERNAME

-u:uid to be greater than or equal to 500,

-g:gid refers to the basic group, must exist beforehand, UID will be at the bottom of an ID plus 1

episode, download the Xshell to run.

-g:gid, groups to exist, may exist multiple.

-C: "COMMENT" comment

-d:/path/to/somedirectory meaning for the specified home directory. The default is under Userfolder in the home directory.

-S: Specifies the security shell that is available for the current system, which exists under Etc/shells

Note the method for switching users: #su –username, as follows #su –user413

-M: Forcing the user to create a home directory

-K: To use with-m

/etc/skel, in fact, is the shell configuration file, where-A is used to display the shadow file

Use-M to specify not to create home directories

2. Do not create a home directory for users

First, there's a file that you can take out to see/etc/login.defs first.

/etc/login.defs is a file that sets user account limits. The configuration in this file is not valid for the root user.

If the same option is found in the/etc/shadow file, the settings in the/etc/shadow are the same, which means that the/etc/shadow configuration takes precedence over/etc/login.defs

# *required* REQUIRED

# Directory where mailboxes reside, _or_ name of file, relative to the

# home directory. If you _do_ define both, Mail_dir takes precedence.

# Qmail_dir is for QMAIL

#

#QMAIL_DIR Maildir

Mail_dir/var/spool/mail# Specifying the Mail directory

#MAIL_FILE. MAIL

# Password Aging Controls:

#

# pass_max_days Maximum Number of days a password could be used.

# pass_min_days Minimum Number of days allowed between password changes.

# Pass_min_len Minimum acceptable password length.

# pass_warn_age number of days warning given before a password expires.

#

Pass_max_days 99999 #密码最大有效期

Pass_min_days 0 #两次修改密码的最小间隔时间

Pass_min_len #密码最小长度, invalid for root

Pass_warn_age 7 #密码过期前多少天开始提示

#

# Min/max values for automatic uid selection in Useradd

#创建用户时不指定UID的话自动UID的范围

Uid_min #用户ID的最小值

Uid_max 60000 #用户ID的最大值

#

# Min/max values for automatic gid selection in Groupadd

#自动组ID的范围

Gid_min #组ID的最小值

Gid_max 60000 #组ID的最大值

#

# If defined, this command was run when removing a user.

# It should remove any at/cron/print jobs etc. owned by

# The user to be removed (passed as the first argument).

#

#USERDEL_CMD/usr/sbin/userdel_local script that executes when the user is deleted

#

# If Useradd should create home directories for users by default

# on RH systems, we do. This option was overridden with THE-M flag on

# useradd command line.

#

Create_home Yes #使用useradd的时候是够创建用户目录

# The permission mask is initialized to this value. If not specified,

# The permission mask is initialized to 022.

UMASK 077 #

# This enables Userdel to remove the user groups if no members exist.

#

Usergroups_enab Yes

# use MD5 or DES to encrypt password? Red Hat use MD5 by default.

Md5_crypt_enab Yes #用MD5加密密码

3. Delete a user

Userdel

#userdel [Options] USERNAME

If no option is specified, the home directory is not deleted.

ID: View user's account information

#id USERNAME

Note that there is also a finger command, this should be an external command, the function is to view the user account information.

In fact Userdel This command just delete/etc/passwd under the account information. But the information under home has not been deleted.

If you want to completely delete, you need an option –r

To add that, when Tom was deleted, passwd was deleted, but home has not been deleted, and if we delete it by this order, it will go wrong. As for how to do, come back to summarize.

Take Jack for example.

4. Modify user account Properties

Usermod is similar to Useradd

-U UID

-G GID

-G GID will overwrite the original GID

-a-g GID, adding a new group, does not overwrite

-d-m: Specify both home directory and previous home directory content (this is unclear)

-L lock account, similar to disable

CHSH: Change the user's default shell

CHFN: Modifying annotation information

5. Password Management

passwd users are only used to change their own password

passwd USERNAME, admin change other password

--stdin: (standard input), standards inputs, the standard input accepts the password, the future script will use

-L: Lock user account

-D: Remove user password

Pwck:password Check the user account integrity. But it's not clear how this is going to look.

6. Group Management

Create a group

Groupadd, specifying GID with –g, does not specify greater than or equal to 500, and is larger than the previous.

Remember: There are groups that can be viewed through cat/etc/group

-R: Add a System user or group, the system account does not have login permission, and there is no home

Groupmod:

-g:gid

-N GRPNAME

Groupdel

GPASSWD: Change password for group

NEWGRP GROUPNAME Switch Group

It seems that creating a user and adding a password contains three aspects: passwd, Shell, and group file, plus one row. But to understand the format

7. Job

4-1 Linux User Management commands detailed

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.