Alt linux add user to group

Управление пользователями

Вместо bash мы можем установить пользователю другой командный интерпретатор (/bin/bash, /bin/sh, /bin/zsh).

# grep -E 'petr' /etc/passwd petr:x:1001:1001::/home/petr:/bin/sh

adduser

adduser по командам аналогична useradd.

Изменение пользователя

Изменение имени пользователя

Существующему пользователю можно изменить имя, делается это опцией -l. Первым указывается новое имя, вторым — старое.

Изменим имя пользователя petr на petr_admin,

# usermod -l petr_admin petr 
# id petr id: petr: такого пользователя нет # id petr_admin uid=1001(petr_admin) gid=1002(group_1) группы=1002(group_1),10(wheel),1003(group_2) 

Изменение пароля пользователя

Добавление/Изменение отображаемого имени

# usermod -c "Тестировщик" test1 
$ grep -E 'test1' /etc/passwd test1:x:1001:1001:Тестировщик:/home/test1:/bin/bash

Изменение домашнего каталога пользователя

Опция -d меняет каталог, а опция -m переносит в новый каталог все содержимое старого.

# grep -E 'petr' /etc/passwd petr:x:1001:1001:Имя Фамилия:/opt/petr:/bin/bash

Установка даты истечения срока аккаунта

Пользователю можно назначить дату истечения действия аккаунта. Она задается опцией -e ГГГГ-ММ-ДД.

Для работы chage нужно установить пакет shadow-change.

# chage -l petr Последний раз пароль был изменён : мая 29, 2023 Срок действия пароля истекает : никогда Пароль будет деактивирован через : никогда Срок действия учётной записи истекает : дек 31, 2024 Минимальное количество дней между сменой пароля : -1 Максимальное количество дней между сменой пароля : -1 Количество дней с предупреждением перед деактивацией пароля : -1

Просмотреть список пользователей

Только с домашней папкой в /home:

Удаление пользователя

userdel

Изменение командной оболочки пользователя

Чтобы изменить командную оболочку пользователя (например, на /bin/bash, /bin/sh, /bin/zsh), нужно выполнить команду usermod с опцией -s.

Например, изменим пользовательскую оболочку для petr_admin с /bin/bash/ на /bin/sh/.

# usermod -s /bin/sh petr_admin 
# grep -E 'petr_admin' /etc/passwd petr_admin:x:1001:1002:Имя Фамилия:/opt/petr:/bin/sh

Изменение UID и GID пользователя

Для изменения UID пользователя используется опция -u.

# id petr_admin uid=777(petr_admin) gid=1002(group_1) группы=1002(group_1),10(wheel),1003(group_2) 

Для изменения GID пользователя используется опция -g.

# id petr_admin uid=777(petr_admin) gid=777(newgroup) группы=777(newgroup),10(wheel),1003(group_2) 

Таким образом можно управлять пользователями и изменять их по своему усмотрению.

Группы

Просмотреть список групп

Источник

Alt linux add user to group

Even if only one person works on the computer, you should understand some aspects of user management in the Linux system. It is important to create at least one user name (apart from the root user) for routine work.

Every individual user should have his or her own user name. It is very rarely useful for several people to share the same user name. Apart from security aspects, aspects of user management and control are also important, and users should be identified in the system by their names.

Читайте также:  Internal server error apache astra linux

Users in Linux

The system stores the following information about any user:

This name must be unique within the system. Only Latin letters, digits and _ and . (period) symbols can be used in user names.

This ID, abbreviated to UID , is the user’s unique identifier in the system. In fact, the system uses UID’s to identify users, rather than their names.

This ID (abbreviated to GID ) identifies a group to which the user belongs by default. Groups help regulate access of multiple users to various resources. Every user belongs to one or more groups. Users are added to groups by the system administrator.

The user’s encrypted password. To create or change a password, use the passwd command.

Apart from the user’s system name, the system stores the name (first name, last name, etc.) of the “ real ” user. For example, user schmoj may in real life be named Joe Schmo.

This is the name of a directory that opens when a user starts up the system, and where his or her private files are stored. Every user has such a directory and all such directories are gathered in one directory, usually named /home.

This is the command shell launched when the system starts up, for example, /bin/bash or /bin/zsh.

All this information is stored in the file /etc/passwd. Every string of this file has the following format:

user name:encrypted password:UID:GID:full name:home directory:login shell
kiwi:Xv8Q981g71oKK:102:100:Laura Poole:/home/kiwi:/bin/bash

In this example, a user name, �.��. kiwi, is the first record. The next field stores an encrypted password: Xv8Q981g71oKK. Passwords are stored in the system in an encrypted (unreadable) form, with the password itself used as a key. In other words, in order to decrypt a password, you must know it. This encryption type is secure enough.

Some systems use “ shadow passwords ”, with information about the password stored in the file /etc/shadow. This system is a bit safer, since the file /etc/passwd can be read by anyone, while the access rights for the file /etc/shadow are much more strictly limited. Shadow passwords have some additional functions, for example, they have a password expiration option.

