Posted on 2011-10-14
Last Modified: 2012-05-12
Hi, I need to collect information for user accounts on lots of servers.

Which command can I use to get all these informaion at once?

• Username
• Login
• Status of the account
• Profil
• Date of last connection
Question by:cismoney
    LVL 4

    Expert Comment

    by:Christopher Raymond Mendoza
    You can use finger for this.

    Including it in a bash script may be be useful for multiple users.
    LVL 9

    Accepted Solution

    You may not be able to extract this information at one go but you can create a shell script like a sample given below

    for x in `cat /etc/passwd`
    Login=`echo $x | cut -f 1 -d ':'`
    UserName=`echo $x | cut -f 5 -d ':'`
    LoginStatus=`passwd -S $Login | cut -f 2 -d ' '`
    Profile=`echo $x | cut -f 6 -d ':'`
    LastLogin=`last $Login | head -n 1 | tr -s ' ' | cut -f 5- -d ' '`
    echo "$Login|$UserName|$LoginStatus|$Profile|$LastLogin"

    Open in new window

    LVL 9

    Expert Comment

    Please note some options for commands last and passwd could be different across linux variants.

    Hope this helps.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now