Create, copy, cut, rename, empty, and delete commands for folders under Linux

Source: Internet
Author: User

In the home directory there is a wwwroot directory, wwwroot under the Sinozzz directory, that is/home/wwwroot/sinozzz

First, Directory creation

Create a new sinozzz123 folder under the/home/wwwroot directory

Mkdir/home/wwwroot/sinozzz123

Second, directory replication

1. Copy the files and folders inside the/home/wwwroot/sinozzz into the home/wwwroot/sinozzz123 directory

cp-rf/home/wwwroot/sinozzz/*/home/wwwroot/sinozzz123

2. Copy the folders and files under the/home/wwwroot/sinozzz123/abc/to the home/wwwroot/sinozzz123 directory

cp-rf/home/wwwroot/sinozzz123/abc/*/home/wwwroot/sinozzz123

3. Copy the/home/wwwroot/sinozzz directory to the/home/wwwroot/sinozzz123 directory, that is, sinozzz copy into a sinozzz123 subdirectory, into/home/wwwroot/ Path of the Sinozzz123/sinozzz

Cp-rf/home/wwwroot/sinozzz/home/wwwroot/sinozzz123

Iii.. Catalog Cut

1. Use the MV command to cut the file.

If you need to cut the 1.mp3 file in the/home/wwwroot/sinozzz123/music/directory into the/HOME/WWWROOT/SINOZZZ123/ABC directory, execute the following command:

# MV/HOME/WWWROOT/SINOZZZ123/MUSIC/1.MP3/HOME/WWWROOT/SINOZZZ123/ABC

2. Use the MV command to cut the folder.

Cut the/home/wwwroot/sinozzz123/soft folder into the/HOME/WWWROOT/SINOZZZ123/ABC directory

# MV/HOME/WWWROOT/SINOZZZ123/SOFT/HOME/WWWROOT/SINOZZZ123/ABC

3. Use the MV command to cut folders and files

Cut the folders and files under the/home/wwwroot/sinozzz123/photo/to the/HOME/WWWROOT/SINOZZZ123/ABC directory

# mv/home/wwwroot/sinozzz123/photo/*/HOME/WWWROOT/SINOZZZ123/ABC

Iv. Directory renaming

Under Linux, moving files and renaming is the same command, MV (meaning of Move)

Command: MV source file name destination file name

1. Rename the/home/wwwroot/sinozzz123/index.htm to/home/wwwroot/sinozzz123/index.html

# mv/home/wwwroot/sinozzz123/index.htm/home/wwwroot/sinozzz123/index.html

2. Rename the/home/wwwroot/sinozzz123 directory to/home/wwwroot/sinozzz456

# mv/home/wwwroot/sinozzz123/home/wwwroot/sinozzz456

V. Directory deletion

Linux Delete directory is very simple, many people are still accustomed to use rmdir, but once the directory is not empty, it fell into deep distress, now use the RM-RF command.

Direct RM is available, but add two parameters-rf

That is: RM-RF directory name

-R is recursive down, no matter how many levels of directory, delete

-F is directly forcibly deleted, without any hint of meaning

1. Delete File Usage instances:

Rm-f/home/wwwroot/sinozzz456/index.html

This file will be forcibly deleted/home/wwwroot/sinozzz456/index.html

2. Clear the folder instance:

rm-rf/home/wwwroot/sinozzz456/abc/*

All files, folders, and/HOME/WWWROOT/SINOZZZ456/ABC directories in the/HOME/WWWROOT/SINOZZZ456/ABC directory will be forcibly deleted.

3. Delete the folder instance:

rm-rf/home/wwwroot/sinozzz456

Will force the deletion of the/home/wwwroot/sinozzz456 directory and all files and folders under it

To be reminded: Use this RM-RF with extreme caution, Linux does not have a recycle Bin

Of course, RM has more parameters and usage, and man RM can view the

If you are operating under the/home/wwwroot/directory, you can omit the/home/wwwroot/part of each command


Create, copy, cut, rename, empty, and delete commands for folders under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.