How to add a user account in Linux


Use the useradd command to add a user as shown below.

useradd -c "Some comment" -d /home/fred -m -g 100 -G admin -u 1025 -s /bin/bash fred

This command does the following.

Creates a user account for the user fred with the following options.
-c adds a comment "Some comment",
-d specifies the home directory /home/fred,
-m creates the home directory,
-g specifies the primary group with GID 100,
-G specifies the secondary group admin,
-u specifies the user ID (UID) 1025,
-s specifies the shell /bin/bash,
fred is the username.