Copying whole home/user1 directory to home/user2 directory on Linux - Ubuntu16.04

Viewed 83

I have researched on google about copying a whole directory home to another user account on my Linux machine but i have not encountered one post about this. People usually want to copy a particular path but not the whole directory.

By reading three articles that i will post here later on(i have read a bunch more but these three were the best ones i founded) i have founded that the best command line i can write to do what i want is:

$ sudo cp -a /home/user1/ /home/user2/
$ sudo chown -R user2:user2 /home/user2/ 

These are the links i founded the best.

  1. https://linuxize.com/post/how-to-copy-files-and-directories-in-linux/
  2. https://linuxize.com/post/cp-command-in-linux/
  3. https://askubuntu.com/questions/86822/how-can-i-copy-the-contents-of-a-folder-to-another-folder-in-a-different-directo

The problem is i cannot copy every file i have there, for example:

"cp: cannot stat '/home/user1/.var/app/org.mozilla.firefox/cache/mozilla/firefox/4dcohxta.default-release/cache2/entries/C02B703BAA45ED748D7DB6B07D15FA0DFCCD37E8': No such file or directory"

Which other command could help me resolve this problem? Are the two command lines i posted safe to write and achieve what i want or can i choose better ones?

1 Answers

I did what i wanted to do by writing those lines of code, as i said on my post write these two lines of code and you are done.

$ sudo cp -a /home/user1/ /home/user2/
$ sudo chown -R user2:user2 /home/user2/ 

Those commands save all the programs and documents without any problem, but it doesn't move anything to each folder of your "user2" tree directory, it only copies the entire folder into "/home/user2/".

Related