linux复制整个目录

Linux provides different tools to copy directories entirely. The most popular and well-known tool is cp. In this tutorial, we will look at how to copy Linux directories entirely or specific content.

Linux提供了不同的工具来完全复制目录。 最受欢迎和最著名的工具是cp 。 在本教程中,我们将研究如何完全复制Linux目录或特定内容。

仅复制目录 (Copy Only Directory)

In this first example, we will copy the only directory. We can just provide the source directory and destination directory names to the cp command. In this example, we will try to copy a single directory. As we can see we get an error like below.

在第一个示例中,我们将复制唯一目录。 我们只能为cp命令提供源目录和目标目录名。 在此示例中,我们将尝试复制一个目录。 如我们所见,我们收到如下错误。

$ cp backup newbackup

Copy Only Directory
仅复制目录

递归复制整个目录(Copy Entire Directory Recursively)

Now here is the real scenario. We will copy our directory named backup with a new named newbackup. We will use the -r option which makes copy operation recursively. Recursive means subdirectories and files will be copied too.

现在这是真实的情况。 我们将使用名为newbackup的新目录复制名为backup的目录。 我们将使用-r选项来递归执行复制操作。 递归意味着子目录和文件也将被复制。

$ cp -r backup newbackup

Copy Entire Directory Recursively
递归复制整个目录

复制特殊文件(Copy Special Files)

During recursive copy operation, special file content will not be copied by default. We can copy special file contents with the -b option like below.

在递归复制操作期间,默认情况下不会复制特殊文件内容。 我们可以使用-b选项复制特殊文件的内容,如下所示。

$ cp -r -b backup newbackup

保留源目录属性时复制 (Copy While Preserving Source Directory Attributes)

Files and directories provide some attributes in Linux operating systems. These attributes are file mode, ownership, timestamp, context, links, xattr, etc. During directory copy, we can copy these attributes too with the -a option like below.

文件和目录在Linux操作系统中提供了一些属性。 这些属性是文件模式,所有权,时间戳,上下文,链接,xattr等。在目录复制期间,我们也可以使用-a选项复制这些属性,如下所示。

$ cp -r -a -v backup new_backup

Copy While Preserving Source Attributes
保留源属性时复制

将整个目录复制到当前用户的主目录(Copy Entire Directory To The Current User Home Directory)

Linux bash shell provides some shortcuts about the paths. If we want to copy a directory completely into the current user home directory we can ~ tilde to specify the user home directory path. In this example, we will copy the directory named backup to the current user home directory.

Linux bash shell提供了一些有关路径的快捷方式。 如果要将目录完全复制到当前用户主目录中,可以~波浪号指定用户主目录路径。 在此示例中,我们将名为backup的目录复制到当前用户主目录。

$ cp -r backup ~/

复制详细Providig详细信息 (Copy Verbosely Providig Detailed Information)

During copy operation, there will be no sign about the current operation. We can make this copy operation verbose where copied files will be printed to the shell. We will use -v command like below.

在复制操作期间,不会有任何有关当前操作的迹象。 我们可以使此复制操作变得冗长,将复制的文件打印到外壳上。 我们将使用-v命令,如下所示。

$ cp -r -v newbackup oldbackup

Copy Verbosely
详细复制

使用rsync命令复制整个目录(Copy Entire Directory with rsync Command)

rsync is very popular and useful tools used to copy, sync, and backup files and directories. We can use rsync in order to copy the complete directory with its subdirectories locally or to the remote systems. We will use -r options to copy all directories and files recursively and also use -v option for verbose output.

rsync是非常流行且有用的工具,用于复制,同步和备份文件和目录。 我们可以使用rsync来将完整的目录及其子目录复制到本地或远程系统。 我们将使用-r选项以递归方式复制所有目录和文件,还将使用-v选项进行详细输出。

$ rsync -r -v backup backup_old

