3.6. Adding a new user as an SELinux-confined user
You can add a new SELinux-confined user to the system right with the command for creating the user account. This example procedure maps the user to the SELinux staff_u user.
Prerequisites
-
The
rootuser is running unconfined, as it does by default in Red Hat Enterprise Linux.
Procedure
Enter the following command to create a new Linux user named
<example_user>and map it to the SELinuxstaff_uuser:# useradd -Z staff_u <example_user>To assign a password to the Linux
<example_user>user:# passwd <example_user> Changing password for user <example_user>. New password: Retype new password: passwd: all authentication tokens updated successfully.- Log out of your current session.
-
Log in as the Linux
<example_user>user. The user’s shell launches with thestaff_ucontext.
Verification
When logged in as the
<example_user>user, check the context of a Linux user:$ id -Z uid=1000(<example_user>) gid=1000(<example_user>) groups=1000(<example_user>) context=staff_u:staff_r:staff_t:s0-s0:c0.c1023