Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell script to display all users names, or users names of a particular group, or name of users who are currently working in the system

Posted By: Adelaide Fischer     Category: Unix / Linux / Ubuntu     Views: 14670

Write a shell script to display all users names, or users names of a particular group, or name of users who are currently working in the system.

Code for Shell script to display all users names, or users names of a particular group, or name of users who are currently working in the system in Unix / Linux / Ubuntu

i="y"while [ $i = "y" ]
do
echo "1. TO DISPLAY ALL USERS NAMES."
echo "2. USERS NAME OF PARTICULAR GROUP."
echo "3. NAME OF USERS WHO ARE CURRENTLY WORKING ON THE    SYSTEM."
echo "4. EXIT"
echo "ENTER A CHOICE:"
read choice
case $choice in
        1)echo "ALL USERS NAMES ARE:"
          cut -d ":" -f 1 /etc/passwd | more
          read choice;;
        2)echo "ENTER A PARTICULAR GROUP NAME:"
          read g1
         grep "$g1" /etc/passwd | cut -d ":"  -f 1
                read choice;;

        3)who | more
         read choice;;
        4) exit;;
esac
echo "Do u want to continue ? "
read i
if [ $i != "y" ]
then
exit
fi
done












OUTPUT
***********
[04mca58@LINTEL 04mca58]$ sh samegroup.sh
1. to display all users names.
2. users name of particular group.
3. name of users who are currently working on the system.
4. exit
enter a choice:
1                     
all users names are:
root
bin
adm
mca01
mca58

do you want to continue ?
y
1. to display all users names.
2. users name of particular group.
3. name of users who are currently working on the system.
4. exit
enter a choice:
2
enter a particular group name:    
adm
adm         
do you want to continue ?
y
1. to display all users names.
2. users name of particular group.
3. name of users who are currently working on the system.
4. exit
enter a choice:
3          
root     :0       des 12 08:04
mca01    pts/9    des 12 09:10
mca58    pts/10   des 12 09:16
do you want to continue ?
y
1. to display all users names.
2. users name of particular group.
3. name of users who are currently working on the system.
4. exit
enter a choice:
4
  
Share: 



Adelaide Fischer
Adelaide Fischer author of Shell script to display all users names, or users names of a particular group, or name of users who are currently working in the system is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!