Linux user and group rights management commonly used commands and parameters

==========================================================================

1. Basic concepts:

Owner: General file creator, who created the file, it is natural to become the owner of the file

                By [chown username] to modify the file's owner

When a user group creates a file, the file's group is the user is: where the group

                By [chgrp group file name], modify the file's group

 ==========================================================================

2. User Management

useradd aaron add users

passwd aaron Change Password

Delete user userdel aaron

useradd aaron -m add users to simultaneously create the user's home directory

userdel aaron -r delete users delete the user's home directory

==========================================================================

3. User Group

groupadd group1 Add Group

groupdel group1 delete group

==========================================================================

4. add users to the group

Create a new user and add to the group

useradd -g group1 aaron add users to join the group at the same time

usermod -g group1 aaron change the user's group

usermod -g directory name aaron change the initial user login directory

The existing users to join group

gpasswd -a aaron group1 Users Group

gpasswd -d aaron group1 to remove the user from the group

==========================================================================

The user and group file

/ Etc / passwd to see all user information system

/ Etc / group to view all group information system

 ==========================================================================

6 , see the user details

finger Username

 ==========================================================================

7 , set up user profiles, input the user's profile

chfn user name (the system will interact with the model to improve the user's profile)

 ==========================================================================

8 , a user specified display command information

 

Including user ID, user name, number and the name of the primary group, affiliated group list

id username

 ==========================================================================

9, delete users and their personal folders

 

(Delete personal folders before adding -r)

userdel -r username

 ==========================================================================

Note: you can when using the useradd command by man or useradd --help to view information specific parameters, parameter using the parameter information required in accordance with.

==========================================================================

10 , common commands specific parameters

==========================================================================

Syntax: the usermod [parameters]

 

-c <Notes>

Modify user account callout text

-d <login directory>

Modify directory when the user logs in

-e <expiration date>

Modify the account expiration date

-f <buffer days>

Modify the number of days after the password expires, ie close the account

-g <group>

Modify the group the user belongs

-G <groups>

Modify additional groups the user belongs

-l <account name>

Modify the user account name

-L

Lock user password, the password is invalid

-s<shell>

After the shell is used to modify user login

-u<uid>

Modify User ID

-U

Password lock is released

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax: groupmod [parameters]

Common parameters:

-g

To use the setting group identifier

-O 

Reuse group ID

-n

To use the setting group name

 

 

 

 

 

 

 

 

==========================================================================

Syntax chgrp [parameters] [directory]

Common parameters:

-c

Similar partially effective "-v" argument, but only in return change

-f

No error message

-h

Make changes to a file symbolic link, without any change to other relevant documents

-R

Recursive processing, all files and subdirectories in the specified directory treated together

-v

Display during execution of instructions

–reference

The specified file or directory belongs to group all of their group and set to reference the same file or directory

 

 

 

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax: chown [parameters]

Common parameters:

-R

All files and subdirectories under the current directory of the same owner change

-c

If the file owner really has changed, it shows the change action

-f

If the document owner can not be changed and do not display an error message

-h

Only changed files to link (link), rather than the real point of the link

-v

Details show the owner to change the

–help

Display HELP

–version

Display version

 

 

 

 

 

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax:  chmod [parameters] [file]

Common parameters:

-c

If the file permissions have changed indeed, it shows the change action

-f

If the file permissions can not be changed nor display an error message

-v

Details show permission to change the

-R

All files and subdirectories in the current directory the same permissions changed (that is handed back to the way one by one to change)

 

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax: useradd [parameters] [username]

Common parameters:

-D

New user to change the preset value

-c

Add notes text

-d

When a new user home directory used by each landing

-e

User termination date, the date format is YYYY-MM-DD

-f

Users expired permanently suspended a few days. When the value is 0, the user is immediately suspended, and then turn this feature off value of -1, the default value of -1

-g

Specified user group corresponding to the user

-G

This is defined as a member of a number of different user groups

-m

Is automatically created when a user directory does not exist

-M

Does not create the user's home directory, set file priority over /etc/login.defs

-n

Cancel establish a user name in the name of the group

-r

Establish a system account

-u

Specifies the user id

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax: userdel [parameters] [username]

Common parameters:

-f

Forced to delete user accounts

-r

Delete the user's home directory and any files

-h

Displays help information about the command

 

 

 

 

 

 

 

 

 

==========================================================================

Syntax : groupdel [parameters] [group name]

Common parameters :

-h

Displays help information

-R

Apply the changes and use the configuration file chroot_dir directory in the directory chroot_dir

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/kunlunsun/p/11425838.html