简体   繁体   English

将整个 home/user1 目录复制到 Linux 上的 home/user2 目录 - Ubuntu16.04

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

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.我在谷歌上研究了关于将整个目录主页复制到我的 Linux 机器上的另一个用户帐户,但我没有遇到过关于此的帖子。 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/ https://linuxize.com/post/how-to-copy-files-and-directories-in-linux/
  2. https://linuxize.com/post/cp-command-in-linux/ 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 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?我发布的两个命令行是否可以安全编写并实现我想要的,或者我可以选择更好的命令行吗?

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/".这些命令可以毫无问题地保存所有程序和文档,但它不会将任何内容移动到“user2”树目录的每个文件夹中,它只会将整个文件夹复制到“/home/user2/”中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM