Wednesday 23 September 2015

add user and create group LINUX



#Assignment noA3
Roll no:
Batch  :
ch=1
  while [ $ch  -eq 1 ]
  do 
    echo "1.Add user"
    echo "2.Add group "
    echo "3.adding user to group "
    echo "4.check the content of group "
    echo "5.check the info of user"
    echo "6.change owner"
    echo "7.change group"
    echo "plz enter u r choice"
    read no

  case $no in
   1) echo " how many user u want to create"
       read no
       i=0
       while [ $i -lt $no ] 
       do
        echo "enter the user name u want to create"
        read usrname 
        sudo adduser $usrname 
        $((i+=1))
       done 
       ;;
   2)  echo "enter group name "
       read gname
       sudo addgroup $gname
       ;;
   3)  echo "add user in group"
       echo "how many user u want to enter into group"
       read n
       echo "enter group name which u want to add user"
       read gname
       i=0
       while [$i -lt $n ]
       do 
         echo "enter user name which u want to already create"
         read username
         sudo adduser $username $gname 
         $((i+=1))
       done
       ;;
   4)  echo "information of group"
       sudo cat /etc/group
       ;;
   5)  echo "information of all user"
       sudo cat /etc/passwd
       ;;
   6)  echo "plz enter owner name"
       read ownername
       echo "plz enter usrname which u want change owner"
       read username
       sudo chgrp $ownername $username
       getfacl $username
       ;;
   7)  echo "plz enter group name"
       read gname
       echo "plz enter usrname which u want change group"
       read username
       sudo chgrp $gname $username
       getfacl $username
       ;;
   *)
       echo "wrong choice"
       ;;
   esac
   echo "do u want to continue y=1/n=0"
   read ch
done

No comments:

Post a Comment