Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to copy files in a linux system

Shulou Source: shulou.com Published: 2022-06-03 02:24:43 09月22日 Update

File copy command cp

Command format:

Cp [- adfilprsu] Source file (source) destination file (destination) cp [option] source1 source2 source3... Directory

Parameter description:

-a: it means archive, and it also means copying all the directories.

-d: if the source file is a connection file (link file), copy the properties of the connection file instead of the file itself

-f: force (force), if there is repetition or other questions, the user will not be asked, but will be forced to copy

-I: if the target file (destination) already exists, it will first ask whether the operation is true when overwriting.

-l: establish a hard connection file (hard link) instead of copying the file itself

-p: copied with the properties of the file instead of using the default properties

-r: recursive replication for directory replication operations

-s: copy into a symbolic link file (symbolic link), that is, a "shortcut" file

-u: if the target file is older than the source file, update the target file

For example:

Copy the file1 from the / test1 directory to the / test3 directory and change the file name to file2, enter the following command:

Cp / test1/file1 / test3/file2

These are the details of how to copy files in linux. Please pay more attention to other related articles!

Tags: File directory target command attribute source file force content parameter that is meaning file name article method more format user question symbol yes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi macOS MySQL vpn