What is cp in linux system

little bottle
Release: 2019-05-30 14:54:53
Original
4752 people have browsed it

There are many commands in Linux that have their own unique meanings, including the cp command, one of the most commonly used commands in Linux systems that I will talk about below.

What is cp in linux system

The cp command is used to copy files or directories and is one of the most commonly used commands in Linux systems.

Generally, the shell will set an alias. When copying a file from the command line, if the target file already exists, it will ask whether to overwrite it, regardless of whether you use the -i parameter.

But if cp is executed in a shell script, it will not ask whether to overwrite without the -i parameter. This shows that command line and shell scripts are executed somewhat differently.

1. Command format:

Usage:

cp [option]... [-T] source destination

Or: cp [option]... source. .. Directory

Or: cp [option]... -t Directory Source...

2. Command function:

Copy the source file to the target file, or copy multiple source files to the target directory.

3. Command parameters:

-a, --archive Equal to -dR --preserve=all

--backup[=CONTROL Create a backup for each existing target file

-b Similar to --backup but does not accept parameters

--copy-contents In recursive processing, special file contents are copied

-d Equivalent to --no-dereference --preserve =links

-f, --force If the target file cannot be opened, remove it and try again (there is no need to select this option when the -n option

exists)

-i, --interactive Ask before overwriting (disables previous -n option)

-H Follow command line symbolic links in source files

-l, --link Link files without copying

-L, --dereference Always follow symbolic links

-n, --no-clobber Do not overwrite existing files (disables the previous -i option )

-P, --no-dereference Do not follow symbolic links in source files

-p Equivalent to --preserve=mode, ownership, timestamp

-- preserve[=attribute list Preserves the specified attributes (default: mode, ownership, timestamp), if

It is possible to maintain additional attributes: environment, link, xattr, etc.

-R, -r, --recursive Copy the directory and all items in the directory

The above is the detailed content of What is cp in linux system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template