• 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

Assigning User IDs (UIDs) for User Accounts Command

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

The useradd command in Unix-like operating systems is used to create new user accounts. One of the options available with this command is -u or --uid, which allows specifying the User ID (UID) for the new user. The UID is a unique numeric identifier assigned to each user on the system.

Here are some examples of how to use the useradd command with the -u option:

Example 1: Creating a user with a specific UID.

    useradd -u 2001 johndoe
    

This command creates a new user account named johndoe with the UID set to 2001.

Example 2: Creating a user with a UID outside the usual range.

    useradd -u 50000 janedoe
    

In this case, the command creates a user account named janedoe with a UID of 50000. This can be useful when managing large numbers of users on a system.

Example 3: Specifying a UID that is already in use.

    useradd -u 1000 bobsmith
    

If the UID 1000 is already assigned to another user, this command will fail and display an error message indicating that the UID is not available.

Example 4: Creating a system user with a specific UID.

    useradd -r -u 3001 appuser
    

Here, the -r option creates a system user, and appuser is created with the UID 3001. System users typically have UIDs in a different range than regular users.

Example 5: Creating a user with a UID from a reserved range.

    useradd -u 0 root2
    

The UID 0 is reserved for the root user. This command attempts to create a user named root2 with UID 0, but it will likely fail because the UID is already assigned to the root user.

To verify whether the useradd command executed successfully, you can check if the user account was created with the specified UID. You can use commands like id or grep in conjunction with /etc/passwd to see if the user and UID exist:

    id johndoe
    
    grep johndoe /etc/passwd
    

These commands will display information about the user johndoe, including the UID assigned. If the user was created successfully with the specified UID, the output will confirm this information.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Specifying Login Shells for User Accounts Command

Next Post

Creating User Groups Automatically with Useradd 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

Creating User Groups Automatically with Useradd Command

howto

Using SEUSER for SELinux User Mapping with Useradd Command

howto

Managing User Accounts with Extra Users Database 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.