LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-11-2004, 07:24 AM   #1
dileepkk
Member
 
Registered: Jul 2004
Posts: 42

Rep: Reputation: 15
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

Last edited by dileepkk; 08-12-2004 at 01:32 AM.
 
Old 08-11-2004, 01:21 PM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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
 
Old 08-12-2004, 01:30 AM   #3
dileepkk
Member
 
Registered: Jul 2004
Posts: 42

Original Poster
Rep: Reputation: 15
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
 
Old 08-12-2004, 01:40 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
try your hand at
'wtmp' and 'utmp' files

man utmp,man wtmp

regards
 
Old 08-12-2004, 11:49 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login screen with list of names BaltikaTroika SUSE / openSUSE 3 11-18-2005 10:53 PM
root login to mandrake 10.1 and manu names PeterOnTheNet Mandriva 2 02-20-2005 09:17 AM
Mozilla runs applets when I'm logged in as root, but not my other login. tdr_nj Red Hat 2 04-28-2004 11:19 PM
How to auto login to Samba from 2 computers with 2 names? fclifton Linux - Networking 3 02-03-2004 02:00 PM
Hiding user names on the login screen windoze killa Mandriva 2 10-16-2003 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration