shell scripts for The file /etc/passwd contains info about all users. Write a program which would receive the logname during execution, obtain information about it from the file and display the information on screen in some appropriate format. (Hint : Use cut)

 
-----------------------------Script---------------------------
echo "Enter the logname : "
read lname
uid=`grep $lname /etc/passwd | cut -d ":" -f 3`
echo "User Id is : " $uid
gid=`grep $lname /etc/passwd | cut -d ":" -f 4`
echo "Group Id is : " $gid
dwd=`grep $lname /etc/passwd | cut -d ":" -f 6`
echo "Default Working Directry is : " $dwd
dws=`grep $lname /etc/passwd | cut -d ":" -f 7`
echo "Default Working directory is : " $dws

-----------------------------output---------------------------
Enter the logname :
mca114
User Id is :  680
Group Id is :  680
Default Working Directry is :  /home/dca19
Default Working directory is :  /bin/bash
-----------------------------END------------------------------ 

SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment