search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat are the types of linux user groups?

There are two types of Linux user groups: 1. Basic group (private group); when creating an account, if the group to which the account belongs is not specified, the system will create a group with the same name as the user , this group is the basic group. 2. Additional groups (public groups) can accommodate multiple users, and users in the group have the rights owned by the group.

Classification of Linux users and groups

1. Users under Linux can be divided into 3 categories

  • Super user - the user name is root, which has all permissions. You can log in as a super user only for system maintenance (for example: creating users, etc.) or other necessary circumstances to avoid system security problems.

  • The user necessary for the normal operation of the Linux system is the pseudo user (system user). It is mainly established to meet the requirements of the corresponding system processes for file owners, such as bin, daemon, adm, lp and other users. System users cannot be used to log in.

  • Ordinary user - is established to allow users to use Linux system resources. Most of our users fall into this category.

2. There are two types of groups in Linux:

  • Basic group ( private group ) : When creating an account, if the group to which the account belongs is not specified, the system will create a group with the same name as the user name. This group is the basic group.

  • Additional Group ( public group ) : Can accommodate multiple users, and users in the group have the rights owned by the group.

3. Configuration files of user groups and users in Linux

In Linux, user accounts, passwords, user group information, and users Group passwords are stored in different configuration files.

/etc/passwdUser password/etc/shadowUser group account file/etc/gruoupUser group password file/etc/gshadow##

(1) User account file——/etc/passwd

passwd is a text file used to define user accounts of the system, since all users have passwd has read permission, so only user accounts are defined in this file, and passwords are not saved.

What are the types of linux user groups?

# Each line defines a user account information, each line consists of 7 It consists of fields, and the fields are separated by ":" separated by:

Account Name : password :UID:GID: personal information : Main directory :Shell

/etc/passwd Field description in the file

  • Account name: User login Linux The name used by the system.

  • Password: This was where passwords were previously saved in encrypted format, now passwords are saved in /etc/shadow file, here is just the password holder "x" or "*" . If "x" , indicating that the password has passed shadow protection of.

  • UID : The user's identifier is a numerical value, which is used to distinguish different users. Each user has a UID Value:

    of super user UID——0

  • System user’s UID——1 ~ 999

  • for ordinary users UID—— ≥ 1000

  • GID : The identifier of the basic group where the user is located is a numerical value, which is used to distinguish different groups. The same group has the same GID .

  • Personal information: You can record the user’s complete name, address, office phone number, home phone number and other personal information.

  • Home directory: similar Windows 's personal directory, usually /home/username ,here username is the username, user executes "cd ~ " command, the current directory will be switched to the personal home directory.

  • Shell : Define what is activated after the user logs in Shell , the default is Bash Shell

(2) User password file——/etc/shadow

What are the types of linux user groups?

#Each line A user information is defined. Each field in the row is separated by ":". The format is as follows:

Login name: Encrypted password: Last modification time: Minimum time interval: Maximum time interval: Warning time: No Active Time:Expiration Time:Flag The meanings of the 9 fields in each line of the

/etc/shadow file are fields

  • Login name: Login name

  • Encrypted password: Password encrypted using SHA-512/SHA-256/MD5 algorithm ($id$, id is 1 for md5, 5 for sha256, 6 for sha512), if it is empty, Indicates that the user can log in without a password. If it is "*", it means that the account cannot be used to log in to the system. If it is "!", it means that the account password has been locked.

  • Last modification Time: The date when the password was last changed, expressed as the number of days from January 1, 1970

  • Minimum time interval: How many days the password cannot be changed. The default value is 0, which means there is no limit.

  • Maximum time interval: how many days after which the password must be changed. The default value is 99999, which means no restriction.

  • Warning time: how many days in advance to warn the user that the password will expire. The default value is 7 days, 0 means no warning is provided

  • Inactivity time: How many days after the password expires to disable this user

  • Expiration time: Password expiration date, expressed in days from January 1, 1970, the default is Empty, means permanently available. Flag: reserved for future development.

View the date when the user last modified the root password

What are the types of linux user groups?

(3) User group account file -/etc/group

Each group in the system has a line record in the /etc/group file, and any user can Read the user group account information configuration file.

What are the types of linux user groups?

Field description

  • Groupname: The name of the group

  • Passwd: The encrypted password of the group

  • GID: It is the ID that the system uses to distinguish different groups. The GID field in the /etc/passwd domain uses this number to specify the user's basic group.

  • Userlist: It is the user name separated by ",", and the listed members have this group as an additional group.

Assignment:

1. Create user lockuser, and specify the home directory as /home/lock, and then lock the user

What are the types of linux user groups?

2. Unlock lockuser and set the password to be changed the next time you log in.

What are the types of linux user groups?

3. Create user testuser and set password , change the user name to normaluser

What are the types of linux user groups?

4. Create a file, query the acl of the file, set acl for the file. The user is testuser1 and the permission is rwx. Set the acl mask: permission for the file. For r-x

What are the types of linux user groups?

What are the types of linux user groups?

5, set suid, set suid for the file (two ways u s and nnnn)
6. Set sgid, the way to set sgid for files (two ways g s and nnnn)
7. Set sbit, the way to set sbit for directories (two ways o t and nnnn)

What are the types of linux user groups?

What are the types of linux user groups?

