Добавление пользователя и группы в Linux

Добавление пользователя

sudo useradd -m your_new_user_name

Возможные опции у команды (выписал самое важное из помощи к команде):

  -d, --home-dir HOME_DIR        home directory of the new account
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -g, --gid GROUP                         name or ID of the primary group of the new account
  -G, --groups GROUPS               list of supplementary groups of the new account
  -m, --create-home                    create the user's home directory
  -M, --no-create-home              do not create the user's home directory
  -N, --no-user-group                 do not create a group with the same name as the user
  -r, --system                                create a system account
  -s, --shell SHELL                        login shell of the new account
  -u, --uid UID                              user ID of the new account
  -U, --user-group                       create a group with the same name as the user

Как просмотреть список групп у пользователя

groups
id

Как добавить новую группу

sudo groupadd your_new_group_name

Как добавить пользователя в группу

sudo usermod -aG group_name user_name

Как добавить пользователя в несколько групп

sudo usermod -aG group_name_1,group_name_2,group_name_3 user_name

Как изменить основную группу у пользователя

sudo usermod -g group_name user_name