UNIX Create User Account

How do I create a user account under UNIX operating system and assign a password to user account so that he / she can login into server or UNIX workstation?

You need to user the useradd command under UNIX operating systems to create user account and password command to set a password for the same. You need to login as root user to add users. Usually, /etc/passwd, /etc/group and /etc/shadow or /etc/master.passwd files are required for user account management.

Example: Add A User Called Tom Under UNIX

Create / add a user called tom with home directory, enter:
# useradd -m tom

Setup A Password For Tom

Type the following command:
# passwd tom
Make sure password must be 8 character long and include special characters and digits for security.

How Do I Add User Jerry To A Secondary Group Called Sales?

Type the following command:
# useradd -G sales -m jerry
# passwd jerry

How Do I Add /bin/ksh as A Shell While Creating A User Account?

Use the following syntax:

useradd -m -s /bin/ksh username

How Do I Setup HomeDirectory Path While Creating A User Account?

Use the following syntax:

useradd -m -s /bin/ksh -d /path/to/home/user username

You can pass all those options as follows:
# useradd -d /nas/users/v/vivek -m -s /bin/bash -c "Vivek Gite" vivek
# passwd vivek

Further readings:

See useradd and passwd command man page:
man useradd
man passwd


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Nocare Munemo Apr 11, 2011 @ 10:18

    thanks for this opportunity to air my views. May you please link me to other unix users who also use cs3 accounting package.

  • Debojyoti Roy Sep 4, 2011 @ 13:11

    How to extend a user validity for unlimited .

    Thanks
    Debojyoti

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum