Member Avatar for b1izzard

How to list out i"dle users only" using finger command? (Commandline)

$finger
Login      Name                  Tty      Idle  Login Time   Where
ravikumar  ravikumar            *:0      -         Sun 19:54 console
ravikumar  ravikumar            *pts/0    2:36     Sun 19:56 
ravikumar  ravikumar            *pts/1   -         Sun 22:08 
$ finger | tr -s " " | sort -k 4 
ravikumar ravikumar *pts/0 2:47 Sun 19:56 
Login Name Tty Idle Login Time Where
ravikumar ravikumar *:0 - Sun 19:54 console
ravikumar ravikumar *pts/1 - Sun 22:08

In the above usage how to get the number of idle users,
so that I can pipe with head command?

Opensuse uses '-' to represent idle state, suppose if Blank space is used
to indicate idle state Means, How to select the idle users, since "tr -s" is useless?

Bear in mind that console windows or tabs in the UI are represented by the *pts/0...n devices. In this case, ravikumar is logged in on the console and has two virtual terminals open, one of which has been idle for some time. I also keep a number of virtual terminals open on my system, each for different purposes, so in my case I have a couple with no idle time, and 2 with 5 day idle times. They don't take much memory or other resources, so it is usually best to leave them alone. Remote logins are another issue, and those are what you need to look for because they do take up network bandwidth just to keep the connection alive.

Member Avatar for b1izzard

Bear in mind that console windows or tabs in the UI are represented by the *pts/0...n devices. In this case, ravikumar is logged in on the console and has two virtual terminals open, one of which has been idle for some time. I also keep a number of virtual terminals open on my system, each for different purposes, so in my case I have a couple with no idle time, and 2 with 5 day idle times. They don't take much memory or other resources, so it is usually best to leave them alone. Remote logins are another issue, and those are what you need to look for because they do take up network bandwidth just to keep the connection alive.

Thanks for the Info. I just want to give an example. Actually I need to find out Idle users in our lab environment where we use PUTTY to connect to the server.

Thanks for the Info. I just want to give an example. Actually I need to find out Idle users in our lab environment where we use PUTTY to connect to the server.

That makes sense, and is the most common use for terminating idle connections. You also might want to check into the "who" command instead of finger. It will provide a lot of useful information, including old connections if you use the "-a" option. Anyway, read the man page.

who -Tu | awk '$7 !~ /\./ {print $1 , $8}' | sort -u

Member Avatar for b1izzard

who -Tu | awk '$7 !~ /\./ {print $1 , $8}' | sort -u

Thank you voidyman :cool:,

$who -Tu | tr -s " " | cut -d " " -f1,6 | grep "[^a-z?. ]"

How about this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.