Copy Entire Directory with rsync Command
使用rsync命令复制整个目录
.u84abda36f9837a6ec519a79b02a3527c , .u84abda36f9837a6ec519a79b02a3527c .postImageUrl , .u84abda36f9837a6ec519a79b02a3527c .centered-text-area { min-height: 80px; position: relative; } .u84abda36f9837a6ec519a79b02a3527c , .u84abda36f9837a6ec519a79b02a3527c:hover , .u84abda36f9837a6ec519a79b02a3527c:visited , .u84abda36f9837a6ec519a79b02a3527c:active { border:0!important; } .u84abda36f9837a6ec519a79b02a3527c .clearfix:after { content: ""; display: table; clear: both; } .u84abda36f9837a6ec519a79b02a3527c { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u84abda36f9837a6ec519a79b02a3527c:active , .u84abda36f9837a6ec519a79b02a3527c:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u84abda36f9837a6ec519a79b02a3527c .centered-text-area { width: 100%; position: relative; } .u84abda36f9837a6ec519a79b02a3527c .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u84abda36f9837a6ec519a79b02a3527c .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u84abda36f9837a6ec519a79b02a3527c .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u84abda36f9837a6ec519a79b02a3527c:hover .ctaButton { background-color: #E67E22!important; } .u84abda36f9837a6ec519a79b02a3527c .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u84abda36f9837a6ec519a79b02a3527c .u84abda36f9837a6ec519a79b02a3527c-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u84abda36f9837a6ec519a79b02a3527c:after { content: ""; display: block; clear: both; }

LEARN MORE  What Is File Explorer (Windows)?

.u84abda36f9837a6ec519a79b02a3527c , .u84abda36f9837a6ec519a79b02a3527c .postImageUrl , .u84abda36f9837a6ec519a79b02a3527c .centered-text-area { min-height: 80px; position: relative; } .u84abda36f9837a6ec519a79b02a3527c , .u84abda36f9837a6ec519a79b02a3527c:hover , .u84abda36f9837a6ec519a79b02a3527c:visited , .u84abda36f9837a6ec519a79b02a3527c:active { border:0!important; } .u84abda36f9837a6ec519a79b02a3527c .clearfix:after { content: ""; display: table; clear: both; } .u84abda36f9837a6ec519a79b02a3527c { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u84abda36f9837a6ec519a79b02a3527c:active , .u84abda36f9837a6ec519a79b02a3527c:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u84abda36f9837a6ec519a79b02a3527c .centered-text-area { width: 100%; position: relative; } .u84abda36f9837a6ec519a79b02a3527c .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u84abda36f9837a6ec519a79b02a3527c .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u84abda36f9837a6ec519a79b02a3527c .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u84abda36f9837a6ec519a79b02a3527c:hover .ctaButton { background-color: #E67E22!important; } .u84abda36f9837a6ec519a79b02a3527c .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u84abda36f9837a6ec519a79b02a3527c .u84abda36f9837a6ec519a79b02a3527c-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u84abda36f9837a6ec519a79b02a3527c:after { content: ""; display: block; clear: both; }

了解更多什么是文件资源管理器(Windows)?

翻译自: https://www.poftut.com/copy-entire-directory-linux/

linux复制整个目录

linux复制整个目录_如何在Linux中复制整个目录?相关推荐

  1. linux按目录名查找目录_如何在Linux中查找目录?

    linux按目录名查找目录 Linux provides different ways to find directories. Here we will look at how to find di ...

  2. 在linux里复制文件命令_如何在Linux上使用“安装”命令复制文件

    在linux里复制文件命令 Fatmawati Achmad Zaenuri/Shutterstock.com Fatmawati Achmad Zaenuri / Shutterstock.com ...

  3. linux mint 图标主题_如何在 Linux Mint 中更换主题

    一直以来,使用 Cinnamon 桌面环境的 Linux Mint 都是一种卓越的体验.这也是为何我喜爱 Linux Mint的主要原因之一. -- It's Foss(作者) 一直以来,使用 Cin ...

  4. linux上开发应用程序_如何在Linux上安装软件应用程序

    linux上开发应用程序 如何在Linux上安装应用程序? 与许多操作系统一样,该问题不仅有一个答案. 应用程序可以来自许多来源-几乎无法计数-每个开发团队都可以以自己认为最佳的方式交付软件. 知道如 ...

  5. linux删除用户所有信息_如何在Linux上删除用户(以及删除所有跟踪)

    linux删除用户所有信息 Fatmawati Achmad Zaenuri/ShutterstockFatmawati Achmad Zaenuri / Shutterstock Deleting ...

  6. linux python开发环境_如何在Linux系统中搭建Python编程环境

    1 在大多数的Linux系统中,基本上都默认安装了Python,也就是说,在Linux的系统中基本上是不需要安装什么软件,就可以使用Python. 下面以ubuntu操作系统为例,看看如何在Linux ...

  7. linux 更改ssh端口_如何在Linux中更改SSH端口-简易指南

    linux 更改ssh端口 The default port on SSH is 22. But for security reasons, it's a good idea to change SS ...

  8. linux重启网卡命令_如何在 Linux 中更改 MAC 地址 | Linux 中国

    在向你展示如何在 Linux 中更改 Mac 地址之前,让我们首先讨论为什么要更改它.-- Dimitrios Savvopoulos 在向你展示如何在 Linux 中更改 MAC 地址之前,让我们首 ...

  9. linux swf文件打开_如何在Linux上播放.swf文件?

    linux swf文件打开 How to play the flash (.swf) files downloaded from the Web on Linux? 如何在Linux上播放从Web下载 ...

最新文章

  1. 线性求[1,P-1]的逆元
  2. 三代测序数据纠错的方法、装置和计算机可读存储介质与流程
  3. 剑指offer:二叉树的下一个节点
  4. 组策略安全选项对应注册表项汇总
  5. Homebrew软件包管理器中发现RCE漏洞,小心你的Mac和Linux
  6. Web服务器的配置与管理(2) 虚拟主机技术
  7. 数据持久化------Archiving(归档,解档)
  8. c语言数组-1_C数组-智能问题与解答
  9. doc 问卷调查模板表_调查问卷范文调查问卷模板.doc
  10. 18个Windows应该有却没有具有的苦守(2)
  11. LNMT架构部署:Linux+Nginx+Mysql+Tomcat
  12. SpringCloud五大神兽之Eureka服务注册(三)——Eureka的自我保护
  13. 记录:删除鼠标右键的某个“流氓”选项
  14. was not declared in this scop
  15. “要么增长要么死”,狼性文化正在毁掉什么?
  16. SpringMVC入门
  17. 树莓派linux led字符设备驱动(原子操作)
  18. CRM系统慢慢转为企业微信SCRM
  19. iOS中ImageIO框架详解与应用分析
  20. 函数的单调性和曲线的凹凸性

热门文章

  1. spring cloud tencent:框架概括及组件详解(一)
  2. JAVA系列之JVM优化
  3. 去哪里下载SSL证书?
  4. SpringBoot2尚硅谷笔记
  5. LintCode 练习【C++】
  6. 基于 WT2003H0语音芯片在扫地机/智能桌游等产品更换语音bin应用设计方案介绍
  7. while(true) Thread.Sleep(XX)我通常是用这种写法,有没有更好的写法或者改进
  8. 获取html元素的高,获取HTML元素的高度jQuery
  9. [RK3288][Android5.1] 调试笔记 --- 根据VIDPID读取不同的rilLib以实现4G模块的适配
  10. 心形源码HTML,纯CSS实现心形加载动画(附源码)