How to Create User in linux
Step 1: User Management
To add user in linux use the useradd command in shell, In linux the first 500 users are reserved as system users and rest of them are used for other users:
root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin redis:x:494:495:Redis Server:/var/lib/redis:/sbin/nologin vmail:x:5000:5000::/home/vmail:/bin/bash vpostfix:x:5001:5001::/home/vpostfix:/sbin/nologin john:x:5002:5002::/home/john:/bin/bash test:x:5003:5003::/home/test:/bin/bash staging:x:5004:5004::/bathak/staging:/bin/bash
Step 2: Create User
# useradd testuser # passwd testuser Changing password for user testuser. New password: Retype new password: passwd: all authentication tokens updated successfully.
Step 3: Check User Existance
To check the user ID, group, ownership, use the id command:
# id testuser uid=1001(testuser) gid=1001(testuser) groups=1001(testuser)
Note: By default one group is must for every user
Step 4: Change User Group
In order to change the user group use usermod command:
# usermod -G wheel testuser
Note: There is the difference between -g and -G in usermod command. -g is used as primary group and -G is used as secondary group, by default linux use -g while creating new user.
Following are some important files where all details are provided:
/etc/passwd – all users detail
/etc/shadow – all users encrypted passwords
/etc/group – all groups detail
Leave a Reply
Want to join the discussion?Feel free to contribute!