Linux Add User to User Group

Through several examples using the Linux command line, I will show you step by step how to add users to the user group on Linux. Add users to user groups and how to add users and groups on Linux. These commands should work on any Linux distribution and have been tested on CentOS, Debian, and Ubuntu.

Add a new user to the user group

A Linux user can have a primary group and one or more secondary groups. These groups can be used as arguments to the adduser command when creating a user.

All commands must be executed as the root user. On Ubuntu, prepend all commands with sudo, or run sudo -s to switch to the root user.

Add user groups

As a first step, I will add two new user groups, family and friends :

groupadd family
groupadd friends

Add a new user to a single user group

Below I will add a new user tom and also add the user to the user group Groupfamily. The family user group will be added as a subordinate group using the -G parameter.

useradd -G family tom

Add new user to multiple user groups

tom is now a user in the family user group. Parameter -G allows specifying multiple user groups, separated by commas between each user group. If you want to add user tom to the family and friends user groups, use the following command:

useradd -G family,friends tom

Set User Password

Please note that new Linux user tom does not have a password yet, so cannot log in. To set the password for this user, you can execute the following command:

passwd tom

and enter the new password twice when the command requests it.

In the above example, we added user tom to the secondary group. The adduser command automatically created a new primary group and assigned the group Main group.

  • Username: tom

  • Main group: tom

  • Affiliated group: family (or Use the second case to add two subsidiary groups, family and friends)

Set a new main group

Maybe you want to add ## When using #tom, set the main group to family (instead of the tom user group created by default), and the subsidiary group to friends, you can use this Command:

useradd -g family -G friends tom

Use the

man command to get a detailed description of all command line options of the useradd command:

man useradd

What are the types of linux user groups?

Add an existing user to the user group

For this task, we will use the

usermod command. usermod The command can modify various options of the user, including the user's group membership.

First I will add a third user group

colleagues:

groupadd colleagues

using usermod

I will add the

colleagues user group as an affiliate group to the user tom:

usermod -a -G colleagues tom

Command explanation:

-a means append, which can only be used in combination with the -G option (affiliated group). So in the end we added the tom user to the colleagues user group, which is an affiliated group of the user.

-G 选项可以指定多个用户组,每个用户组之间使用逗号进行分隔。例如:-G group1,group2,group3

如果想要修改 tom 用户的主组为 family,可以使用命令:

usermod -g family tom

使用 man 命令可以获取 usermod 命令的所有命令行选项的详细说明:

man usermod

What are the types of linux user groups?

File function File name
##User account file


The above is the detailed content of What are the types of linux user groups?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
Linux Operations: Understanding the Core FunctionalityLinux Operations: Understanding the Core FunctionalityMay 03, 2025 am 12:09 AM

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

Linux: Entering and Exiting Maintenance ModeLinux: Entering and Exiting Maintenance ModeMay 02, 2025 am 12:01 AM

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

Understanding Linux: The Core Components DefinedUnderstanding Linux: The Core Components DefinedMay 01, 2025 am 12:19 AM

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

The Building Blocks of Linux: Key Components ExplainedThe Building Blocks of Linux: Key Components ExplainedApr 30, 2025 am 12:26 AM

The core components of the Linux system include the kernel, file system, and user space. 1. The kernel manages hardware resources and provides basic services. 2. The file system is responsible for data storage and organization. 3. Run user programs and services in the user space.

Using Maintenance Mode: Troubleshooting and Repairing LinuxUsing Maintenance Mode: Troubleshooting and Repairing LinuxApr 29, 2025 am 12:28 AM

Maintenance mode is a special operating level entered in Linux systems through single-user mode or rescue mode, and is used for system maintenance and repair. 1. Enter maintenance mode and use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can check and repair the file system and use the command "fsck/dev/sda1". 3. Advanced usage includes resetting the root user password, mounting the file system in read and write mode and editing the password file.

Linux Maintenance Mode: Understanding the PurposeLinux Maintenance Mode: Understanding the PurposeApr 28, 2025 am 12:01 AM

Maintenance mode is used for system maintenance and repair, allowing administrators to work in a simplified environment. 1. System Repair: Repair corrupt file system and boot loader. 2. Password reset: reset the root user password. 3. Package management: Install, update or delete software packages. By modifying the GRUB configuration or entering maintenance mode with specific keys, you can safely exit after performing maintenance tasks.

Linux Operations: Networking and Network ConfigurationLinux Operations: Networking and Network ConfigurationApr 27, 2025 am 12:09 AM

Linux network configuration can be completed through the following steps: 1. Configure the network interface, use the ip command to temporarily set or edit the configuration file persistence settings. 2. Set up a static IP, suitable for devices that require a fixed IP. 3. Manage the firewall and use the iptables or firewalld tools to control network traffic.

Maintenance Mode in Linux: A System Administrator's GuideMaintenance Mode in Linux: A System Administrator's GuideApr 26, 2025 am 12:20 AM

Maintenance mode plays a key role in Linux system management, helping to repair, upgrade and configuration changes. 1. Enter maintenance mode. You can select it through the GRUB menu or use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can perform file system repair and system update operations. 3. Advanced usage includes tasks such as resetting the root password. 4. Common errors such as not being able to enter maintenance mode or mount the file system, can be fixed by checking the GRUB configuration and using the fsck command.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment