To add a user that is separate from root.
Use this command to add the user homersimpson:
Add user with home directory
useradd -g users -u 1001 -d /home/homersimpson -s /bin/bash -m homersimpson
- The option -g add the user to group users
- The option -u set the UID (take care if you'll add more than one user).
- Check current UIDs with:
awk -F: '{if ($3 >= 1000) { print $0 } }' /etc/passwd
- Check current UIDs with:
- The option -d defines the home folder
- The option -s setup the default bash
- The option -m to creates the home directory.
Add user without home directory
useradd -M homersimpson
- The option -M for no user home directory
Set a password for the new user with the passwd command:
passwd homersimpson