cp
FilesBeginner In simulator In real LinuxCopy files and directories
Name: cp = copy
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
cp copies files. The last argument is the destination: if it is an existing directory the sources are copied into it, otherwise the copy gets that name.
Directories need -r. By default the copy belongs to you and gets the current time; -p or -a preserve the original mode, ownership and timestamps.
Syntax
cp [OPTION]... SOURCE... DESTCommon options
| -r / -R / --recursive | Copy directories recursively |
| -a / --archive | Archive: copy recursively, keeping permissions, times, owners and links (for backups) |
| -i / --interactive | Ask before overwriting |
| -n / --no-clobber | Never overwrite an existing file |
| -u / --update | Copy only when the source is newer or the destination is missing |
| -f / --force | If a destination cannot be opened, remove it and try again |
| -v / --verbose | Explain what is being done |
| -p | Preserve mode, ownership and timestamps |
| -l / --link | Make hard links instead of copying |
| -s / --symbolic-link | Make symbolic links instead of copying |
| -L / --dereference | Copy what symbolic links point to |
| -P / --no-dereference | Copy symbolic links as links |
| -t / --target-directory DIR | Copy everything into DIR (the destination first, handy with xargs) |
| -b / --backup | Back up a file before overwriting it, as name~ |