• 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

Managing Default User Creation Settings in Linux

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

The useradd command in Linux is used to create new user accounts. With the -D or --defaults option, you can manage the default settings used when creating new users.

Example 1: Setting default options for user creation:
useradd -D -m -s /bin/bash

Explanation: This command sets the default behavior for user creation to create a home directory (-m) and set the default shell to /bin/bash (-s /bin/bash).

To verify: Check the output of grep "^USERADD" /etc/default/useradd to see the default options.

Example 2: Modifying default options for user creation:
useradd -D -s /usr/sbin/nologin

Explanation: This command changes the default shell for new users to /usr/sbin/nologin, which prevents them from logging into the system.

To verify: Check the output of grep "^SHELL" /etc/default/useradd to confirm the default shell.

Example 3: Disabling user home directory creation by default:
useradd -D -m

Explanation: This command ensures that user home directories are created by default (-m), which is the default behavior.

To verify: Check the output of grep "^CREATE_HOME" /etc/default/useradd to ensure home directories are being created.

Example 4: Setting default expiration for new user accounts:
useradd -D -e 2025-12-31

Explanation: This command sets the default expiration date for new user accounts to December 31, 2025.

To verify: Check the output of grep "^EXPIRE" /etc/default/useradd to see the default expiration date.

Example 5: Configuring default UID and GID for new users:
useradd -D -u 2000 -g 2000

Explanation: This command sets the default UID and GID for new users to 2000.

To verify: Check the output of grep "^UID_MIN" /etc/login.defs and grep "^GID_MIN" /etc/login.defs to confirm the default UID and GID.

Example 6: Restricting default password aging settings:
useradd -D -f 30 -I 7

Explanation: This command sets the default maximum password age to 30 days and the default minimum password age to 7 days.

To verify: Check the output of grep "^PASS_MAX_DAYS" /etc/login.defs and grep "^PASS_MIN_DAYS" /etc/login.defs to verify the default password aging settings.

Example 7: Setting default group membership for new users:
useradd -D -G developers

Explanation: This command adds new users to the developers group by default.

To verify: Check the output of grep "^GROUPADD" /etc/default/useradd to confirm the default group membership.

Example 8: Configuring default skel directory for new user profiles:
useradd -D -k /etc/skel

Explanation: This command sets the default skeleton directory (/etc/skel) for new user profiles.

To verify: Check the output of grep "^SKEL" /etc/default/useradd to confirm the default skel directory.

Example 9: Specifying default umask settings for new users:
useradd -D -U 0022

Explanation: This command sets the default umask for new users to 0022.

To verify: Check the output of grep "^UMASK" /etc/login.defs to verify the default umask settings.

Example 10: Setting default login classes for new users:
useradd -D -c staff

Explanation: This command assigns new users to the staff login class by default.

To verify: Check the output of grep "^LOGIN_CLASSES" /etc/default/useradd to confirm the default login classes.

Tags: CommandsLinuxLinux Command TutorialLinux Commands
Previous Post

Using BTRFS Subvolume for User Home Directory in Linux

Next Post

Setting Expiry Dates for 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 Expiry Dates for User Accounts in Linux

howto

Configuring Password Inactivity Periods for Users in Linux

howto

Assigning Primary Group for New User Accounts 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.