File management is the process of creating, deleting, copying, and moving files or directories for organizing files logically. When doing file management tasks on the command line, awareness of your current working directory is very important. This will help you to give correct absolute or relative pathnames for the immediate task in hand.
cp is used to copy a file or directory from one location to another. The various useful options used with this command are listed in the following table:
Command |
Description |
cp file1 file2 |
Copies file1 with the name file2 in the current directory |
cp file1 file2 /tmp/ |
Copies file1 and file2 with the same name to the /tmp/ directory |
cp file1 /tmp/myfile |