Introduction to the Linux cp command parameters

  • 2020-05-09 19:50:39
  • OfStack

cp (copying files or directories)


[root@linux ~]# cp [-adfilprsu]  The source file (source)  Objective to � (destination)
[root@linux ~]# cp [options] source1 source2 source3  ... . directory

Parameters:
-a: equivalent to -pdr;
-d: if the source file is the properties of the linked file (link file), copy the properties of the linked file instead of the file itself;
-f: for the purpose of mandatory (force), if there is a repetition or other questions, the user will not be asked, but is forced to copy;
-i: if the target copy (destination) already exists, the overwrite will ask if the action is real!
-l: create hard links (hard link) rather than copy the files themselves;
-p: copy along with the file property 1, instead of using the default property;
-r: recursive continuous replication for directory replication;
-s: copy into a symbolic link file (symbolic link), also known as a "shortcut" file;

-u: update destination if destination is older than source!
Finally, if there are more than two source files, the last destination file must be a "directory"!

Not prompted for coverage information.


\cp -R -f source target

By default, the cp command will not prompt overwrite? cp, but the -i option for cp will prompt, and the 1 Linux startup file ~/.bashrc will name cp


alias cp='cp -i'

So the cp command under Linux actually runs cp-i, plus a "\" sign to make the cp command run without an alias (cp-i).


Related articles: