In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the relevant configuration files for managing users and user groups in the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Linux is a multi-user, multi-task operating system. Understand Linux's single-user multi-task, multi-user multi-task.
The distinction between the roles of the user:
Users are divided into roles in the system, and in the Linux system, due to different roles, permissions and tasks are also different. it is worth noting that users' roles are identified through UID, especially UID; in system management, the system administrator must adhere to the unique characteristics of UID.
Root user: the system is unique, is real, can log in to the system, can operate any file and command, and has the highest permissions
Virtual user: this kind of user is also called pseudo-user or fake user, which is different from real user. This kind of user does not have the ability to log on to the system, but it is a system.
Users who are indispensable for unified operation, such as bin, daemon, adm, ftp, mail, etc.; these users are owned by the system itself, not later.
Of course, we can also add virtual users
Ordinary real users: this kind of users can log in to the system, but can only operate the contents of their own home directory, and their permissions are limited. These users are added by the system administrator himself.
If you want to know some accounts of the Linux system, please check / etc/passwd
The corresponding relationship between users and user groups is one-to-one, many-to-one, one-to-many or many-to-many.
Profiles related to users (user) and user groups (group):
1) profile related to the user (user)
The code is as follows:
/ etc/passwd
Note: profile of user (user)
The code is as follows:
/ etc/shadow
Note: user (user) shadow password file
2) configuration files related to user groups (group)
The code is as follows:
/ etc/group
Note: user Group (group) profile
The code is as follows:
/ etc/gshadow
Note: shadow file of user group (group)
Tools or commands for managing users (user) and user groups (group):
1. Tools or commands for managing users (user)
Useradd Note: add user
Adduser Note: add user
Passwd Note: set the password for the user
Usermod Note: modify user commands, you can use usermod to modify login, user's home directory, and so on.
Pwcov Note: synchronize users from / etc/passwd to / etc/shadow
Pwck Note: pwck verifies whether the contents of the user profile / etc/passwd and / etc/shadow files
Legal or complete
Pwunconv Note: it is a vertical reverse operation of pwcov, created from / etc/shadow and / etc/passwd
Build / etc/passwd, and then delete the / etc/shadow file
Finger Note: view user Information tool
Id Note: check the user's UID, GID and the user group to which they belong
Chfn Note: change user Information tool
Su Note: user switching tool
Sudo Note: sudo executes the command through another user (execute a command as
Another user), su is used to switch users, and then finish by switching to the user
Into the corresponding task, but sudo can directly execute commands later, for example, sudo does not need root
Password can be executed root assigned execution only root can execute the corresponding command; but
Through visudo to edit / etc/sudoers to achieve
Visudo Note: visodo is a command for editing / etc/sudoers; you can also use this command directly
The effect of editing / etc/sudoers with vi is the same.
Sudoedit Note: similar to sudo function
2. Tools or commands for managing user groups (group)
Groupadd Note: add a user group
Groupdel note: delete a user group
Groupmod Note: modify user group information
Groups note: displays the user group to which the user belongs
Grpck
Grpconv note: synchronize or create through the file contents of / etc/group and / etc/gshadow
Build / etc/gshadow, create if / etc/gshadow does not exist
Grpunconv Note: synchronize or create the contents of / etc/group and / etc/gshadow files
Build / etc/group, then delete the gshadow file
3. / etc/skel directory
The / etc/skel directory is generally the directory where the user startup files are stored. This directory is controlled by root permissions. 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 all hidden files, that is, similar to the .file format. We can provide users with a unified, standard and default user environment by modifying, adding and deleting files in the / etc/skel directory.
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 root 4096 August 11 23:32.
Drwxr-xr-x 115 root root 12288 October 14 13:44..
-rw-r--r-- 1 root root 24 May 11 00:15. Bash _ logout
-rw-r--r-- 1 root root 191 May 11 00:15. Bash _ profile
-rw-r--r-- 1 root root 124 May 11 00:15 .bashrc
-rw-r--r-- 1 root root 5619 2005-03-08 .canna
-rw-r--r-- 1 root root 438 May 18 15:23. Emacs
-rw-r--r-- 1 root root 120 May 23 05:18 .gtkrc
Drwxr-xr-x 3 root root 4096 August 11 23:16. KDE
-rw-r--r-- 1 root root 658 2005-01-17 .zshrc
The files under the / etc/skel directory are usually copied to the home directory of the newly added user (user) automatically when we use the useradd and adduser commands to add users (user). If we add users by modifying / etc/passwd, we can create the user's home directory ourselves, 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
The / etc/login.defs file is some planning when creating a user, such as whether a home directory is required when creating a user, the scope of UID and GID, the duration of the user, and so on. This file can be defined through root.
For example, the contents of the / etc/logins.defs file of Fedora
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: when creating 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 may 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 maximum number of days that a user's password does not expire
PASS_MIN_DAYS 0 Note: the minimum number of days between password changes
PASS_MIN_LEN 5 Note: minimum password length
PASS_WARN_AGE 7
#
# Min/max values for automatic uid selection in useradd
#
UID_MIN 500Note: the minimum UID is 500. that is to say, when adding users, UID starts at 500th.
UID_MAX 60000 Note: maximum UID is 60000
#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN 500Note: GID starts at 500th.
GID_MAX 60000
#
# If defined, this command is 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
#
# 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's home directory is required.
5. / etc/default/useradd file
Rules file when adding users 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: whether to enable account expiration suspension.-1 means it is not enabled.
EXPIRE= Note: account termination date. If not set, it will not be enabled.
SHELL=/bin/bash Note: type of SHELL used
SKEL=/etc/skel Note: the default directory for adding users is the default file location; that is, when we add users with adduser, the user
All the files in the home directory are copied from this directory.
This is the end of the content of "what are the relevant configuration files for managing users and user groups in the Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.