The Linux Accountant
To create a new user account with a specific username and home directory:
useradd -m -d /home/newuser -s /bin/bash newuser
To create a new user account with a specific UID and GID:
To create a system user account without a home directory:
To create a new user account with a specific expiration date:
To create a new user account with a specific password:
To create a user with a username that contains characters that are not allowed by default, you can use the --badname option
The following command will create a user with the username joe and the home directory /opt/users/joe
useradd -b /opt/users -d /opt/users/joe -m joe
The following command will create a user with the username joe and the home directory /home/joe, using a BTRFS subvolume for the home directory
The following command will create a user with the username joe and the GECOS field "Joe Schmoe,Developer":
The following command will print the default configuration for useradd:
The following command will create a user with the username joe and an expiration date of June 1, 2024:
The following command will create a user with the username joe and a password inactivity period of 30 days:
The following command will create a system user with the username joe and add entries to the /etc/subuid and /etc/subgid files:
To create a new user with the username "john" and set the primary group to "staff", you can use the following command:
To create a new user with the username "jane" and add her to the "developers" and "users" groups, you can use the following command:
To create a new user with the username "bob" and use the skeleton directory "/etc/skel2" instead of the default "/etc/skel", you can use the following command:
To create a new user with the username "alex" and set the default password expiration time to 30 days instead of the default 90 days, you can use the following command:
To create a new system account with the username "ftp" and the To create a new user with a specific SELinux user, you can use the following command:UID 1001, you can use the following command:
To create a new user with a custom prefix directory, you can use the following command:
To create a new user with the zsh shell, you can use the following command:
To create a new user with a specific user ID, you can use the following command:
To create a new user with a group of the same name, you can use the following command:
To create a new user with a specific SELinux user, you can use the following command:
In conclusion, the "useradd" command is an essential tool for system administrators managing users in a network environment. It enables them to create and manage user accounts efficiently, granting or restricting access to specific system resources based on individual user needs. Additionally, by learning about other related commands like "usermod," "userdel," and "passwd," system administrators can handle critical thinking scenarios for user management and ensure the security and integrity of the network. The ability to effectively manage user accounts is crucial for any system administrator, and mastering these commands can make a significant difference in the smooth functioning of a network environment.