The following are some of the flags and arguments that can be used for the cp command:
• -f, –force if an existing destination file cannot be opened, remove it and try again • -i, –interactive prompt before overwrite • -l, –link link files instead of copying. • -p same as –preserve=mode,ownership,timestamps • -R, -r, –recursive copy directories recursively • -s, –symbolic-link make symbolic links instead of copying • -u, –update copy only when the SOURCE file is newer than the destination file or when the destination file is missing • -v, –verbose explain what is being done
copy a file and preserve the file mode, ownership and timestamps, use cp with -p option. [root@linux ~]# cp -p /etc/passwd .
copy file in verbose mode. [root@linux test]# cp -v test.txt linux.txt `test.txt’ -> `linux.txt’
create identical copy of directory (archive). [root@linux test]# cp –a directory new_directory
create an soft link to a file in verbose mode [root@linux test]# cp -vs linux.txt linux-link.txt `test.txt’ -> `link.txt’ |
