Linux User management commands (version 2) and linux User Management
Add User
1. useradd-set Option username [-D view default parameters]
Option:
U: UID (which must not be in the system]
G: Default User Group GID [preferably]
G: specify multiple groups to which the user belongs. You can specify the department to which the user belongs]
D: Specifies the home directory]
S: Command Interpreter Shell [must be included in the/etc/shells file]
C: Description (which can be used to describe who the user is and what permissions the user has]
E: Specifies the user expiration time.
E. g.
Useradd-u 6666-g root-G sys, apache-d/project-s/bin/bash-c "Project manege"-e 2014-2-23 jack
2. Set Password: passwd jack
Delete a user
Userdel [user name] # delete a user. However, the user's home directory is retained.
Userdel-r [user name] # Delete the user's home directory
Add Group
Groupadd webadmin
Or: groupadd-g 8888 webadmin # specify GID = 8888
Save group information in the/etc/group file]
Add User to group and group management commands
To add users to a group: if a file needs to grant special permissions to several users, add these users to the group.
Method 1,
Usermod-G [group name] [user name]
Method 2: [set the group password and members in the management group using gpasswd]
Gpasswd-a [user name] [group name] # This command is not generally used in UNIX systems
-D. delete a user from the user group.
-A sets the user group administrator. This user can directly participate in the management of this group.
-R: delete user group password
-R: Prohibit users from switching to this group, for example, gpasswd-R webadmin.
Set a password for the group: gpasswd [groupname]
Save the group password in the/etc/gshadow file]
Switch the current user to the group
Switch the current user to a new group: newgrp
Enter the password :*****
View Current Account Information: id
View the group to which the current user belongs: groups
User authorization case
Description: authorizes jack and mary to write the directory/software.
Resolution: Authorize the directory to the user group, and then add users to the group, which is equivalent to authorizing these users
1. Create a directory: mkdir/software
2. Add group: groupadd softadm
3. Add a user to the group: usermod-G softadm jack
Gpasswd-a mary softadm
4. Change the directory group: chgrp softadm/software
5. Change the directory group permission: chmod g + w/software
6. view the directory information: ls-ld/software
Linux User management commands?
Chown changes the file owner
Chgrp changes the group to which the file belongs
Chmod changes the file's writeable, readable, and executable attributes.
Umask changes the properties of Preset files or directories.
Linux User Management: Super User Name, how to determine a unique user, commands for switching between users
The only way to determine a user is the user ID (uid), which is unique among users.
The commands for switching between users try su, and "Add-" indicates that the system environment is switched over, mainly to switch the system variables.