Home >Operation and Maintenance >Linux Operation and Maintenance >What is the meaning of Linux cp command parameters

What is the meaning of Linux cp command parameters

WBOY
WBOYforward
2023-05-18 10:19:181554browse

cp (Copy files or directories)

[root@linux ~]# cp [-adfilprsu] 来源档(source) 目的檔(destination)
[root@linux ~]# cp [options] source1 source2 source3 …. directory

Parameters:
-a: Equivalent to -pdr;
-d: If the source file is the attribute of the link file ( link file), copy the link file attributes rather than the file itself;
-f: means force. If there are duplications or other questions, the user will not be asked and the copy will be forced;
- i: If the destination file (destination) already exists, it will first ask whether it is really an action when overwriting!
-l: Create a hard link link file instead of copying the file itself;
-p: Copy the file together with its attributes instead of using the default attributes;
-r : Recursive continuous copy, used for directory copy behavior;
-s: Copy into a symbolic link file (symbolic link), that is, a "shortcut" file;

-u: If the destination is older than the source Just updated the destination!
Finally, it should be noted that if there are more than two source files, the last destination file must be a "directory"!

Do not prompt for overwrite information?

\cp -r -f source target

The cp command will not prompt overwrite? by default, but the -i option of cp will prompt it, and the general Linux startup file~/ The .bashrc will name cp as

alias cp='cp -i'

. In this way, entering the cp command under Linux actually runs cp -i. Adding a "\" symbol means that the cp command will not be used this time. Run as alias (cp -i).

The above is the detailed content of What is the meaning of Linux cp command parameters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete