cp Linux Command Cheatsheet

4105




cp stands for copy. This command is used to copy files or directories. cp command require at least two filenames in its arguments.

Syntax

cp [OPTION] SourcePath DestinationPath

Options

OptionDescription
-aarchive files
-fforce copy by removing/overriding the destination file (if already present)
-iinteractive mode override (asks before overwrite)
-llinkes the files instead copy
-Lfollows symbolic links
-nno file overwrite, if destination file already exists
-Rrecursive copy (this includes hidden files)
-uupdate mode i.e copy only when source is newer than dest
-vverbose mode i.e prints more information

Example

$ cp file1.txt file2.txt
$ ls
file1.txt	file2.txt