LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   create user without creating user home directory (https://www.linuxquestions.org/questions/linux-software-2/create-user-without-creating-user-home-directory-880386/)

aksharb 05-12-2011 03:19 PM

create user without creating user home directory
 
Hi,
i have rhel 5.2 and i want to create user using useradd command without creating user home directory and not throwing any warning/error about not creating any home directory.
i have tried

useradd -u "$NEW_UID" -g <gid> -d "/home/$1" -M "$1"

where $1 is user name and $NEW_UID is i am calculating.

it throws error as

useradd: cannot create directory /home/$1

which i dont want to come , how to prevent this?

MensaWater 05-12-2011 04:21 PM

Are you actually specifying a value instead of "<gid>" in your command line?

Why do you have quotes around all the variables?

This command should work and does on later RHEL5/CentOS5 so I suspect you're doing something untoward. Maybe putting an echo for your variables above the actual useradd line will show if they are actually what you expect?

Also you might want to run "rpm -qf $(which useradd)" to see the package that installed this on your system then run "yum list <package>" to see if there is a later version - maybe there was a bug in the version you have?

Finally I've found with useradd that sometimes order of options makes a difference. Try moving the -M to before the -d and see if that helps. (However as noted your syntax worked for me on later versions.)


All times are GMT -5. The time now is 02:08 AM.