How to create a new unix user in through a c program


 
Thread Tools Search this Thread
Top Forums Programming How to create a new unix user in through a c program
# 1  
Old 03-01-2006
How to create a new unix user in through a c program

Hi ,

I want to create a new user using c program not with unix adduser command .
is it possible to write a cprogram to create a new user account , it should accept username , grouid , group name and all other privilages .

i can use system calls inside c program to do this .

i will execute it in a super user mode .

Many thanks in advance !

Naren
# 2  
Old 03-01-2006
I don't think this is a simple "C" program with a couple of system calls.... It sounds like you're on Linux, so try getting a copy of your distro's source for useradd.
# 3  
Old 03-02-2006
thanks Jim

Hi Jim ,

Thanks for your response .

no i am in HP-uX 11i, my requirement is whether i can write a cprogram to create unix user account .

is it possible !

thanks once again .

Narendra
# 4  
Old 03-02-2006
I'm on HPUX as well. Half the time.
Yes it's trivially possible since it's already been done by HP, but I do not know how.

You have a lot of reading and research to do:

Richard Stevens 'Advanced Programming in the UNIX Environment'
Cooper & More 'HP-UX 11i Internals'

What is the reason you can't use existing HP-provided code?
# 5  
Old 03-02-2006
Hi Jim ,

Thanks again for your response .

I can use Hp-provided code , but my requirement is that , i should br be able to accept user input from stdin and create a user .

My client wants a mechanisim where he can create users with his login ( if has given the permission of root ) and not by sys admin or root .


anything else let me know !

thanks once again .

Narendra
# 6  
Old 03-03-2006
Just use the HP program useradd. Have your C program construct a useradd command line and then use system() to run the command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

How to create a user in UNIX with some limited permissions?

As i know, Unix or Linux only manages 2 type of user: root user or normal user. All users with userID=0 will have all administration permissions like root user with the system. In my case, i want to create a new user in HP-UNIX environment with all root permissions only one exception that this... (5 Replies)
Discussion started by: hieucn1404
5 Replies

2. Shell Programming and Scripting

New To UNIX - Need Script to create report of user & group accounts

Hi, I'm new to the world of UNIX and have been asked to create a complex script (at least complex to me:confused:) for AIX UNIX to create a report of all the users on the server including server, user, UID, groups, GID, etc. Found a script using lsuser, but the output is still lacking. 2 things I... (2 Replies)
Discussion started by: panthur
2 Replies

3. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

4. UNIX for Dummies Questions & Answers

create new user in unix

hi how to create new user in unix plz explain me (3 Replies)
Discussion started by: arulkumar
3 Replies

5. Programming

create sound using C program

I could not recall the function in C to generate diff type of sounds. Can somebody help me out. (2 Replies)
Discussion started by: bishweshwar
2 Replies

6. UNIX for Dummies Questions & Answers

create New UNIX User

Hi all, I wish to create some users, I can do that using the following command. useradd I wonder If i could create Uers as a clone of Root. I mean different users but having the same provileages as Root user. Can be ablle to access the Root Dir and so on .. Please help me out Is this... (6 Replies)
Discussion started by: Asteroid
6 Replies

7. Shell Programming and Scripting

Create Unix User

Is there any way to create user with default password by shell script withoud manual intervantion and from a text file having user's information and default password. Thanks (6 Replies)
Discussion started by: wenay
6 Replies

8. Programming

Create a lib from a c program

I have a function in a c program that I want to to share with other programs. How do I create a lib using the cc compiler ? (9 Replies)
Discussion started by: npires
9 Replies

9. Programming

Using a C program to create directories in UNIX

Aloha, I'm attempting to use a C program to create directories and then use a system call to have another program write .dat files into that directory. I understand that I could use the "system("mkdir directory_name")" function however, I would like my program to create a new directory each time... (3 Replies)
Discussion started by: aloha_boi
3 Replies

10. UNIX for Advanced & Expert Users

Other than root user .Normal user is unable to create files

Hi all, I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies
Login or Register to Ask a Question