1833356 Members
3468 Online
110051 Solutions
New Discussion

Re: mv command

 
navin
Super Advisor

mv command

Hi,
I'm moving a users homedirectory to differnt directory as his user name changes.Is it need to do chown after doing this.My ? is Is the 2 nd step is necessasry.Pls clear this.
1.mv 1xxx 1yyy
2.chown -R 1yyy(username):group name 1yyy(home)

Thanks
Learning ...
7 REPLIES 7
Mark Greene_1
Honored Contributor

Re: mv command

If you don't change the ownership of the directory after you move it, the user will not have access to it unless his group membership is the same and there are group read and write permissions on all the files.

mark
the future will be a lot like now, only later
navin
Super Advisor

Re: mv command

Thanks mark.So it seems it is really necessary to "chown" after the "mv".Correct?
Thanks
Learning ...
Mark Greene_1
Honored Contributor

Re: mv command

Yes, you need to chown the files to the new user ID. I cannot say if the syntax you provided above is appropriate or not. If, when you are done, the permissions look like they do in other users' directories, you are probably all set.

mark
the future will be a lot like now, only later
navin
Super Advisor

Re: mv command

Thanks for the quick reply.
Thanks.
Learning ...
Paul Sperry
Honored Contributor

Re: mv command

I'd use usermod to do this.
with the -m and -l options.



-m Move the user's home directory to the
directory specified with the -d option. If
the home directory exists, the directory must
have read and execute permission by group,
where group is the primary group of the
login.



-l new_logname Specifies the new login name for the user.
It consists of a string of printable
characters that does not contain a colon (:)
or a newline (\n).
kenny chia
Regular Advisor

Re: mv command

Are you just trying to change his username only?
If so you just need to edit the /etc/passwd file and replace his old username with the new one
All Your Bases Are Belong To Us!

Re: mv command

I'm going with Kenny on this one - if you rename the users login in /etc/passwd (and presumably change their home directory at the same time) without changing their uid, then you won't need to chown the user's login directory - the uid doesn't change!

The same applies to their group id too.