LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   add user with name.name (https://www.linuxquestions.org/questions/linux-newbie-8/add-user-with-name-name-428578/)

Amr Ebeid 03-26-2006 02:30 AM

add user with name.name
 
hi all
i'm a new user ti linux
how can i add a user the format of (user.familyname)

gilead 03-26-2006 02:40 AM

On my system (Slackware) you can't create a login name like that, the '.' is an illegal character. However, when you create a user you also add extra information, including a comment field that usually contains the user name. You can put whatever you like in that field. Have you had a look at man useradd

Ph0en1x 03-27-2006 04:18 PM

You might consider using an underscore. (user_familyname)

XavierP 04-01-2006 04:15 PM

Moved: This thread is more suitable in Linux-Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.

reddazz 04-01-2006 04:42 PM

Useradd will let you create usernames with dots regardless of distro. Some other tools may not permit you to do this. You would need to do something like
Code:

#useradd -m firstname.surname

gilead 04-01-2006 04:52 PM

Are you sure about "regardless of distro"? Here's the output on Slackware:
Code:

# useradd joseph.blogs
useradd: invalid user name 'joseph.blogs'
# useradd -m joseph.blogs
useradd: invalid user name 'joseph.blogs'


reddazz 04-01-2006 05:08 PM

Quote:

Originally Posted by gilead
Are you sure about "regardless of distro"? Here's the output on Slackware:
Code:

# useradd joseph.blogs
useradd: invalid user name 'joseph.blogs'
# useradd -m joseph.blogs
useradd: invalid user name 'joseph.blogs'


I've just tried it on Gentoo, Suse, CentOS and Debian. It works fine on those distros but I get the same error as you on Arch. It leaves me wondering whether the other distros patch useradd to enable it to accept usernames with dots.

gilead 04-01-2006 05:14 PM

Quote:

Originally Posted by reddazz
It leaves me wondering whether the other distros patch useradd to enable it to accept usernames with dots.

I'd say you're right - in the shadow sources at http://cvsweb.pld.org.pl/shadow/libm...ame.c?rev=1.11, the user name must match [a-z_][a-z0-9_-]*[$] according to:
Code:

static int good_name (const char *name)
{
        /*
        * User/group names must match [a-z_][a-z0-9_-]*[$]
        */
        if (!*name || !((*name >= 'a' && *name <= 'z') || *name == '_'))
                return 0;

        while (*++name) {
                if (!((*name >= 'a' && *name <= 'z') ||
                      (*name >= '0' && *name <= '9') ||
                      *name == '_' || *name == '-' ||
                      (*name == '$' && *(name + 1) == '\0')))
                        return 0;
        }

        return 1;
}


reddazz 04-01-2006 05:23 PM

One thing to note though is that if have a username with a dot, you cannot use chown or chgrp using dots because they will fail or cause problems. The code below would fail,
Code:

#chown firstname.surname.somegroup somefile
The right syntax would have to be,
Code:

#chown firstname.surname:somegroup somefile

Mitio 11-29-2009 07:35 AM

workaround
 
Today i have the same problem with my OS - FC12.
I need to create user: FNAME.LNAME, and when i tried (with and without-m) i received:

useradd: invalid user name

In comparison, in FC11 i haven't such problem.

The workaround i used is to create user manually:
1. create home directory:
Code:

# mkdir /home/FNAME.LNAME
2. adding user TEMPLATEUSER:
Code:

# useradd TEMPLATEUSER
3. change /etc/passwd:
Code:

# cat /etc/passwd | sed -e "s/TEMPLATEUSER/FNAME.LNAME/g" > /etc/passwd
4. change /etc/group:
Code:

# cat /etc/group | sed -e "s/TEMPLATEUSER/FNAME.LNAME/g" > /etc/group
5. change /etc/shadow:
Code:

# cat /etc/shadow | sed -e "s/TEMPLATEUSER/FNAME.LNAME/g" > /etc/shadow
6. change permition to home directory:
Code:

# chown -R FNAME.LNAME:FNAME.LNAME /home/FNAME.LNAME
Please note, that this is workaround, and you could have problems with script that relay that you haven't dots in your username.


All times are GMT -5. The time now is 06:36 PM.