LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   curious about adduser (https://www.linuxquestions.org/questions/linux-newbie-8/curious-about-adduser-624403/)

john83reuben 02-28-2008 02:56 AM

curious about adduser
 
I am a bit curious about this adding user commands in linux, like adduser and useradd

Just say a user name john1 exists in the system, and then we adduser john1 again, we have an error that shows

adduser: The user `john1' already exists.

I want to know where the configuration files is placed that shows this message. I want to know how it checks the /etc/passwd file and produce that output. I want to knw teh scripting part of it.

Any ideas.

Thanks in advance.

bathory 02-28-2008 03:28 AM

adduser is a shell script, so you can open it with an editor like vi and take a look at its code to see how the various checks are done.

Regards

john83reuben 02-28-2008 04:00 AM

issit the adduser.conf???

bathory 02-28-2008 04:19 AM

You can use an editor to view adduser as it's a shell script. In Slackware the check is done by this piece of code:
Code:

...
  grep "^${LOGIN}:" $pfile >/dev/null 2>&1  # ensure it's not already used
  if [ $? -eq 0 ]; then
    echo "- User '$LOGIN' already exists; please choose another"
...

where $pfile=/etc/passwd and $LOGIN is the input (username).
I guess that if you have a file called adduser.conf, then it contains the defaults for a user creation, like homedir, shell etc.


All times are GMT -5. The time now is 10:40 AM.