LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 03-17-2013, 12:29 PM   #1
NuxIT
Member
 
Registered: Jul 2003
Location: Westminser, CO
Distribution: xUbuntu
Posts: 76

Rep: Reputation: 20
How do I move files using mv and change ownership at the same time?


I had an issue where my top and bottom menu panels were not loading correctly on my ubuntu XFC desktop. So, I created a new user to get the panel back to normal.
Now I'm in the process of moving all my folders from user1 to the new user2's home directory.

So, this is what I've been doing.. Can someone tell me the more efficient way to go about doing this?

I'm moving one folder at a time from the terminal with the following command.

Code:
sudo mv -f /home/user1/linux /home/user2/linux
Then I change the ownership of files so I can write to them via this command.
Code:
sudo chown -hR user2 /home/user2/linux/
Now I can write to the files but I think they still retained my user1 Group settings.
Code:
user@brits:~/linux$ ll
total 80
drwxrwxr-x  2 user2 user1  4096 Mar  9 10:49 ./
-rw-rw-r--  1 user2 user1   595 Oct 10 22:58 cachefolders_size
-rw-rw-r--  1 user2 user1   398 May  6  2012 crashreport
-rw-rw-r--  1 user2 user1   551 Dec 15  2011 howto
-rw-rw-r--  1 user2 user1    40 Nov  9  2011 linuxapps
Can someone advise me if I can use one command to move the folders and subfolders while changing permissions from user1 to user2?

I'm sure I could probably use one command to move all my files and folders from user1 to user2 home directory so appreciate any help.

Also, any tip on deleting user1 and all the .cache folders ,etc associated with user1 would be helpful. I was thinking it *should* delete all the folders if I go into this menu.. System> Users and groups and delete the user1 account. I was concerned that if I delete this user1 that it might mess up the group associations I listed above??

Thanks

Edit, I figured out how to change the group on all my files as well using the chgrp command. Still looking for tips to be more efficient in the future.

Last edited by NuxIT; 03-17-2013 at 12:44 PM.
 
Old 03-17-2013, 12:52 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,745

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
For the mv command, try this:
Code:
 sudo mv /home/user1/* -tu /home/user2/
-t move all SOURCE arguments into DIRECTORY
-u move only when the SOURCE file is newer than the destination file or when the destination file is missing

That should move the entire contents of /home/user1 to /home/user2.

For the chown command, try this:
Code:
sudo chown -R user2:group /home/user2/
Use the appropriate user and group names.

Last edited by bigrigdriver; 03-17-2013 at 07:16 PM.
 
Old 03-18-2013, 12:47 AM   #3
NuxIT
Member
 
Registered: Jul 2003
Location: Westminser, CO
Distribution: xUbuntu
Posts: 76

Original Poster
Rep: Reputation: 20
Thumbs up

Cool. Thanks for these tips bigrigdriver.. I'm going to try the mv arguments you provided when I get home this morning and see how that works out. Nice sig file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Automatically change permissions/ownership of files in a directory Shimdidly Linux - Newbie 3 04-08-2012 08:22 PM
How to change the ownership of files mounted from floppy image osdevkid Linux - Software 3 03-08-2011 08:21 AM
Can't change ownership of files on windows partition alan_the_eagle Linux - Newbie 4 03-27-2005 03:35 AM
sudo: How can i change the ownership of particular files? anoopp Linux - Security 1 03-18-2005 02:03 AM
change ownership on files written by apache/php to maintain effective quotas untoldone Linux - Software 2 01-14-2005 07:18 PM


All times are GMT -5. The time now is 04:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration