Introduction to related profiles for managing users and user groups in Linux systems

Source: Internet
Author: User

Linux is a multi-user, multitasking operating system that understands Linux's single-user multitasking, multi-user multitasking, and user role differentiation:
Users in the system is a role in the Linux system, due to different roles, permissions and the task accomplished are different; it is noteworthy that the user's role is through UID and recognition, especially the UID; in system management, the system administrator must stick to the unique characteristics of UID;

Root User: System only, is true, can login system, can the operating system any files and commands, with the highest authority;
Virtual User: This type of user is also known as a pseudo user or dummy user, in contrast to real users, this type of user does not have the ability to log on to the system, but it is an indispensable user for the system to run, such as bin, daemon, ADM, ftp, mail, etc., which are owned by the system and not later added, Of course, we can also add virtual users;
Ordinary real User: This kind of user can login the system, but only can operate own home directory content, the limited authority, this kind of user all is the system administrator to add;
If you want to know some of the Linux system account number, please check the/etc/passwd;
The corresponding relationship between user and user group is: one-to-one, more than one or one pairs or more;

Profiles related to users (user) and user groups (group):
1 configuration files related to user (users);

The code is as follows:

/etc/passwd

Note: User's configuration file;

The code is as follows:

/etc/shadow

Note: User shadow password file;

2 configuration files related to user groups (group);

The code is as follows:

/etc/group

Note: User groups (group) configuration file;

The code is as follows:

/etc/gshadow

Note: Shadow files for user Group (group);

Manage tools or commands for user (user) and group (group):
1. Manage user's tools or commands;
Useradd Note: Add user;
AddUser Note: Add user;
PASSWD Note: Set the password for the user;
Usermod Note: Modify the user command, you can modify the login by Usermod, user's home directory and so on;
Pwcov Note: Sync user from/etc/passwd to/etc/shadow;
PWCK Note: Pwck is the validation of user profile/etc/passwd and/etc/shadow file content is legal or complete;
Pwunconv Note: Pwcov is the reverse operation, from/etc/shadow and/etc/passwd to create/etc/passwd, and then delete/etc/shadow files;
Finger Note: View user Information tool;
ID Note: View the user's UID, GID, and the user group they belong to;
CHFN Note: Change the user Information tool;
SU Note: User Switching tool;
sudo note: sudo executes commands through another user (execute a command as another user), Su is used to toggle the user, and then through the switch to the user to complete the corresponding task, but sudo can directly follow the command, such as Sudo does not need The root password can be executed with root assignment only root can execute the corresponding command, but it has to be visudo to edit the/etc/sudoers to achieve;
Visudo Note: Visodo is the editor of the/etc/sudoers command, you can not use this command, directly with VI to edit the/etc/sudoers effect is the same;
Sudoedit Note: Similar to sudo function

2. Tools or commands for managing user groups (group)
Groupadd Note: Add user group;
Groupdel Note: delete user group;
Groupmod Note: Modify user group information
Groups Note: Displays the user group to which the user belongs
Grpck
GRPCONV Note: Synchronizes or creates/etc/gshadow through the contents of/etc/group and/etc/gshadow files, if/etc/gshadow does not exist;
Grpunconv Note: Synchronize or create/etc/group through/etc/group and/etc/gshadow file contents, then delete gshadow file;

3,/etc/skel directory;
The/etc/skel directory is typically a directory of user startup files, which is controlled by root, and when we add users, the files in this directory are automatically copied to the newly added user's home directory; the files in the/etc/skel directory are hidden files. which is similar to. file format, we can modify, add, delete the/etc/skel directory of files, to provide users with a unified, standard, Default user environment;

The code is as follows:

[Root@localhost beinan]# ls-la/etc/skel/
Total dosage 92

The code is as follows:

Drwxr-xr-x 3 root 4096 August 11 23:32.

Drwxr-xr-x  115 Root 12288 October 14 13:44.
-rw-r--r--   1 root root    24  5 00:15. Bash_logout
-rw-r--r--   1 Root R Oot   191  5 00:15 bash_profile
-rw-r--r--   1 root root   124  5 month 00:15
-rw-r--r--   1 root root  5619 2005-03-08  .canna
-rw-r--r--   1 root root   4  5 15:23. Emacs
-rw-r--r--   1 root root    5.05:18
GTKRC drwxr-xr-x ;  3 root root  4096  8 23:16. KDE
-rw-r--r--   1 root root   658 2005-01-17  .zs HRC
/etc/skel   directory files, typically when we add users (user) with Useradd and adduser   commands, the system is automatically copied to the newly added user's home directory; If we modify the/etc/ passwd   To add users, we can create the user's home directory, and then copy the files under/etc/skel to the user's home directory, and then use Chown to change the owner of the new user's home directory;

4,/etc/login.defs configuration file;
/etc/login.defs files are some of the planning for creating users, such as the need for home directories, UID and GID ranges when creating users, and the duration of the user, which can be defined by root;
For example, Fedora/etc/logins.defs file content;

The code is as follows:

# *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 Note: To create a user, create a user mail file in the directory/var/spool/mail;
#MAIL_FILE
# 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 Note: The user's password is not the maximum number of days;
Pass_min_days 0 Note: The minimum number of days between password modifications;
Pass_min_len 5 Note: Minimum password length;
Pass_warn_age 7
#
# Min/max values for automatic uid selection in Useradd
#
Uid_min 500 Note: The minimum UID is 500, which means that when adding a user, the UID starts at 500;
Uid_max 60000 Note: maximum UID is 60000;
#
# Min/max values for automatic gid selection in Groupadd
#
Gid_min 500 Note: The GID is starting from 500;
Gid_max 60000
#
# 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 "the"-argument).
#
#USERDEL_CMD/usr/sbin/userdel_local
#
# If Useradd should create home directories for users by default
# on RH systems, we do. This option is ORed with THE-M flag on
# useradd command line.
#
Create_home Yes Note: whether to create a user home directory, request creation;
5,/etc/default/useradd documents;
Rule file when adding a user through useradd;

The

Code is as follows:
# useradd defaults file
group=100
home=/home         NOTE: Build the user's home directory in/home;
Inactive=-1           Note: Enable account expiration stop, 1 means not enabled;
expire=                   NOTE: Account expiration date, not set to indicate not enabled;
Shell=/bin/bash     Note: type of SHELL used;
Skel=/etc/skel         NOTE: The default location for adding users ' directory default files is added, which means that when we add a user with AddUser, the files in the user
home directory are copied from the directory;

Related Article

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.