Thursday, January 28, 2016

How to Manage Users and Groups in Linux via Terminal

1)
Add new group named "school"

            praveen@praveen-VirtualBox:~$ sudo groupadd school



2)
List the group that created in above step.

          praveen@praveen-VirtualBox:~$ cat /etc/group


3)
Add two users named "students" and "staffs"

             praveen@praveen-VirtualBox:~$ sudo useradd -m students
            praveen@praveen-VirtualBox:~$ sudo useradd -m staffs
  

-m option is used for crate the home directory at the time of user is created.

4)
List the users that created in the above step.

            praveen@praveen-VirtualBox:~$ cat /etc/passwd


5)
Then, add the existing users "students" and "staffs" to the group "school".

               praveen@praveen-VirtualBox:~$ sudo adduser students school

               Adding user `students' to group `school' ...
               Adding user students to group school
               Done.
             praveen@praveen-VirtualBox:~$ sudo adduser staffs school
           
             Adding user `staffs' to group `school' ...
               Adding user staffs to group school
               Done.
              praveen@praveen-VirtualBox:~$


After adding users to the group then list the name of groups then we can see the changes..


6)
Delete the user.

              praveen@praveen-VirtualBox:~$ sudo userdel -r students         
              praveen@praveen-VirtualBox:~$ sudo userdel -r staffs

 -r option is used for delete the user with its home directory 

7)
Delete the group.

             praveen@praveen-VirtualBox:~$ sudo groupdel schoo

No comments:

Post a Comment

AI & M L Lab - 18CSL76

  Lab programmes: View