• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Commands

Using Custom Skeleton Directories for User Accounts in Linux

June 21, 2024
in Commands, Linux, Linux Command Tutorial, Linux Commands
A A
0
14
SHARES
131
VIEWS
Share on FacebookShare on Twitter

The useradd command in Linux is used to create a new user account. One of its options, -k or --skel, allows you to specify a custom skeleton directory (SKEL_DIR) to use as a template for creating the new user’s home directory and initial configuration files.

Using custom skeleton directories with useradd is particularly useful when you want to predefine certain configurations or provide specific files to new user accounts automatically. Here are several examples of how you can utilize this feature:

Example 1: Creating a new user with a custom skeleton directory:
sudo useradd -m -k /etc/skel_custom john_doe
This command creates a new user account named john_doe and copies the contents of the /etc/skel_custom directory to the new user’s home directory. To verify, check if /home/john_doe contains files from /etc/skel_custom.

Example 2: Creating a user with a specific default shell and custom skeleton:
sudo useradd -m -s /bin/bash -k /etc/skel_custom2 jane_smith
Here, the command creates a user jane_smith with /bin/bash as the default shell and populates her home directory with files from /etc/skel_custom2.

Example 3: Adding a system user with a custom skeleton directory:
sudo useradd -r -k /etc/skel_service service_user
This example creates a system user service_user (with a UID less than 1000, typically used for system services) and sets up the home directory using files from /etc/skel_service.

Example 4: Creating a user without a home directory but with custom skeleton files:
sudo useradd -r -M -k /etc/skel_no_home app_user
Here, app_user is created as a system user without a home directory (-M), but with custom files from /etc/skel_no_home.

Example 5: Specifying a custom skeleton directory with additional options:
sudo useradd -m -k /etc/skel_custom3 -c "Custom Skeleton Example" tom_jones
This command creates a new user tom_jones with a comment and utilizes /etc/skel_custom3 for the initial home directory structure.

Example 6: Adding a user with a custom skeleton and specifying a different primary group:
sudo useradd -g developers -k /etc/skel_developer bill_gates
This command creates the user bill_gates with the primary group set to developers and uses /etc/skel_developer for initial configuration.

Example 7: Creating a user with custom skeleton files and setting an expiration date:
sudo useradd -m -k /etc/skel_custom4 -e 2025-12-31 amy_wong
The -e option sets an expiration date for the user amy_wong, while /etc/skel_custom4 provides the initial files for her home directory.

Example 8: Creating a new user with a custom skeleton directory and a specific UID:
sudo useradd -m -k /etc/skel_custom5 -u 2001 steve_jobs
This command assigns the UID 2001 to the user steve_jobs and uses /etc/skel_custom5 for the initial setup.

Example 9: Creating a user with a custom skeleton and specifying a different default umask:
sudo useradd -m -k /etc/skel_custom6 -d /home/other_home -o -U other_user
Here, other_user is created with a different home directory path and custom skeleton files from /etc/skel_custom6.

Example 10: Adding a user with a custom skeleton and setting a specific login class:
sudo useradd -m -k /etc/skel_custom7 -l special_login linda_jackson
This command assigns the login class special_login to linda_jackson and uses /etc/skel_custom7 for initial configurations.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Adding Supplementary Groups to User Accounts in Linux

Next Post

Overriding Default Settings with Useradd Key-Value Pairs in Linux

Related You may like!

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024

Find Files by Group Name with -group in find Command

August 21, 2024

Locate Files by Group ID Using -gid in find Command

August 21, 2024

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Use -false to Test Conditional Expressions in find Command

August 21, 2024
Next Post
howto

Overriding Default Settings with Useradd Key-Value Pairs in Linux

howto

Managing User Database Entries with Useradd Command

howto

Creating Home Directories Automatically with Useradd Command

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.