How to copy a folder to another folder in linux

藏色散人
Release: 2023-01-04 14:14:38
Original
29325 people have browsed it

How to copy a folder to another folder in Linux: 1. Open a terminal command window; 2. Copy the folder packageA to the packageB file through the "cp -r /home/packageA /home/packageB" command Just clip it.

How to copy a folder to another folder in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

How to copy a folder to another folder in Linux?

Linux Copy a folder or all the contents under a folder to another folder

1. Copy all the contents of one folder to another folder

cp -r /home/packageA/* /home /cp/packageB/
or
cp -r /home/packageA/. /home/cp/packageB/
These two methods have the same effect.

Method example:
How to copy a folder to another folder in linux

2. Copy one folder to another folder

cp -r /home/packageA /home/packageB

After running the command, there will be the packageA folder under the packageB folder. .

Method example:
How to copy a folder to another folder in linux

3. Delete a folder and all the files under it

rm -rf /home/packageA

  • -r means downward recursion, no matter how many levels of directories there are, delete them all
  • -f means direct forcible deletion without any prompt

Method example:
How to copy a folder to another folder in linux

4. Move a folder to another folder

mv /home/packageA /home/packageB/
or
mv / home/packageA /home/packageB
These two methods have the same effect.

Method example:
How to copy a folder to another folder in linux

5. Move all the contents under one folder to another folder

mv /home/packageA/* /home/packageB/

Method example:
How to copy a folder to another folder in linux

Recommended study: "Linux Video Tutorial"

The above is the detailed content of How to copy a folder to another folder in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!