Online Linux Terminal Logo
OnlineLinuxTerminal
文件操作CLI Manual

$cp

Copy files and directories to a destination path.

命令语法POSIX Standard
cp [OPTIONS] SOURCE... DEST
Linux 社区2.4k 在线

与真实 Linux 用户交流,学习常用命令并免费获取精美速查表 PDF。

在交互式终端沙盒中实时运行

无需安装的客户端实时仿真环境。

在全屏终端工作区中打开 ↗
bash — terminal

概述与工作原理

`cp` (Copy) duplicates files or folders from a source to a destination. It supports copying single files, multiple files into target directories, and recursive directory tree replication with preservation of file modes and timestamps.

常用参数与选项说明

Flag / OptionDescription
-r, -RCopy directories and their contents recursively.
-pPreserve specified attributes like mode, ownership, and timestamps.
-aArchive mode (same as -dR --preserve=all) for exact backups.
-uCopy only when the SOURCE file is newer than the destination file.
-vVerbose output showing files as they are copied.

实际生产案例与代码范例

#1Create a backup copy of a configuration file
cp welcome.txt welcome.txt.bak && ls -l

Duplicates welcome.txt into welcome.txt.bak in the same directory.