Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chown question

Status
Not open for further replies.

paladin256

Technical User
Apr 16, 2002
189
US
I created user john.doe by doing useradd -m -c "john Doe" -s /bin/false john.doe

The owner of the home directory was changed by accident. I am now trying to change it back by doing chown -R john.doe but am getting error no group doe.

How do I get the ownership set back? I have tried quotes and other things to no avail.

Thank You
 
paladin256,

Try the following:

# chown -R john\.doe <path to home directory>

you must use the &quot;\&quot; character in order to search for unix defined characters such as . ? $ etc... If you do not do this the system will look for user john in group doe, and as the error is telling you, there is no group called doe.

If you want to change the owner and group in one single command it can be done like so:

# chown -R john\.doe:<groupname> <path to home directory>

Good luck!

Have a Great Day!! :)
~Sol
Sys Admin
 
I wish to only change the owership back to john.doe. I just tried chown -R john\.doe john.doe and still got the same error unknown group: doe

Thank You
 
I tried both of these also work:
Environment:
grep abc /etc/passwd
abc.test:x:20000:10::/export/home/abc.test:/bin/false

ls -l
drwxr-xr-x 2 myname staff 512 Oct 16 13:37 abc.test

chown -R abc.test abc.test #work!
chown -R abc\.test abc.test #also work!

So I think it must be related to the /etc/group. Maybe it is really group missing.
Pls. show more details to us.
 
Sorry if I was unclear before. The username is john.doe, not username john in group doe. I hope this clears things up.

Thank You
 
You could do:

chown <UID> <filename>

Just look at /etc/passwd, get john.doe's user ID (3rd filed in /etc/passwd), and run the chown command with the uid, not the username.

 
paladin256,

The command I gave before set the user and group ownership of the file (I assumed john.doe belongs to a group and that you would want everything in the home directory owned by the proper user and group). If you do not want to do the group at the same time try the following:

# chown -R john\.doe /home/john\.doe

I'm assuming that /home/john.doe would be the home directory.

Also in your initial post you did not assign john.doe to a group. Try the following to verify the user's groups:

# groups -a john.doe

If he is not in a group, edit the /etc/group and add john.doe to a group. Then try the chown again.

Hope this does it for you.


Have a Great Day!! :)
~Sol
Sys Admin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top