• 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

Setting Base Directory for New User Accounts in Linux

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

The useradd command in Linux is used to create new user accounts. One of the options available with this command is -b, --base-dir BASE_DIR. This option allows you to specify a base directory where new user home directories will be created.

Here are some examples demonstrating the usage of useradd with the -b option:

Example 1: Creating a user with a specified base directory:

    useradd -b /home/customusers johndoe
    

This command creates a new user account named johndoe with the home directory located at /home/customusers/johndoe.

To verify: Use grep johndoe /etc/passwd to check if the user johndoe exists and see the home directory specified.

Example 2: Specifying a different base directory:

    useradd --base-dir /data/users janedoe
    

Here, the command creates a user janedoe with the home directory set to /data/users/janedoe.

To verify: Check with grep janedoe /etc/passwd and confirm the specified home directory.

Example 3: Using a relative path for the base directory:

    useradd -b users newuser
    

This command creates newuser with the home directory set to /home/users/newuser, assuming /home is the default base directory.

To verify: Verify with grep newuser /etc/passwd to see the home directory path.

Example 4: Creating a user with an absolute path:

    useradd --base-dir /mnt/storage/files userservice
    

This will create a user userservice with the home directory /mnt/storage/files/userservice.

To verify: Check the output of grep userservice /etc/passwd for the specified home directory.

Example 5: Using a different directory structure:

    useradd -b /srv/clients/client1/employees employee1
    

Here, the user employee1 will have a home directory located at /srv/clients/client1/employees/employee1.

To verify: Ensure the entry for employee1 is present in /etc/passwd with the expected home directory.

Example 6: Creating a user with a customized directory:

    useradd --base-dir /var/custom/home customuser
    

This command creates customuser with the home directory /var/custom/home/customuser.

To verify: Check grep customuser /etc/passwd to confirm the home directory path.

Example 7: Using a network share as the base directory:

    useradd -b /mnt/nfs/users nfsuser
    

Creates a user nfsuser with the home directory /mnt/nfs/users/nfsuser.

To verify: Verify grep nfsuser /etc/passwd for the specified home directory path.

Example 8: Creating a user with a nested structure:

    useradd --base-dir /home/domain1/users/client1 clientuser
    

This command sets up clientuser with the home directory /home/domain1/users/client1/clientuser.

To verify: Check grep clientuser /etc/passwd for the home directory information.

Example 9: Assigning a user to a specific system directory:

    useradd -b /opt/application/users appuser
    

This creates a user appuser with the home directory /opt/application/users/appuser.

To verify: Use grep appuser /etc/passwd to see the user details and home directory path.

Example 10: Creating a user in a different partition:

    useradd --base-dir /media/storage/users storageuser
    

This command results in storageuser having the home directory /media/storage/users/storageuser.

To verify: Check grep storageuser /etc/passwd to confirm the home directory path.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

How to Exclude Bad Names when Creating User Accounts in Linux

Next Post

Adding Comments to New User Accounts 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

Adding Comments to New User Accounts in Linux

howto

Customizing Home Directory Paths for Users in Linux

howto

How to Clone a Git Repository into a New Directory

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.