How to get all login names though they are not logged ??
Hi
I am searching for a system call that provides all login names. I know that they will be in /etc/passwd. Thanks in advance Dileep :Pengy: |
I don't think there is a system call to show all valid user accounts.
You could try: cat /etc/passwd|awk -F: '{ printf($1); }' But this will just get the username from /etc/passwd for all entries, and as a lot of these are system accounts that are not allowed to login... it probably is not what you are after. What is it you are trying to acheive? If you want to know who is currently logged in you can use either finger or who |
I want to get all user login names and other details evn if they are not login
Hi,
cat /etc/passwd|awk -F: '{ printf($1); }' prints all the entries, But i want only valid login names. how to get them. if we r using "redhat-config-users" we will get the details, actuallu i want those details, for that only iam searching the system call. Thankd in advance Dileep |
try your hand at
'wtmp' and 'utmp' files man utmp,man wtmp regards |
Ok, various options
1. Assuming valid users home directories reside directly under /home the most basic option is: ls /home 2. If you want General Users, assuming that general users have a UID between 101 and 65533 cat /etc/passwd|awk -F: '\ { if ( $3 > 100 ) { if ( $3 < 65534 ) { printf($1"\n"); } } }' 3. If you want All User accounts that can log in, note that neither option 1 or 2 will guarantee this. ** You will need to run this as root (or sudo) ** cat /etc/shadow|awk -F: '\ { if ( $2 != "!" ) { if ($2 != "*" ) { printf($1"\n"); } } }' This list will include the root account |
All times are GMT -5. The time now is 09:55 PM. |