The third field, 102, is UID. This number must be unique. The fourth field, 100, is GID, �.��. the user belongs to a group with number 100. Information about groups is stored in the file /etc/group.

The fifth field is the real name of the user, in our case this is Laura Poole. The last two fields are the user’s home directory (/home/kiwi) and login shell (/bin/bash). There is no need for the user name and home directory to coincide, but such organization helps determining the ownership of a directory.

New User Creation

To create a new user, you should follow a number of steps. First, create a record for the user in /etc/passwd. In this file, each user must have a unique name and UID. UID’s of ordinary users must be greater than 100, since smaller UID’s are reserved for system purposes. Besides this, GID (group ID), the user’s real name and some other information should be provided. After that, a home directory is created for the user and access rights are set up in such a way that the user becomes the owner of this directory. Login shell initialization files are placed in this directory. Besides this, configuration files in the entire system are updated (for instance, the spool for users’ incoming mail).

Читайте также:  Fs 1060dn linux drivers

Manual creation of users is not difficult, but when a system with a large number of users operates, you may forget about some details. The easiest way to create new users in this case is by using an interactive program that automatically updates the contents of all the required system files. This program is called useradd or adduser , depending on which software is installed on the computer.

File /etc/default/useradd contains information about the standard initial configuration for all new users. In this file, you can assign values for variables used by the useradd program. Besides, this file specifies the location of configuration files containing default settings. Location of these files is specified by the SKEL variable. Files placed in this directory (such as the file .profile that sets the default mode for the entire system and the files .zshrc or .bashrc) are automatically copied to the home directory of the user that is being created by the useradd command.

User Deletion

To delete a user from the system, use commands userdel or deluser .

If you need to temporarily prohibit a user to enter the system, but you do not want to delete this user’s home directory and other personal settings, you may simply place an asterisk (*) in front of his or her password in the /etc/passwd file. For example, the string for user kiwi modified in this way will look as follows:

kiwi:*Xv8Q981g71oKK:102:100:Laura Poole:/home/kiwi:/bin/bash

By doing this, you have made it impossible for the user kiwi to log into the system.

Setting User Attributes

After you have created a name for the new user, you may need to change some of the attributes assigned to this user, for example, his or her home directory or password. The simplest way to do this is just changing the data in /etc/passwd file. To create a password, use the passwd command. The command

changes user larry‘s password. Only the root user has rights to change any other user’s password, but other users may change their own passwords themselves using the passwd command without any parameters.

User Groups

As stated above, every user belongs to a group or several groups. The only essential characteristic of any group is access rights. Every file does not only have a personal owner, but also a group owner, and a set of access rights which determine how users from this group may access this file. When a new user is created, a group is also created with a name coinciding with the name of that user. It contains only the new user himself or herself.

Читайте также:  Linux and unix system programming handbook

There are several groups defined by the system, for instance, bin, mail, sys. These groups are created to manage access rights to system files, and users should not belong to these groups. For users, special groups are created, for example, users. You may create several groups for users, for example, student, staff, and faculty.

Information about groups is contained in /etc/group file. The format of every string in this file is as follows:

group name:password:GID:other group members
root:*:0: users:*:100:mdw,larry guest:*:200: other:*:250:kiwi

The first group, root, is a special group for the root user. The second group, users, contains regular users. The GID of this group is 100, and it contains users: mdw and larry. Let us remember that in the /etc/passwd file, each user has a group defined for him or her by default. Nevertheless, users may belong to more than one group, and this is done by listing their names in the /etc/group file. The command groups displays a list of groups to which a given user belongs (or has access).

The third group is called guest and is intended for visitors. For all other users, the group other is used. This group contains the user kiwi.

Sometimes the password field is filled in the /etc/group file in order to set a password for group access. This is rarely needed. To prevent users from entering privileged groups (by the newgroup command), enter an asterisk (*) in this field.

To create a new user group, the commands addgroup or groupadd may be used. Usually, it is easiest to enter a new string into the /etc/group file manually, since no other configuration is required. To delete a group, delete the corresponding string from the /etc/group file.

Источник

Alt linux add user to group

Product SiteDocumentation Site

⁠35.2. Объединение пользователей в группы

Пользователи могут быть объединены в группы. Это может быть полезно для более точного распределения полномочий пользователей. Например, члены группы wheel могут получать полномочия администратора на локальной машине, выполнив команду:

Настройка групп производится в модуле ЦУС Группы (пакет alterator-ldap-groups ) из раздела Пользователи . С помощью данного модуля можно:

Веб-интерфейс модуля alterator-ldap-groups

Для выбора источника списка групп, нажмите кнопку Выбор источника и выберите источник:

Выбор источника списка групп

Возможные варианты: текущий способ аутентификации (выбирается в модуле Аутентификация ), файл /etc/group , локальная база LDAP, другой сервер LDAP или Samba ActiveDirectory.

Для создания новой группы необходимо ввести название группы и нажать кнопку Создать , после чего имя отобразится в списке слева.

Источник

Оцените статью
Adblock
detector