O'Reilly logo

Practical Linux by Bill Ball, John Ray, Michael Turner, M. Drew Streib

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

Copying Files and Directories

The ability to quickly and efficiently copy files and directories is important when using Linux. The following sections show you how to copy single or multiple files and directories.

Copying Files with the cp Command

The cp (copy) command is used to copy files. Use the original filename followed by a new filename on the command line to copy a single file:

$ cp notes notes.old

Use wildcards to copy multiple files to a new location:

$ cp *jpg vacation_pics/

Use the cp command with caution. Unless you use the -i (interactive) command-line option, the cp command overwrites existing files without prompting you first. When you use the -i option, the cp command prompts for a y or n:

 $ cp -i notes.old notes cp: overwrite ...

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