O'Reilly logo

Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition by Matthew Helmke

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 a File with cp

Copying works similarly to moving, but retains the original in the original location. To copy a file named filename from ~/documents to ~/archive, use this command:

matthew@seymour:~$ cp documents/filename archive

Notice that the filename is not included in the destination. The destination here must be an existing directory. If it is not, the file is renamed to the term used. Some examples will make this clear.

To copy a file that is in my current directory I could use the following, and it will work exactly the same as mv, except that both files will exist afterward:

matthew@seymour:~$ cp oldfilename newfilename

To rename a file as I copy it from ~/documents to ~/archive, I could use this:

matthew@seymour:~$  cp documents/oldfilename ...

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