1832880 Members
2359 Online
110048 Solutions
New Discussion

useradd fails

 
SOLVED
Go to solution
Brad Marks
Super Advisor

useradd fails

When I execute this command:
useradd -g users -d /home/users -s /bin/sh -c test x.xxx
I get this error:
'/home/users' is not a valid directory

What could be invalid about /home/users?

Thanks,
Brad
It's not impossible -- it'll just cost more...
9 REPLIES 9
Jeff Schussele
Honored Contributor

Re: useradd fails

Hi Brad,

Does it exist prior to the command?
If not then you need a -m to "make" it.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Brad Marks
Super Advisor

Re: useradd fails

Jeff,
Yes it does.
Further, I found that if i add a trailing "/"; making it "-d /home/users/" it works, except the ownership of /home/users changes from root:sys to the user being added (in this case x.xxx:users)!?
It's not impossible -- it'll just cost more...
hari jayaram_1
Frequent Advisor

Re: useradd fails

Hi,

I just tried that on a test server and it works perfectly fine. I had to later create the directory. Please advice if the directory is already there and also if you are doing it with sufficient priveleges.

Thanks
Sundar_7
Honored Contributor

Re: useradd fails

I dont believe you will get an invalid directory message even if the directory exists already.

Learn What to do ,How to do and more importantly When to do ?
Jeff Schussele
Honored Contributor

Re: useradd fails

OK - what is the ownership & perms of /home?
A clueless admin doing chown username:groupname .* inside a user's home dir can change the ownership of /home& that can result in these symptoms.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Brad Marks
Super Advisor

Re: useradd fails

The /home/users directory already exists:
drwxrwxrwx 2 root users 96 May 10 16:07 .
drwxrwxrwx 32 root root 1024 May 4 11:18 ..
-rw-r--r-- 1 root users 893 May 10 13:42 .profile
It's not impossible -- it'll just cost more...
Jairo Campana
Trusted Contributor
Solution

Re: useradd fails

useradd -g users -d /home/users -s /bin/sh -c test x.xxx

error '/home/users' is not a valid directory
the comamd some times the directory does not create

in my case

made mkdiir /home/users or option:

-m Creates the home directory for the new login if it
does not exist. If the home directory exists, the
directory must have read and execute permission by
group, where group is the primary group of the new
login.
legionx
Brad Marks
Super Advisor

Re: useradd fails

It seems that the group ownership of /home/users needs to be 'users'.
This fixed it.

Thanks to all!
Brad
It's not impossible -- it'll just cost more...
Bill Hassell
Honored Contributor

Re: useradd fails

The permissions on /home and /home/users are very wrong. They should be 755 (drwxr-xr-x). Do you have umask set? If not, you will have to fix all the directories and files created since the original installation. umask is critical for the root user and should be 022 or even 077.


Bill Hassell, sysadmin