linux - [Solved-3 Solutions] How to copy folder with files to another folder in Unix/Linux ? - ubuntu - red hat - debian - linux server - linux pc



Linux - Problem :

How to copy folder with files to another folder in Unix/Linux ?

Linux - Solution 1:

The option you're looking for is -R.

cp -R source destination/
click below button to copy the code. By - Linux tutorial - team

If destination doesn't exist, it will be created.

Linux - Solution 2:

  • You are looking for the cp command. You need to change directories so that you are outside of the directory you are trying to copy.
  • If the directory you're copying is called dir1 and you want to copy it to your /home/Pictures folder
cp -r dir1/ ~/Pictures/
click below button to copy the code. By - Linux tutorial - team
  • Linux is case-sensitive and also needs the / after each directory to know that it isn't a file. ~ is a special character in the terminal that automatically evaluates to the current user's home directory.
  • If you need to know what directory you are in, use the command pwd.
  • When you don't know how to use a Linux command, there is a manual page that you can refer to by typing
man [insert command here]
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 3:

Use this code:

$ cp -R SRCFOLDER DESTFOLDER/
click below button to copy the code. By - Linux tutorial - team

Related Searches to - linux - linux tutorial - How to copy folder with files to another folder in Unix/Linux ?