LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-01-2009, 01:14 AM   #1
AdnanShaheen
Member
 
Registered: Aug 2009
Distribution: Suse, RedHat, CentOS, Solaris, Windows
Posts: 38

Rep: Reputation: 16
System Users


Dear all
Is there any API/library available to get all system users and their groups or any one of them?

How can we set a user password programmatically. (I'm a root user, I want to add a user, set its group and password)
 
Old 10-01-2009, 01:39 AM   #2
carbonfiber
Member
 
Registered: Sep 2009
Location: Sparta
Posts: 237

Rep: Reputation: 46
Dear AdnanShaheen,

One of the great things about "open source" is that you can actually read the source. Your system most likely already provides utilities for adding/removing users/groups - why do you not read their sources to see how they accomplish this task? The passwd utility also has a source.

Yours truly, etc.

Last edited by carbonfiber; 10-01-2009 at 01:41 AM.
 
Old 10-01-2009, 01:43 AM   #3
robajz
LQ Newbie
 
Registered: Apr 2009
Distribution: Debian
Posts: 4

Rep: Reputation: 0
Hi,

I don't know of any library, but surely you can execute standard tools like
useradd - http://linux.about.com/od/commands/l...l8_useradd.htm
passwd - http://unixhelp.ed.ac.uk/CGI/man-cgi?passwd

You can read /etc/passwd for a list of users

Regards, Rob
 
Old 10-01-2009, 02:03 AM   #4
bangaram
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Rep: Reputation: 0
u can try "listusers" in solaris ...which reads from the appropriate source as directed in nsswitch.conf.....not sure in linux

/etc/passwd is a good option but ..will list only local users
 
Old 10-01-2009, 02:42 AM   #5
AdnanShaheen
Member
 
Registered: Aug 2009
Distribution: Suse, RedHat, CentOS, Solaris, Windows
Posts: 38

Original Poster
Rep: Reputation: 16
Thanks guys
I know about useradd, userdel etc and /etc/passwd. But I would be happy if some one have already read it somewhere, about any lib/API. Any how thanks once again
 
Old 10-02-2009, 01:21 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You don't say what language, but in C I'd start with http://linux.die.net/man/3/getpwuid
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to add a secondary group to all users except system default users Tekken Linux - Server 5 06-29-2009 04:02 PM
How to sort regular users and system users from /etc/passwd joeyBig Red Hat 9 05-29-2008 12:59 AM
Allow System Users and Virtual Users in VSFTPd Nickbrandson Linux - Software 0 01-24-2008 08:06 AM
use of having system users ?? kirtikjr Linux - Software 1 06-18-2007 02:39 PM
migrating users from one system to another system wincrk Linux - Newbie 4 04-26-2006 10:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:31 PM.

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