backup. The command requires several parameters: the
name of the file you want to copy and where you want to
copy it to and the name of the copy. When copying the
contents of a folder, you need to use the -r, or recursive,
flag. You can use the cp command as follows:
$ cp sydney.txt
sydney2.txt
Copies a file called sydney.txt from
the current directory and names the
copy sydney2.txt
$ cp
/home/username/
sydney.txt
~/sydney2.txt
Copies a file as described above but
using the full path and the home
directory path
$ cp -r folder
folder.old
Copies a folder
mv
The mv command allows you to move a file or folder
from one directory to another, and it is also used to
rename files or folders from the command line, as BASH
does not have a dedicated renaming function. The mv
command takes a source and destination, just as cp
does. You can use the -i flag to create an interactive
option prompt when moving files that exist at the
destination. The -f flag forces the move and overwrites
any files at the destination. Wildcards also work to select
multiple source files or directories. You can use the mv
command as follows:
$ mv caleb.txt
calebfinal.txt
Renames a file called caleb.txt to
calebfinal.txt
$ mv
/home/username/cal
Renames a file as described above
but using full paths