SLES: управление пользователями и группами с помощью YaST2

Автор: | 11/04/2013
 

suse_logo2Основной инструмент управления всеми параметрами в SUSE Linux Enterpise EditionYaST2.

Рассмотрим его применение, касающееся пользователей и групп.

Параметры вызова YaST2 из командной строки:

# yast2 [modulename] <command> [options]

Например — вывести краткую справку по модулю users:

# yast2 users help

YaST Configuration Module users
--------------------------------

User configuration module

Basic Syntax:
yast2 users interactive
yast2 users <command> [verbose] [options]
yast2 users help
yast2 users longhelp
yast2 users xmlhelp
yast2 users <command> help

Commands:
add     Add new user
delete  Delete an existing user (home directory is not removed)
edit    Edit an existing user
list    List of available users
show    Show information of selected user

Run 'yast2 users <command> help' for a list of available options.

Или по модулю groups:

# yast2 groups help

YaST Configuration Module groups
---------------------------------

Group configuration module

Basic Syntax:
yast2 groups interactive
yast2 groups <command> [verbose] [options]
yast2 groups help
yast2 groups longhelp
yast2 groups xmlhelp
yast2 groups <command> help

Commands:
add     Add new group
delete  Delete an existing group
edit    Edit an existing group
list    List of available groups
show    Show information of selected group

Run 'yast2 groups <command> help' for a list of available options.

Можно получить более подробную информацию по каждой команде:

# yast2 users add help

YaST Configuration Module users
--------------------------------

Command 'add'
Add new user

Options:
username       [string]  Login name of the user
uid            [string]  UID of the user
cn             [string]  Full name of the user
password       [string]  Password of the user
home           [string]  Home directory of the user
no_home                  Do not create home directory for new user
shell          [string]  Login shell of the user
gid            [string]  GID of user's default group
grouplist      [string]  List of groups of which the user is a member (separated by commas)
type           [string]  Type of the user (local, system, nis, ldap)
ldap_password  [string]  Password for LDAP server
help                     Print the help for this command
verbose                  Show progress information

Теперь, воспользовавшись этими подсказками создадим группу testgroup:

# yast2 groups add groupname="testgroup" verbose
Ready
Initializing
Finishing
Done

Группа создана, но в ней нет пользователей. Добавим пользователя в систему и назначим ему созданную группу, а так же сразу добавим его в существующую группу trusted.

Узнаём GID созданной группы:

# cat /etc/group | grep testgroup | cut -d":" -f 3
1001

Создаём пользователя user1, добавляем его в группу testgroup и задаём пароль password:

# yast2 users add username="user1" password="password" gid="1001" grouplist="trusted" verbose
Ready
Initializing
Finishing
Done

Проверяем:

# ls -l /home/ | grep user1
drwxr-xr-x  8 user1     testgroup  584 Nov  2 11:33 user1
# cat /etc/shadow | grep user1
user1:$2a$05$dIKpQPK2itG3nafC47MuoeOtGoPi4WI8FimoLEliUSBZfCrXk7AhO:16011:0:99999:7:::
# su -l user1
user1@sles:~>

Если потребуется отредактировать пользователя, например изменить пароль — можно воспользоваться стандартной для Linux/FreeBSD утилитой passwd:

# passwd user1
Changing password for user1.
New Password:
Bad password: it is based on a dictionary word
Reenter New Password:
Password changed.

Или опять использовать YaST2:

# yast2 users edit help

YaST Configuration Module users
--------------------------------

Command 'edit'
Edit an existing user

Options:
username       [string]  Login name of the user
uid            [string]  UID of the user
cn             [string]  Full name of the user
password       [string]  Password of the user
home           [string]  Home directory of the user
shell          [string]  Login shell of the user
gid            [string]  GID of user's default group
grouplist      [string]  List of groups of which the user is a member (separated by commas)
new_username   [string]  New login name of the user
new_uid        [string]  New UID of the user
type           [string]  Type of the user (local, system, nis, ldap)
ldap_password  [string]  Password for LDAP server
help                     Print the help for this command
verbose                  Show progress information
# yast2 users edit username="user1" password="newpassword" verbose
Ready
Initializing
Finishing
Done

Так же, можно воспользоваться псевдо-графической оболочкой для YaST2:

# yast2

YaST2 - User Management