O'Reilly logo

The Linux Command Line by William E. Shotts Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

cp—Copy Files and Directories

The cp command copies files or directories. It can be used two different ways:

cp item1 item2

to copy the single file or directory item1 to file or directory item2 and:

cp item... directory

to copy multiple items (either files or directories) into a directory.

Table 4-4 and Table 4-5 list some of the commonly used options (the short option and the equivalent long option) for cp.

Table 4-4. cp Options

Option

Meaning

-a, --archive

Copy the files and directories and all of their attributes, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy.

-i, --interactive

Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required