search
HomeCommon ProblemWhat 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, and 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.

What are the types of linux user groups?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

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. Only use the super user when performing system maintenance ( For example: creating users, etc. ) or other necessary situations Log in to avoid security issues with your system.

  • System user (pseudo user) —— is Linux Users necessary for the system to work properly. It is mainly established to meet the requirements of the corresponding system process for the owner of the file, for example: bin , daemon , adm , lp and other users. System users cannot be used to log in.

  • Ordinary users—— is created to allow users to use Linux system resources. Our Most 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. These groups are the basic groups.

  • 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 user 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 the user account of the system. Since all users have access to passwd has read permission, so only the user account is defined in this file, and the password is not saved.

What are the types of linux user groups?

# Each line defines a user account information, each line consists of 7 Composed of fields, use between fields “:” separated, the format is as follows:

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 the password was previously saved in encrypted format, now the password is saved in /etc/shadow In the file, here is just the password occupying characters “x” or “*” . If it is “x” , indicating that the password has been 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:

    Super user’s 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.

  • Main directory: similar Windows ’s personal directory, usually /home/username ,here username is the user name, user Execute “cd The current directory will be switched to the personal home directory when executing the command.

  • Shell : Define the activated after user login Shell , the default is Bash Shell

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

What are the types of linux user groups?

# Each row defines a user information, and each field in the row is marked with “:” Separate , The format is as follows:

Login name : Encrypted password : Last modification time : Minimum time interval : Maximum time interval : Warning time : Inactivity time : Expiration time : Logo

The 9 fields in each line of the/etc/shadow file have the meanings of fields

  • Login name: Login name

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

  • Last modified time: the date of the last password change, With distance 1970 Year 1 moon 1 The number of days represents

  • Minimum time interval: how many days the password cannot be modified. The default value is 0, means no restrictions
  • Maximum time interval: The number of days after which the password must be changed. The default value is 99999, Indicates no restriction

  • Warning time: How many days in advance to warn the user that the password will expire, The default value is 7 sky ,0 means no warning
  • Inactivity time: How many days after the password expires to disable this user

  • Expiration time: Password expiration date, With distance 1970 Year 1 moon 1 The number of days in a day is expressed , Default is empty , means permanently available Flag: reserved for future development

View the last time the user modified the root password Date

What are the types of linux user groups?

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

Every group in the system, in /etc/group There is a row of records in the file, and any user can read the user group account information configuration file.

What are the types of linux user groups?

Field description

  • Groupname: Group Name

  • Passwd: The encrypted password of the group

  • GID: It is the system that distinguishes different Group ID ,exist /etc/passwd in the domain GID The field uses this number to specify the user’s basic group

  • Userlist: Use " Separate user names, the listed members have this group as an additional group.

Assignment:

1. Create the user lockuser, and specify the home directory as /home/lock, and then lock it This 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 the 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 the acl user for the file to testuser1 and the permissions to rwx, set the acl mask for the file: permissions to 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, set sgid for the file (two ways) One way g s and nnnn) way
7. Set sbit, set sbit for the directory (two ways o t and nnnn) way

What are the types of linux user groups?

1What are the types of linux user groups?

Linux Adding Users to User Groups

Through several examples using the Linux command line, I will show you step by step how to add users to user groups on Linux, 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 subsidiary groups (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 affiliated groups: family and friends)

Set a new primary group

Maybe you want to set the primary group to family## when adding a tom user # (Instead of the tom user group created by default), the affiliated group is friends, you can use this command:

useradd -g family -G friends tom

Use the

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

man useradd

11-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. The

-G option can specify multiple user groups, separated by commas between each user group. For example: -G group1,group2,group3.

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

usermod -g family tom

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

man usermod

1What are the types of linux user groups?

相关推荐:《Linux视频教程

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
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
什么是linux设备节点什么是linux设备节点Apr 18, 2022 pm 08:10 PM

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

Linux中open和fopen的区别有哪些Linux中open和fopen的区别有哪些Apr 29, 2022 pm 06:57 PM

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

linux中什么叫端口映射linux中什么叫端口映射May 09, 2022 pm 01:49 PM

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

什么是linux交叉编译什么是linux交叉编译Apr 29, 2022 pm 06:47 PM

在linux中,交叉编译是指在一个平台上生成另一个平台上的可执行代码,即编译源代码的平台和执行源代码编译后程序的平台是两个不同的平台。使用交叉编译的原因:1、目标系统没有能力在其上进行本地编译;2、有能力进行源代码编译的平台与目标平台不同。

linux中eof是什么linux中eof是什么May 07, 2022 pm 04:26 PM

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

linux怎么判断pcre是否安装linux怎么判断pcre是否安装May 09, 2022 pm 04:14 PM

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux怎么查询mac地址linux怎么查询mac地址Apr 24, 2022 pm 08:01 PM

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

linux中rpc是什么意思linux中rpc是什么意思May 07, 2022 pm 04:48 PM

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools