Linux
  1. Oracle Linux 8

This article will explain and share how to add and remove user account with useradd(add) and userdel (remove) from the command-line on linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7 server.1. C, –comment COMMENT Add a value, such as a full name, to the GECOS field.-g, –gid GROUP Specify the primary group for the user account.-G, –groups GROUPS Specify a list if supplementary groups for the user account.-a, –append Used with the -G option to append the user to the supplemental groups mentioned without removing the user from other groups.-d, –home HOMEDIR Specify a new home directory to a new location. Must be used with the -d option.-m, –move-home Move a user home directory to a new location. Must be used with the -d option.-s, –shell SHELL Specify a new login shell for the user account. L, –lock Lock a user account.-U, –unlock Unlock a user account.2.

Oracle Linux 8

Deleting a User from an Linux System.a) Get userdel manual: # man userdel userdel - delete a user account and related filesb) userdel username removes the user from /etc/passwd, but leaves the home directory intact by default. Proper command to remove the user’s account, user’s home directory and mail spool as part of the deletion process: # userdel -remove ehowstuffor # userdel -r ehowstuffWarning: When a user is removed with userdel without the -r option specified, the system will have files that are owned by an unassigned user ID number. This can also happen when files created by a deleted user exist outside their home directory. This situation can lead to information leakage and other security issues.