Adding or Removing Unix and Linux User Accounts
To add or remove a user from a Unix/Linux box, you can edit the password and group files. However, whenever you make an edit to such an important file, there is always the chance that something will go wrong and you’ll end up rendering an account, or possibly a system, unusable. It’s advisable to always make a backup of an important file before making any edits.
After making entries in the /etc/passwd and / etc/groups files, you’ll have to create the user’s home directory and install any files that are part of your standard distribution, such as shell files.
However, on most systems you won’t have to go through all this trouble. Instead, most versions of Unix or Linux provide a program that can be used to perform all the functions needed to add or remove a user. On FreeBSD Unix, for example, the adduser command can be used. The syntax for thiscommand is as follows:
adduser [-dDv] [-c changetime] [-C class] [-e expiretime] [-g primarygroup]
- [-G gecos] [-h homedirectorybasedir] [-H homedirectory]
- [-m homedirectorymode] [-p passwd] [-P encryptedpasswd] [-s shell]
- [-S skeletondir] [-uid] [username…]
- -v—This is the typical Unix/Linux “verbose” option. It causes the adduser command to output more information about its operations. Good to use if you’re new at this.
- -D—If you use the uppercase “D” character, the adduser command does not actually add a user.
Instead, it sets defaults to use the next time adduser is invoked.
- -C class—This specifies a login class for the user. FreeBSD Unix provides a file called /etc/login .conf that stores class definitions for users. Classes can be used to customize authentication methods and the user environment.
- -e expiretime—This field is not generally used. It is intended to set an expiration time for the password.
- -g primarygroup—This sets the user’s default group value. If you do not include this on the command line, adduser will prompt you for it.
- -G gecos—This is the GECOS comment field. You’ll be prompted for this value if it is not included on the command line. Substitute text after the -G command that you want to appear in the GECOS field.
- -h homedirectorybasedirectory—Use this to specify the home directory for the user. The value of homedirectory is the base directory under which the user’s directory is created using the user- name.
- -H homedirectory—This version of the home directory option lets you specify the complete path of the user’s home directory.
- -m homedirectorymode—Use this to specify the mode for the user’s home directory. The defaultis 0775.
- -p passwd—This option enables you to enter, in clear text, a password for the user account.
- -P encryptedpasswd—This option enables you to enter, in encrypted format, a password for the user account. You must use either - p or - P. If neither is used, you will be prompted for a value.
- -S skeletondir—You can set up a “skeleton” directory to serve as a template to use when creating user home directories. This option enables you to specify the name of the template to use for this user’s home directory and possible subdirectories.
- -u uid—Enter the user’s ID (UID) with this option. FreeBSD starts ordinary users‘ UID at 100 and increments the value. Other flavors of Unix/Linux may use different starting values.
- username … —You can enter one or more user account names separated by spaces.
If you enter the adduser command with no command-line arguments, the command will prompt you for the information it needs (such as a username) to create the new account. You can use the large number of options available with the command to construct your own command to add users. If you need to add a large number of users at a time, or if you use the same command-line options frequently, create script files that can be used to invoke the adduser command for your customized requirements.
By using this command, you not only make the necessary entries into the /etc/passwd and /etc/groups files, but also create the user’s home directory.
The rmuser command can be used to remove a user. Simply follow the command with the username that is to be removed. The - v option is the only other command-line option available with this command.
The addgroup command works similar to the adduser command and helps automate the process of managing entries in the /etc/groups file. The syntax for this command is much simpler because th are fewer fields in the groups file, and no directories or other data structures need to be created. The syntax for this command is as follows:
addgroup [-vd] [-g gid] [-m members] [groupname…]
- -v—Again, this causes more output to be displayed during the execution of the command.Useful when you are first learning to use the system.
- -d—Similar to the adduser -d command, this command is the equivalent of using the rmgroup command that is used to remove a group. For example, addgroup -d groupname will remove that groupname from the / et c / g roups file.
- -g gid—This is used to specify the group ID (GID) for the group you are adding. If you omit this, the next available (unused) group number will be used.
- -m members—Use this to specify the initial members of the group, separating each by a space when more than one member is entered.
Other versions of Unix/Linux have similar programs. For example, Compaq’s True64Unix uses the useradd command. The syntax is similar to that of the adduser command, but a few other options are available. For example, the -x option enables you to further specify options relating to NIS, password expiration times, and so on. Red Hat’s Linux distribution enables you to use a similar useradd command. However, it also offers a more complex tool called linuxconf, which can be used in text mode, and also in a GUI mode using an X Window Systems interface or a Web browser. This tool goes tar beyond simple user configuration tasks, including options for managing groups, file systems, system services, and many other objects.
Check the documentation of your Unix or Linux version to determine the commands and exact syntax for any script files or other utilities that can be used to automate user management.
More Help'n Tips: account, adduser, adduser command, available, class, command, create, create the user, directory, enables, enter, etc, etc groups, etc groups files, example, file, files, gecos, group, groupname, groups, home, home directory, linux, option, option enables, options, passwd, passwd and etc, password, remove, similar, specify, syntax, uid, unix, unix linux, used, used to remove, user, user account, username, users, using, value, versions of unix.
-
Web Hosting by PowWeb - One Plan, One Price (50004) / Internet ...
-
Vitamin k - Vitamin and Dietary Supplements
-
Acronis True Image Complete Backup and Disaster Recovery Solution ...
-
Appliance Doors | Kitchen Essential Blog
-
Indoor Car Cover - Car Parts and Accessories
-
Sheer Mineral make up - Vitamin and Dietary Supplements
-
Foreign Exchange - Funds Investing
-
Nutritional Supplements - Vitamin and Dietary Supplements
-
Weight Control - Natural Herbal Beauty
-
Marginal Zinc Deficiency - Vitamin and Dietary Supplements
- April 18th

Leave a Reply