• 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

Specifying Login Shells for User Accounts Command

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

The useradd command in Linux is used to create new user accounts. One of its options, -P or --prefix PREFIX_DIR, allows setting a prefix directory where user home directories will be created. This is particularly useful when you want to organize user home directories under a specific directory structure.

Here are several examples demonstrating the usage of -P option with useradd:

Example 1: Setting the prefix directory to /home/users:

            useradd -P /home/users john
        

This command creates a new user john and sets their home directory to /home/users/john.

Example 2: Using an existing directory path:

            useradd -P /srv/users alice
        

This command creates a user alice with the home directory at /srv/users/alice.

Example 3: Specifying a relative path:

            useradd -P relative/path bob
        

Here, the command creates a user bob with the home directory at relative/path/bob.

Example 4: Using an environment variable:

            useradd -P $HOME/users charlie
        

This command creates a user charlie with the home directory at $HOME/users/charlie.

Example 5: Combining options with user creation:

            useradd -m -P /var/lib/users dave
        

Here, -m ensures creation of the user’s home directory and -P sets it to /var/lib/users/dave.

Verification: To verify if the user creation with the specified prefix directory was successful, you can check the existence of the user’s home directory using:

            ls -ld /path/to/prefix/directory/username
        

Replace /path/to/prefix/directory/username with the actual path where the user’s home directory should have been created.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Setting Prefix Directories for Useradd Command

Next Post

Assigning User IDs (UIDs) for User Accounts Command

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

Assigning User IDs (UIDs) for User Accounts Command

howto

Creating User Groups Automatically with Useradd Command

howto

Using SEUSER for SELinux User Mapping 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

    Dumping BLOBs in Hexadecimal Format with mysqldump

    16 shares
    Share 6 Tweet 4
  • How to Exclude Bad Names when Creating User Accounts in Linux

    14 shares
    Share 6 Tweet 4
  • Suppressing CREATE DATABASE Statements in mysqldump

    11 shares
    Share 4 Tweet 3
  • Managing Kubernetes Certificates with kubectl certificate

    20 shares
    Share 8 Tweet 5
  • Using BTRFS Subvolume for User Home Directory in Linux

    24 shares
    Share 10 Tweet 6
  • Running a Kubernetes API Proxy with kubectl proxy

    14 shares
    Share 6 Tweet 4
  • Setting Character Set in mysqldump Output

    12 shares
    Share 5 Tweet 3
  • Searching Git Repositories with Grep

    12 shares
    Share 5 Tweet 3
  • Running Docker Images on Kubernetes with kubectl run

    13 shares
    Share 5 Tweet 3
  • Disabling Keys in mysqldump Output

    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.