I'm new to the Linux command line and am trying to get to grips with the copy command at the moment.
Can anyone please tell me if it's possible to copy a directory with its subdirectories and associated files to a new directory with a new name, e.g. directory_backup
?
Thanks for any and all help in advance.
Best Answer
You can use
cp
with the-r
(copy recursively) flag and specify the new directory name:In the above command replace the given paths with the real ones.
For example, to copy
stuff
from my home directory to an existing directory namedbackup
and name the new directorystuff-backup
(if this directory already exists, note thatstuff
will be copied into it, not overwrite it), you run:~
is a shortcut for your home directory/home/$USER
or/home/zanna
in my case. You can omit it if the current working directory is your home directory - you can see this from your promptYou can add the
-v
(verbose) flag to makecp
report each copy being performed: