Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Write a program in C to mimic the "adduser" command on Linux. This command will add either an ordinary user or a system user. It has to handle 2 files "passwd" and "shadow". Both these files will be in some folder specified by an environment variable PFILE. The program has to take all arguments as command line arguments


for the above question i have very hardly done some research and done some coding .
code is of no errors .
but when i try to add user using command like ...
adduser –u 100 –g 200 –c "M S DHONI"msdhoni

it gives me option g is ambiguous .
can anyone tell me what is wrong

What I have tried:

I have tried to research about what is option g is ambiguous but could not find anything
Posted
Updated 18-May-20 20:30pm
Comments
Rick York 17-May-20 12:15pm    
Yes : your program does not work right.

Check the man page for adduser on your system. On Fedora31 system, -g adds the user to the (already defined) group given. On my raspbian system (debian based, so probably the same for other debian based systems i.e. ubuntu), -g is not an option, but --gid is.
 
Share this answer
 
Linux adduser and addgroup commands help and examples[^]
There is no -g flag to adduser command. There is a -gid flag to put the new user into the group with specified id, and there is a -group flag to create a group with the same name as the user.

You should always refer to documentation for this kind of issues.
 
Share this answer
 
Comments
Member 14830575 18-May-20 1:31am    
can you tell me what should be the command for adding newuser?
instead of the below command what should be the command?
adduser –u 100 –g 200 –c “M S DHONI”msdhoni -
phil.o 18-May-20 3:48am    
Everything is explained on the link I provided. You can also type
man adduser
to get syntax and usage examples. There also exists an useradd command accepting -g as option. Check it with
man useradd
Member 14830575 19-May-20 4:01am    
useradd –u 100 –g 200 –c “M S DHONI”msdhoni - I TRIED THIS AND I GOT group does not exist on the screen
Did you name your program adduser? Maybe you need to name it something else. Try
which adduser
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900