LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-12-2011, 03:19 PM   #1
aksharb
LQ Newbie
 
Registered: Mar 2011
Posts: 27

Rep: Reputation: 0
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?
 
Old 05-12-2011, 04:21 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
create a directory at user home using shell script nagendrar Solaris / OpenSolaris 10 04-30-2010 05:30 AM
Creating a user without a home directory. deedawn Linux - Newbie 2 10-29-2008 11:36 AM
create a new user with a different home directory cccc Debian 6 08-06-2008 05:47 AM
How can I set the permission on the home directory when creating an user crisostomo_enrico Solaris / OpenSolaris 4 09-26-2007 06:24 PM
Creating new user gives empty /home directory rkfb Slackware 8 12-28-2005 11:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration