• 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

How to Exclude Bad Names when Creating User Accounts in Linux

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

The useradd command in Linux is used to create new user accounts. One of the options available for this command is --badnames. This option allows administrators to specify a list of names that should be considered “bad” or undesirable when creating user accounts, helping to enforce naming conventions or prevent the use of reserved or inappropriate names.

When using useradd --badnames, you provide a file containing a list of names that should be excluded. Here are a few examples to illustrate its usage:

Example 1: Exclude common system names.

            $ cat badnames.txt
            root
            admin
            nobody
            $ sudo useradd --badnames badnames.txt newuser1
        

Explanation: In this example, we create a file badnames.txt listing common system usernames. The command then attempts to create a new user account newuser1, excluding any names listed in badnames.txt. Verification: To verify if newuser1 was created, use grep newuser1 /etc/passwd.

Example 2: Preventing the use of reserved names.

            $ echo "temp" | sudo tee badnames.txt
            $ sudo useradd --badnames badnames.txt tempuser
        

Explanation: Here, we directly specify a bad name temp using echo and tee commands. The useradd command attempts to create a new user account tempuser, excluding the name temp. Verification: Verify if tempuser was created using grep tempuser /etc/passwd.

Example 3: Using the --badnames option with no file specified.

            $ sudo useradd --badnames baduser1
        

Explanation: In this case, baduser1 is considered a bad name directly specified on the command line. The useradd command will check against its internal list of bad names or naming conventions. Verification: Check if baduser1 exists with grep baduser1 /etc/passwd.

Example 4: Specifying multiple bad names.

            $ cat badnames.txt
            temp
            test
            admin
            $ sudo useradd --badnames badnames.txt testuser
        

Explanation: In this example, we create a file badnames.txt with multiple bad names. The command then tries to create a user account testuser, ensuring that neither test nor admin are used. Verification: Check the creation status of testuser with grep testuser /etc/passwd.

Using the --badnames option with useradd helps maintain system integrity by preventing the creation of accounts with names that could potentially cause conflicts or security issues. By specifying a list of bad names, administrators can enforce naming policies and ensure that user accounts adhere to organizational standards.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Managing User Accounts with Extra Users Database Command

Next Post

Setting Base Directory for 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

Setting Base Directory for New User Accounts in Linux

howto

Adding Comments to New User Accounts in Linux

howto

Customizing Home Directory Paths for Users in Linux

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.