Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all, I'm writing a program that allows the user to enter a certain username contained in the home directory which brings bring up their details. i.e. 1. Are they ...
  1. #1
    Just Joined! nistleloy's Avatar
    Join Date
    Dec 2007
    Posts
    4

    Bash

    Hi all,

    I'm writing a program that allows the user to enter a certain username contained in the home directory which brings bring up their details.

    i.e.

    1. Are they logged on now
    2. When did they last log on
    3. What groups are they in


    How would I go about doing this.

    I understand that I will have to use the last command to find data on a users last log in but the system only seems to store log on details for the last few days, when a user might have last logged on months ago.

    Any suggestions?

    Thanks

  2. #2
    Just Joined!
    Join Date
    Dec 2007
    Posts
    11

    hiiiiiiiiii

    hi i m very new for this linux forum..........
    really it is very nice.
    and till now i came across i missed a lots of things before joing this good forum.

  3. #3
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274
    Quote Originally Posted by nistleloy View Post
    Hi all,

    I'm writing a program that allows the user to enter a certain username contained in the home directory which brings bring up their details.

    i.e.

    1. Are they logged on now
    2. When did they last log on
    3. What groups are they in


    How would I go about doing this.

    I understand that I will have to use the last command to find data on a users last log in but the system only seems to store log on details for the last few days, when a user might have last logged on months ago.

    Any suggestions?

    Thanks
    for 1 and 2 you can use "last" as you have mentioned. It shows the last time a user logged on as if they are still currently logged in. For 3 you can use groups. e.g.

    Code:
    last ben
    ben      pts/1        192.168.0.10     Thu Dec  6 22:06 - 22:06  (00:00)
    
    groups ben
    ben : ben
    If last does not go back far enough then you could use some other way of archiving /var/log/wtmp to a file every day (cat /var/log/wtmp >> /var/log/wtmp.big, for example?) and then using grep to search through it. The /var/log/wtmp.big file would get big over time so you could use awk to truncate x number of lines or days of data from the start of the file.
    Registered Linux user #389109
    My Semi-Linux Blog

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    You use finger for this. Finger can do everything you request except group membership, which is easiest done with id.

  5. #5
    Just Joined! nistleloy's Avatar
    Join Date
    Dec 2007
    Posts
    4
    Thanks for you all replies.

    With a little trial and error and using your advice I've been able to advance quite a lot.

    I have to connect to a linux server at uni and therefore do not have root access which makes life just a tad harded.

    Any how
    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...