Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> Redhat Linux Users, Users
dp022
 Posted: Nov 28 2012, 02:57 PM
Quote Post


SLF Newbie


Group: Members
Posts: 6
Member No.: 2090
Joined: 28-November 12









How to find active, inactive and hidden users in redhat linux?

Thanks in Advance smile.gif
PMEmail Poster
^
zxq9
 Posted: Nov 28 2012, 11:52 PM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









You didn't give much background on your situation, so I'll assume you're looking for all users in a system that is getting its user data from itself (as in, no LDAP, Kerberos, NIS, or anything else going on).

User information is stored in /etc/passwd and group information is stored in /etc/group. Most administrators just read these directly:
CODE
cat /etc/passwd
to dump the whole things to the screen (or stdout, really), or
CODE
less /etc/passwd
to be able to page/scroll/search through it or
CODE
grep "username-or-whatever-else" /etc/passwd
to search through it and pull out just the lines you are interested in.

Learning why each user exists, on the other hand, is a subject best explored first through the system documentation. I prefer the Fedora 14 docs myself, so here are the pages on the standard users and the standard groups that can/will be found on a system. A lot of these are only going to exist if you install the package(s) that depends on them, so don't expect to find them all on a single system (unless the admin is crazy and tried to install every package at once).

If raw passwd data is confusing for you at this point in your geek evolution a one-liner can clean things up:
CODE
awk 'BEGIN { FS=":"; } { printf "Name:%15s UID:%7s GID:%7s\n", $1, $3, $4 }' /etc/passwd

Group information can be handled similarly (its in nearly the same format):
CODE
awk 'BEGIN { FS=":"; } { printf "Group Name:%15s GID:%7s\n", $1, $3 }' /etc/group

Using awk to reformat some output is nice and all, but to truly let your inner geek spread his wings I'd recommend reading up a little on awk and combining the output of /etc/passwd and /etc/group to join the two together, so that you get a list of usernames joined with a list of what groups each user belongs to...

And now to my question for you. You mentioned "inactive and hidden users". What did you mean by this? Like old user accounts that haven't been used in a long time or... ? This is pretty vague since none of us know your situation. You'll have to elaborate if you want further advice.
PMEmail PosterUsers Website
^
log69
 Posted: Nov 29 2012, 07:47 AM
Quote Post


SLF Member
***

Group: Members
Posts: 94
Member No.: 1325
Joined: 24-February 12









"last" command shows the most recent users logged in back to 1 month.
PM
^
dp022
 Posted: Nov 29 2012, 09:56 AM
Quote Post


SLF Newbie


Group: Members
Posts: 6
Member No.: 2090
Joined: 28-November 12









Hai,

Thanks for giving good information.

But I just want to know the active users, inactive users and hidden users for the redhat linux.

I know that we can see all the users in /etc/shadow file but I just want to know how to identify the users who are presently active or the users who are still using the services in the system and also to find the inactive and the hidden users.

I think we can't find the hidden users from the /etc/shadow file and how to identify the inactive users(who are already create and not be useful anymore).

Thanks in Advance smile.gif


QUOTE (zxq9 @ Nov 28 2012, 11:52 PM)
This post should probably be moved to an appropriate tech/advice forum...

You didn't give much background on your situation, so I'll assume you're looking for all users in a system that is getting its user data from itself (as in, no LDAP, Kerberos, NIS, or anything else going on).

User information is stored in /etc/passwd and group information is stored in /etc/group. Most administrators just read these directly:
CODE
cat /etc/passwd
to dump the whole things to the screen (or stdout, really), or
CODE
less /etc/passwd
to be able to page/scroll/search through it or
CODE
grep "username-or-whatever-else" /etc/passwd
to search through it and pull out just the lines you are interested in.

Learning why each user exists, on the other hand, is a subject best explored first through the system documentation. I prefer the Fedora 14 docs myself, so here are the pages on the standard users and the standard groups that can/will be found on a system. A lot of these are only going to exist if you install the package(s) that depends on them, so don't expect to find them all on a single system (unless the admin is crazy and tried to install every package at once).

If raw passwd data is confusing for you at this point in your geek evolution a one-liner can clean things up:
CODE
awk 'BEGIN { FS=":"; } { printf "Name:%15s UID:%7s GID:%7s\n", $1, $3, $4 }' /etc/passwd

Group information can be handled similarly (its in nearly the same format):
CODE
awk 'BEGIN { FS=":"; } { printf "Group Name:%15s GID:%7s\n", $1, $3 }' /etc/group

Using awk to reformat some output is nice and all, but to truly let your inner geek spread his wings I'd recommend reading up a little on awk and combining the output of /etc/passwd and /etc/group to join the two together, so that you get a list of usernames joined with a list of what groups each user belongs to...

And now to my question for you. You mentioned "inactive and hidden users". What did you mean by this? Like old user accounts that haven't been used in a long time or... ? This is pretty vague since none of us know your situation. You'll have to elaborate if you want further advice.
PMEmail Poster
^
log69
 Posted: Nov 29 2012, 11:00 AM
Quote Post


SLF Member
***

Group: Members
Posts: 94
Member No.: 1325
Joined: 24-February 12









QUOTE
just want to know how to identify the users who are presently active or the users who are still using the services


who
lsof -i
PM
^
zxq9
 Posted: Nov 29 2012, 11:01 AM
Quote Post


SLF Geek
****

Group: Members
Posts: 321
Member No.: 611
Joined: 5-August 11









You need to define the terms "hidden" and "inactive" to get an answer.

"inactive" means what? Not logged in for fixnum_days?

What do you mean by "hidden"? In a normal configuration there are no hidden users (and I can't think of any system at all where this is even a term), just system and non-system accounts.
PMEmail PosterUsers Website
^
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll