ONE COMMAND A DAY

21.04.2009

3>cp command.

SUMMARY

Copies files from one location to another.cp [options] file1 file2 cp [options] files directory.Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory.

SYNTAX:

-a, –archive

Preserve attributes of original files where possible. The same as -dpr.

-b, –backup

Back up files that would otherwise be overwritten.

-d, –no-dereference

Do not dereference symbolic links; preserve hard-link relationships between source and copy.

-f, –force

Remove existing files in the destination.

-i, –interactive

Prompt before overwriting destination files. On most systems, this flag is turned off by default except for the root user, who is normally prompted before overwriting files.

-l, –link

Make hard links, not copies, of nondirectories.

-p, –preserve

Preserve all information, including owner, group, permissions, and timestamps.

-P, –parents

Preserve intermediate directories in source. The last argument must be the name of an existing directory.


-r, -R, –recursive

Copy directories recursively.

-S backup-suffix, –suffix=backup-suffix

Set suffix to be appended to backup files. This may also be set with the SIMPLE_BACKUP_SUFFIX environment variable. The default is ~. You need to explicitly include a period if you want one before the suffix (for example, specify .bak, not bak).

-s, –symbolic-link

Make symbolic links instead of copying. Source filenames must be absolute.

–sparse=[always|auto|never]

Handle files that have “holes” (are defined as a certain size but have less data). always creates a sparse file, auto creates one if the input file is sparse, and never creates a non-sparse file without holes.

-u, –update

Do not copy a file to an existing destination with the same or newer modification time.

-v, –verbose

Before copying, print the name of each file.

man cp is always there.

EXAMPLES:

Suppose some image is there in a pen drive named corn and you wanna copy an image named abc.png from it to home directory.First we become a super user by doing su – .Then we use the cp command followed by the path name and the source directory.

~]# cp /media/corn/abc.png /home/yevlempy

Advertisements

About yevlempy
A foodie, a cleartripper, a linux geek!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: