Monday 31 October 2011

To add new user in to the system using text base command

The 'useradd' and 'adduser' command can be use to create new user account in Linux Fedora Core system.  Please note that the 'adduser' command is a sybolic link to 'useradd' command so that these two command actually is the same command that link together.




Creating user account using 'useradd' command:


1. Log in on the system using root account.
2. Open x-terminal and type in:

[root@localhost ~]# useradd -c "Sachin T" sachin
[root@localhost ~]#

Note: The example above use the useradd command to add new user named "Sachin T" with the logon name sachin.

or the simples way:

[root@localhost ~]# useradd christ
[root@localhost ~]#

Note: The command above adding new user account to the system with the login name christ.

3. In order to use these newly crated user account, you need to create password for these user. 

[root@localhost ~]# passwd sachin
Changing password for user sachin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#

[root@localhost ~]# passwd christ
Changing password for user christ.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#

4.  To verify the newly created user account you can use the 'finger' command and try to login using these newly created user account.

The user account for 'william':

[root@localhost ~]# finger sachin
Login: sachin Name: Sachin T
Directory: /home/sachin Shell: /bin/bash
Never logged in.
No mail.
No Plan.
[root@localhost ~]#

The user account for 'christopher':

[root@localhost ~]# finger christ
Login: christ Name: (null)
Directory: /home/christ Shell: /bin/bash
Never logged in.
No mail.
No Plan.
[root@localhost ~]#

Add user with supplementary GROUP.


   When we add user, the user have their own initial group and supplementary GROUP.  The step by step procedure below show how to add user account and specify the supplementary GROUP the the user belong to.

1.  The useadd command below with the option '-G' is use to add the user to supplementary GROUP rootbindaemonsysadmdisk andwheel.
[root@localhost ~]# useradd -c "Sachin T" -G root,bin,daemon,sys,adm,disk,wheel sachin
[root@localhost ~]#

2. Verify user groups.
[root@localhost ~]# groups sachin
sachin : sachin root bin daemon sys adm disk wheel
[root@localhost ~]#

The output from command above show that the user sachin initial group is 'sachin' and the user sachin belong to the supplementary GROUP 'rootbindaemonsysadmdisk and wheel'.

3. Dont forget to create password for user ( to make sure that user can login)
[root@localhost ~]# passwd sachin
Changing password for user sachin.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#

4. Login as user william and check the user groups.
[sachin@localhost ~]$ whoami
sachin
[sachin@localhost ~]$ id
uid=505(sachin) gid=505(sachin) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),505(sachin)
[william@localhost ~]$

Create user home directory to other location.


   The default location of users home directory in the Fedora core system is under /home .  The example below show example of creating user and locate their home directory in other location on the system. 

1. Change directory to /tmp.
[root@fedora ~]# cd /tmp/
[root@fedora tmp]#

2. Verify.
[root@fedora tmp]# pwd
/tmp
[root@fedora tmp]#

3. Add user and put the user home directory in /tmp directory.
[root@fedora tmp]# useradd -d /tmp/johnny johnny
[root@fedora tmp]#

4. Verify the existance of user home directory.
[root@fedora tmp]# ls
johnny
[root@fedora tmp]#

5.  Delete the user.
[root@fedora tmp]# userdel -r johnny
[root@fedora tmp]#

6. Verify.
[root@fedora tmp]# ls
[root@fedora tmp]#

No comments:

Post a Comment