Skip to main content

LPI E - skel default

Take Control of Your User Creation Process with useradd's -k Option

The -k option on the useradd command allows you to specify a different SKEL directory than the default one when creating a new user account. The SKEL directory is the skeleton directory that contains default files and directories that will be copied to the new user's home directory when the user account is created.

By default, the SKEL directory is usually set to /etc/skel/, but if you use the -k option, you can specify a different directory that contains the default files and directories that are appropriate for the new user's job function.

For example, if you have users with different roles, such as developers, designers, and managers, each group may require different default files and directories. By using the -k option with a different SKEL directory for each group, you can create new user accounts with the appropriate default files and directories for their job function.

Scenarios

Scenario:
A company has a specific template for new user accounts that includes specific configurations and files that are required for each user. The system administrator can create a SKEL directory with the required files and configurations, and use the -k option to specify that directory when creating new user accounts.

Snippet example:
$ useradd -k /etc/skel-template/ newuser

Scenario:
A school has different departments (e.g. science, humanities, business) that require different resources and permissions for their users. The system administrator can create separate SKEL directories for each department, and use the -k option to specify the appropriate directory when creating new user accounts for each department.

Snippet example:
$ useradd -k /etc/skel-science/ scienceuser

Scenario:
A web development company has different teams working on different projects, each with their own set of requirements and access privileges. The system administrator can create separate SKEL directories for each project, and use the -k option to specify the appropriate directory when creating new user accounts for each team.

Snippet example:
$ useradd -k /etc/skel-project1/ devteam1


Scenario
You need to create a new user account for a developer who requires access to a specific set of configuration files. You want to use the ~/configs directory as the default template directory for the new user's home directory.

Snippet Example:
sudo useradd -m -k ~/configs -s /bin/bash devuser

This will create a new user account called devuser, with a home directory set to /home/devuser and a login shell set to /bin/bash. The -k ~/configs option specifies that the ~/configs directory should be used as the template directory for the new user's home directory.


Scenario
You need to create a new user account for a customer support representative who needs access to a specific set of scripts and documentation. You want to use the /opt/support directory as the default template directory for the new user's home directory.

$ sudo useradd -m -k /opt/support -s /bin/bash supportuser

This will create a new user account called supportuser, with a home directory set to /home/supportuser and a login shell set to /bin/bash. The -k /opt/support option specifies that the /opt/support directory should be used as the template directory for the new user's home directory.

Scenario
You need to create a new user account for a system administrator who needs access to a specific set of system files and scripts. You want to use the /etc/skel directory as the default template directory for the new user's home directory.

sudo useradd -m -k /etc/skel -s /bin/bash adminuser

This will create a new user account called adminuser, with a home directory set to /home/adminuser and a login shell set to /bin/bash. The -k /etc/skel option specifies that the /etc/skel directory should be used as the template directory for the new user's home directory. This is the default template directory used by most Linux systems.