LinuxMoz

Linux Stuff && Coffee

Linux Copy Directory HowTo

| Comments

How to copy a directory on the Linux / Unix based operating systems from the command line using the cp command (the linux copy command). To copy a directory in Linux we need to use the recursive option for the cp comamnd.

Linux Copy Directory Command

Linux copy directory command:

1
cp -r dir /destination/path/dir

Note, the above cp command uses the -r option which stands for recursive.

In this exmaple you want to move the directory named “dir1” from /tmp to /root”:

1
cp -r /tmp/dir1 /root/dir1

Rename the directory you are copying

If you want to rename the directory you’re copying during the copy process use:

1
cp /tmp/dir1 /root/new-dir-name

Drop me a comment below if this Linux copy directory HowTo helped you out :)

Comments