Linux Create User Account

Q. How do I create create a new Linux user account ? How do update or modify default Linux new user information? Using the command prompt (shell) tools, how do I add a user to the system? What are command line options for adding a user?

A. To create a new user account under any Linux distribution use command called useradd. The system administrator is responsible for creating account. Login as root user (or use sudo command).

ADVERTISEMENTS

useradd command syntax

useradd [options] {username}

Depending on command line options, the useradd command will update system files (/etc/passwd and /etc/shadow file with password) and may also create the new user’s home directory and copy initial files.

Linux add a new user called rakhi

Type the command as follows:
useradd rakhi
Set a password for rakhi:
passwd rakhi
Without password user account will be in locked status. To unlock the account, you need to use above passwd command. Use passwd command to assign a password and set password aging guidelines.

Set account disable date

You can set date for the account to be disabled in the format YYYY-MM-DD with -e option while creating account itself:
useradd -e {yyyy-mm-dd} {username}
useradd -e 2008-12-31 jerry

Set default password expiry

The -f {days} option set number of days after the password expires until the account is disabled. (If 0 is specified, the account is disabled immediately after the password expires. If -1 is specified, the account is not be disabled after the password expires.)
useradd -f {days} {username}
useradd -e 2009-12-31 -f 30 jerry

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
120 comments… add one
  • sagar Sep 8, 2007 @ 18:37

    i am first time use linux, How can i see all user ??

    • sashi Aug 26, 2011 @ 10:51

      i dont know

      • Tej Feb 1, 2017 @ 10:43

        … Then don’t answer… Duh

    • pR0Ps Aug 27, 2011 @ 17:58

      cat /etc/passwd

    • manju Sep 22, 2011 @ 14:52

      type in root user
      ls /home/

      • Andy Oct 16, 2011 @ 20:59

        That will only work if there is a userfolder created for every user. And thats not necessary the case.

    • Mehul Jan 23, 2012 @ 7:16

      with command who,,,u can see all users

      • theHOFF Aug 26, 2012 @ 20:51

        $ who only shows you the name of the user you are currently logged into the system as. The ‘ cat /etc/passwd’ method shows all users register to the system. You can grep for userid as well which I picked up from a different post. You have to check your /etc/passwd file to see where added user id numbers start. The example i saw started at 500. Mine start 1000.

        $ cat /etc/passwd | egrep ‘[1][0-9][0-9][0-9]’

        • Huskies xD Feb 23, 2014 @ 19:30

          Nice regEx :)

      • Mustufa Jul 8, 2013 @ 8:47

        No only the user who is active or logged In….

      • lan Oct 14, 2013 @ 6:19

        type ‘w’ command.

    • Luca Francesca Nov 6, 2012 @ 12:44

      User and their home

      cat /etc/passwd | awk -F: ‘{print $1,” =>”, $6}

      • John Bryan Feb 12, 2013 @ 1:18

        you don’t need cat.

        awk -F : ‘{print $1}’ /etc/passwd

        • Luca Francesca Feb 12, 2013 @ 14:23

          TIMDOWTDY :)

    • hariprasad Mar 26, 2013 @ 8:46

      cat /etc/passwd
      or
      vim /etc/passwd

    • Mustufa Jul 8, 2013 @ 7:05

      Login with Any user which is Normal user not the Admin or root.
      eg:[localhost@Root]#:
      Root is admin and if anything in place of root will be Local user.
      type:pwd
      It will list the present working directory…
      type cd /home.
      then type ls

      It will list all the users created in Home directory…..

      • NONYMUST Nov 1, 2016 @ 0:37

        You Didn’t read the above:

        Luca Francesca November 6, 2012, 12:44 pm
        User and their home
        cat /etc/passwd | awk -F: {print $1, =>, $6}

        manju September 22, 2011, 2:52 pm
        type in root user
        ls /home/

        Andy October 16, 2011, 8:59 pm
        [POINT! ATTENTION!]
        That will only work if there is a userfolder created for every user. And thats not necessary the case.

    • HAHA May 20, 2015 @ 8:28

      Haha you guys are saps

  • T-4 Jun 26, 2008 @ 22:51

    Sagar: cat /etc/passwd

    • Fuji May 10, 2010 @ 20:35

      cat /etc/passwd | cut -d”:” -f1

      • Sumit chadha Jun 8, 2011 @ 14:54

        @Fuji : hi , cat /etc/passwd | cut -d”:” -f1 , what is the meaning of this command.Pleaswe tell ASAP.

        • BH.Ram Naidu Jun 12, 2011 @ 18:19

          hi,
          cut -d ” ” -f1 means d is delimiter .In this command delimiter is colon(:) .field1.If the file content is like this ramnaidu7:500:501:Bh.Ram .
          After issuing above command o/p is ramnaidu7 since colon(:) is the delimiter and that is considered as field1(f1)

          • H4CKN3T Aug 3, 2011 @ 10:12

            A better command to pull users would be:

            cat /etc/passwd | grep home | cut -d”:” -f1

          • T Sep 4, 2011 @ 16:25

            I think the folliwng is important. You want one character after the -d, that being the separator between columns.

            [root@localhost ~]# cat /etc/passwd | cut -d”:” -f1
            cut: the delimiter must be a single character
            Try `cut –help’ for more information.
            [root@localhost ~]# cat /etc/passwd | cut -d: -f1
            root
            bin
            daemon
            adm
            lp
            sync

        • raj Apr 30, 2012 @ 7:58

          It display the passwd file in /etc/ and after cut command using -d-delimiter
          where u specify field1 it will shows..

  • Angel Jul 17, 2008 @ 2:10

    How to create a mail account in linux?

    • nuon saratt Aug 11, 2010 @ 8:45

      i can not create mail on linux. can you show me some step of mail?

    • Biplab Mar 6, 2011 @ 13:00

      How to create a mail account in linux?

  • zichzach Feb 23, 2009 @ 17:24

    Thanks this was helpful.

  • Rajeev Apr 30, 2009 @ 8:16

    To view all the users the command is :who

    • sikandar Jan 11, 2011 @ 14:04

      who shows only the single user not all the user

  • William Simbota May 29, 2009 @ 15:16

    thanks alot. It looks simple and I will continue learning

  • mehdi May 31, 2009 @ 9:27

    hi
    i cant create password for my user
    errore: dab password: it is based on a directory word.

  • Vishal Jun 2, 2009 @ 5:06

    It was a really simple & useful tutorial.
    @Mehdi: Try something difficult;t as your password. Linux is intelligent enough to disallow simple dictionary word as password.
    Say for example you can try: awk007

    • Amit Dec 19, 2010 @ 15:03

      login with root account and then change password.

  • satyn Jun 16, 2009 @ 7:37

    i just laod ubuntu and there is no option for PW during the installation now somw want to access my machine through SSH and asking for root PW how can i create the pw for root as well as other account and pw , please guide me ???

    • Andy Oct 16, 2011 @ 21:01

      Why would give somebody root access to your machine?
      Try the following

      sudo -i
      Enter your user password
      Then when logged in as root type
      passwd
      to set a password for the root user.
      But i don’t recommend doing this, especially because you seem not to be too fond of linux….

  • faizal k s Aug 4, 2009 @ 2:31

    exellent

  • Jim Dabbour Aug 5, 2009 @ 17:36

    How do I list user passwords?

    • wkpop93 May 9, 2011 @ 14:24

      If I am not wrong you cannot list user password.

  • Alireza Aug 18, 2009 @ 13:16

    I deleted my user account in fedora 11 by mistake and now I cannot enter to linux.
    What should I do?
    There are no more user accounts in the system.
    Alireza

    • nyx Feb 6, 2011 @ 6:05

      Boot into single user mode and create a new account?

  • Alireza Aug 18, 2009 @ 13:19

    How can I play mp3 files in linux fedora 11.
    The players in this system don’t know the mp3 files.
    Alireza

    • Anonymous Jun 11, 2010 @ 0:54

      Use VLC media player

    • Amit Dec 19, 2010 @ 15:05

      use mplayer..

  • Gal Agay Sep 5, 2009 @ 11:27

    Hello,

    Is it possible to create a new user by edit the /etc/passwd file ?
    when i try to add a new line with a new user name, user ID , user comment, home directory
    it doesn’t work.
    What am i missing ?

    Thank you all,

    Gal

    • wkpop93 May 9, 2011 @ 14:26

      No, you cannot create a new user by editing the /etc/passwd. Instead you should either use a GUI to help you or use ‘useradd -p

  • shreya Oct 6, 2009 @ 15:31

    how can i add a user without using useradd command in linux?

    • Mustufa Jul 8, 2013 @ 7:07

      Through graphic mode you can add,like in windows.
      like as User friendly screen will be pulled up and you can create within the screen only…

  • wolful Oct 18, 2009 @ 14:03

    I have the user linux:/home/wolful

    how to create linux:/home/admin ,
    or how to rename user “wolful” in “admin” without the reinstallation of the linux(suse) ??

    • Amit Dec 19, 2010 @ 15:06

      use usermod command

    • Mustufa Jul 8, 2013 @ 7:10

      For user admin there are four commands mainly..

      1)useradd
      2)usermod
      3)userdel
      4)passwd

      So try the options for usermod as it is used to change username which is currently active in the Linux OS
      syntax
      usermod
      Try to find it from Internet and it will surely help…u

  • anil chauhan Oct 27, 2009 @ 7:52

    linux command sumit my ide

  • Manoj Prajapati Nov 6, 2009 @ 9:19

    how to boot dual booting windos, linux with together press F8 key
    then display windows, after press F8 key then display Linux What Coomand on the linux base

    Manoj Prajapati.
    SIET Gr. Noida

  • Manoj Prajapati Nov 6, 2009 @ 10:39

    how to breack root password in the Linux and how to boot i m forget my root password

    • Amit Dec 19, 2010 @ 15:07

      boot linux in run level 1 and then change password using passwd command.

  • Girish Mahajan Nov 9, 2009 @ 11:53

    Hi Guys,
    Do you want to give the root access to the normal Linux user, even after the root passwd get changed?

    Do follow below commands,
    Login as a root user,
    Let suppose the user is imtestuser
    [root@girish.mahajan ~]# useradd imtestuser
    [root@girish.mahajan ~]# passwd imtestuser
    [root@girish.mahajan ~]# visudo
    #One file get opened,
    # add the below line to the file
    imtestuser ALL=(ALL) NOPASSWD: ALL
    #save the file.
    [root@girish.mahajan ~]# su imtestuser
    [ imtestuser@girish.mahajan ~]#
    [ imtestuser@girish.mahajan ~]#
    [ imtestuser@girish.mahajan ~]#
    [ imtestuser@girish.mahajan ~]# sudo su –
    [ root@girish.mahajan ~]#

    # Now even after changing the passwd , ur imtestuser get authenticated without asking for passwd, and even it get changed…


    Girish Mahajan

  • Girish Mahajan Nov 9, 2009 @ 12:00

    Continuing with above statements…
    Smarter person can do like ,

    [root@girish.mahajan ~]# adduser imtestuser –home /var/.imnotatheft/imtestuser
    [root@girish.mahajan ~]# passwd imtestuser
    [root@girish.mahajan ~]# visudo
    #One file get opened,
    # add the below line to the file
    imtestuser ALL=(ALL) NOPASSWD: ALL
    #save the file.
    [root@girish.mahajan ~]# su imtestuser
    [ imtestuser@girish.mahajan ~]# sudo su –
    [ root@girish.mahajan ~]#

    # Now even after changing the passwd , ur imtestuser get authenticated without asking for passwd, and even it get changed…


    Now , guys , by follwing these steps , u are creating let suppose a hidden user, having a grant to logged in to as a root user without passwd and all.

    Regards,
    Girya ! :)

    • Nilesh May 31, 2011 @ 12:16

      Can I create user without root login ?

      • Mustufa Jul 8, 2013 @ 7:14

        No you cannot create user without root Login,as Root is the Admin and only administrator has a rights to manage and create…

        root is the superuser in the Linux OS.
        If u try creating user with local user login
        EG:[localhost@root]#->This is the root user present
        If i create user
        useradd a
        passwd a
        if you type or change user :su – 2
        [localhost@a]$
        Type useradd b
        It wont work and will show you that u dont have superuser permission for it..

  • nadeem Dec 7, 2009 @ 9:57

    plz tell me uesr account passwd administrative sulotion

  • Celine flores Jan 4, 2010 @ 0:47

    How to create user account in linux?

    • Mustufa Jul 8, 2013 @ 7:16

      Command for creation is
      useradd

  • Tomer Jan 26, 2010 @ 23:58

    Hey,
    there is also this option:

    adduser tomer -p Liux12345

    if you want to automate a scenario in which you need to define a user on a Linux machine programatically, using the above command will save you the hassle of getting prompts from the machine when defining a new user.

    cheers!

  • Justin Mar 10, 2010 @ 20:07

    Hey,

    I was wondering, in linux mint can you use internet explorer 7 still? And also, how do you change operating systems, like I have Windows Vista now, I dont want to get rid of it. I want to get a different operating system though, How could I change back and forth if I didnt like it?

  • Akatchuki 76 Mar 25, 2010 @ 13:21

    Hello Everybody!!!
    can anyone lead me where can I find a source code for Linux?
    my thanx in advance

    • Fuji May 10, 2010 @ 20:38

      goto http://www.kernel.org download the kernel file . it will be a compressed file . just uncompress it thatz all . it contain’s all source code of the linux kernel

  • sarevesh chaurasia (moon up) Mar 27, 2010 @ 17:14

    what is the use of passwd -r command in solaris 10
    and what is the use of useradd -k command in soalris 10

  • booboof@t May 26, 2010 @ 8:04

    I want to modify both sides of the @.

    root@userland:~#

    usermod -l booboof root
    now,
    booboof@userland:~#

    What changes userland?
    Would like booboof@t:~#

    • sam Aug 2, 2011 @ 16:39

      $hostname t
      (run as root)
      reboot.

  • idiots Jun 24, 2010 @ 2:19

    Good article, every comment above this one though sounds like a bunch of script kiddies begging for haxx00rz lol!

  • vikas Sep 9, 2010 @ 5:32

    how to create user in linux without using useradd command………..???????/
    plz reply me early as possible……………….thanx…………….

    • 🐧 nixCraft Sep 9, 2010 @ 6:41

      You need to use Perl or shell script and edit /etc/passwd and /etc/shadow.

  • Pankaj Sep 21, 2010 @ 3:36

    Hey..

    I have a linux server with 5 dedicate IPs on it.
    I have created 5 users on the server and want to restrict each users with 1 specific ips..
    user1 should only access the server with IP 1
    user2 should only access the server only with IP 2..etc

    awaiting for response

  • Kyaw Kyaw San Nov 13, 2010 @ 8:43

    In Linux command,
    -C, -D,-E
    what do they mean?
    Please!
    Can someone answer to me?
    Thanks….

  • sikandar Jan 11, 2011 @ 13:50

    hey ! i created user along with password, but i forgot password how can i access to the same user without password

    • Mustufa Jul 8, 2013 @ 7:18

      Login as root user.

      modify the /etc/passwd file for the user password being lost…

      save it
      Switch user with su command,and check it will work…

  • perumal.A Jan 27, 2011 @ 11:38

    how to create multiuser in linux?

    • sam Aug 2, 2011 @ 16:50

      is already multiuser by default

      • Mustufa Jul 8, 2013 @ 7:19

        No such command exist where you can create multiple users unlike multiple files in Linux OS.

        It requires advance Shell scripting…

  • Leunamme Jan 28, 2011 @ 19:47

    Hi:
    I create a count with the name of IRAF and the next are: “IRAF Maintenance”, home directory “/iraf/iraf/local”, shell “/bin/tcsh”, and a secure password. ” In the directory it appears like “iraf:x:1001:1001::/home/iraf:/bin/sh”; wath does it means?
    …i’m a beginner, then I can’t find the properties and the user privilegies in the tabs. Where are they? I need it for the installation of IRAF in my UBUNTU 32-bit o.s.

  • Tgwizman Jun 13, 2011 @ 10:45

    I created another user account, but they cannot edit what they need to edit. How can I select a folder and have them be able to edit anything within that folder?

    • sam Aug 2, 2011 @ 16:50

      either make the user/ group of users owner of the directory
      use chown
      or change the permissions of the directory as read write [execute] to all
      sudo chmod 777 -R
      #with absolute path

  • kavsmanikyam Aug 6, 2011 @ 14:48

    how can we crete the new user without using useradd and adduser commands

  • binoj Aug 9, 2011 @ 9:21

    how to insatall SAM in linux

  • Linuxuser Aug 12, 2011 @ 13:35

    This is really helpful. I have a linux virtual machine, and it uses backtrack 5 as an interface. I hope this works. :D

  • Jay Sep 17, 2011 @ 23:32

    Doesn’t work…

    Login as root, go to shell,
    useradd x
    passwd y

    passwd: user y does not exist.

    This tutorial sucks.. typical linux, nothing is ever INTUITIVE

  • friv Sep 22, 2011 @ 6:36

    THanks! This is helpful to add new user and password. How to change password?

    • Andy Oct 16, 2011 @ 21:03

      if you are logged in as that user, use
      passwd
      if you are logged in as root and want to change the password of another user use
      passwd username

  • manju Sep 22, 2011 @ 14:37

    how to create a user without using useradd cammand…

    • Andy Oct 16, 2011 @ 21:03

      Just use it…. or use a gui application, but i don’t see why you’d need that.

  • Dado Dec 23, 2011 @ 20:58

    Hello guys,
    I have a vps that I must share with my developer and assistants, how can i prevent file download from server and allow just uploads?
    or how can i protect my files in vps from being downloaded ?
    what I must do?
    Thanks

  • suman Feb 20, 2012 @ 13:21

    i have some questions..Please answer it…
    1.How to know the pirticular user password is locked.?
    2.If the pirticular user forgets the password what will you do.?

    • Mustufa Jul 8, 2013 @ 8:36

      1)If the User is not able to login though after entering password correctly,it means the user accct is locked.
      The only way to unlock is using the usermod command with the Arguments and options as mentioned per the Syntx..

      You can download or can know from google.com.
      2)if a user can forget the password ,Root user can go and reset it,else the user can also change the passwd but then he has to enter password with password complexity.ie. number,symbol and text…
      Root can changed without complexity..
      Choice is yours,Any issue kindly email me,will help you..

  • deepak Mar 24, 2012 @ 18:32

    When I type the command useradd it gives the following details please provide the solution
    deepak@deepak ~/Desktop $ useradd ram
    Command ‘useradd’ is available in ‘/usr/sbin/useradd’
    The command could not be located because ‘/usr/sbin’ is not included in the PATH environment variable.
    This is most likely caused by the lack of administrative priviledges associated with your user account.
    useradd: command not found

  • eshwar Apr 13, 2012 @ 7:38

    Iam fresher for linux.plz help me with ur guidence.

    • Mustufa Jul 8, 2013 @ 7:20

      What you want to know .email me the brief description….plzzzz

  • junel Apr 19, 2012 @ 18:41

    how do i open an account using a linux coomad?

    • Mustufa Jul 8, 2013 @ 7:21

      Use Useradd command to create a user or an User acct…
      EG:useradd xyz
      passwd xyz

  • tplink May 23, 2012 @ 8:57

    Thank you. This tutorial is easy and helpful

  • devi yadav Aug 3, 2012 @ 19:37

    hey, i want to install linux in my system but i am having windows-7.i want to operate linux from cd or from usb.which way would be better.please tell me.

    • Mustufa Jul 8, 2013 @ 8:27

      You can go and install after creating a partition so as to make Two different OS.
      You should have min of 4 GB Ram and min of 512 HDD…
      But it will boot Linux first as it will be installed after preinstalled windows..
      So you can do this way by reading the docs from google ,i just provided you the idea..

      My opinion is to installed Linux virtually by the means of VMWARE workstation as it wont occupy space on ur physical HDD.
      I have installed the same as mentioned Virtualy.

  • prabha Aug 13, 2012 @ 5:47

    how can i view the details of all the user…
    and how can view the user pwd..

    • Mustufa Jul 8, 2013 @ 8:29

      you can view the complete user details under File:/etc/passwd
      user password is stored under /etc/shadow.

  • velvizhi Aug 13, 2012 @ 8:19

    how to execute write and news commands in linux (SuSE) communication commands. and also how to create a user in linux. how to install the printer also

  • chnmay4 Oct 19, 2012 @ 5:28

    Hi ,
    I am a newbie to Linux.
    I want to know all the commands as well as their effects which will help me to manage a server. just like adding users,adding groups assigning them disk spaces and other things.

    Please help me out and if possible share with me some useful links .

    Thanks in Advance.

  • Amit Jan 3, 2013 @ 3:36

    how can u add a user without useradd,adduser,passwd command
    and yes I cannot use the graphical interface too..

  • Sarmins Feb 13, 2013 @ 9:59

    I need to know user group role and job assigning, How?

  • prabhat Feb 28, 2013 @ 19:54

    Hi everyone, i am trying to add a user in ” /home/ ” but every time i get this error

    command ‘useradd’ is available in ‘/usr/sbin/useradd’
    the command could not be located because ‘/usr/sbin’ is not included in the PATH environment variable.
    This is most likely caused by the lack of administrative privileges associated with your user account.
    useradd: command not found.

    what should i do..??
    i use the syntax : “useradd desd”.

    I also tried sudo before the command but it wont accept the password ….

    • Mustufa Jul 8, 2013 @ 8:31

      Hi..

      you should try creating user in superuser mode..as Root is the ony user having sufficient priviledges for creation and deletion of users….

      You must be creating under local user login..
      try creating under Root user,it will work…

  • sheriff Apr 25, 2013 @ 14:15

    how to create graphical user inferfaces login to my users for example ssh. ssh only text based login.but i need to configure my users graphical user inferface login. please solve this question?

    • priyanka Aug 7, 2013 @ 6:43

      it is very useful…….!

    • Sameer Oct 16, 2013 @ 7:49

      If you want a simple solution, you can use bash for this (This will vary for users of unity/gnome/kde). Use ‘zenity’ (see $zenity –help)

      $ export credentials=$(zenity –password –username)
      $ echo $credentials

  • anik Feb 22, 2014 @ 5:56

    how to creat user with user id??

  • lakhan Mar 6, 2014 @ 16:01

    main user is lakhan eg, /home/lakhan
    how i create other users
    and how i delete user

  • Embony Mar 30, 2014 @ 12:41

    To see all the user accounts on your system;
    – First switch to a root user by issuing the command # su –
    – A password for root is required to switch.
    – Once successfully switched, use the command # cat /etc/passwd
    – All the user accounts will be listed including parameters except their password.

  • basavaraj May 6, 2014 @ 3:07

    Hi frnrds,
    It is very useful, thanks to all, am going to RHCE exam prepared nowdays, u have any guide send my mail id- shrirambasava@gmail.com
    Thanks to all

  • jagan May 24, 2014 @ 11:20

    Dear sir/madam how to use useradd & groupadd give with examples
    and syntax ..

  • Taylor Jun 26, 2014 @ 20:28

    Yes! Finally something about intend.

  • rajesh Oct 6, 2015 @ 5:02

    how can create local account in linux machine

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.