RM command usage in Linux

Source: Internet
Author: User


MV Mobile, similar to Windows Mobility, similar in usage and CP
You can move directories directly without the-r option;

MV/1/2.TXT/1/3 the name of 2.txt under directory 1 to 3
mv/1/2.txt/3/move 2.txt under directory 1 to directory/3/
If the directory is the same, renamed, if the directory is not the same move, if the directory is different and the name is different also for renaming, such as: MV 2.txt/tmp/3.txt

RM Delete files, remove files

[Root@zabbix_agentd ~]# Rm/tmp/3.txt
Rm:remove regular empty file '/tmp/3.txt '? Y
[Root@zabbix_agentd ~]#

Delete Directory

If there is a file in the directory, it will not be deleted, except by adding-R, recursively deleting all files in the directory

[Root@zabbix_agentd ~]# mkdir file && Touch file/1.txt
[Root@zabbix_agentd ~]# RM file/
Rm:cannot remove ' file/': is a directory
[Root@zabbix_agentd ~]# rmdir file/
rmdir:failed to remove ' file/': Directory not empty
[Root@zabbix_agentd ~]#

-R Recursive Delete, do not use alias-I, do not prompt to delete
[Root@zabbix_agentd ~]# \rm-r file/

RM-RF/Can be performed before Red Hat 6, after which you will need to add--no-preserve-root, do not protect stub, this operation would remove the system

[Root@zabbix_agentd ~]# RM-RF/
Rm:it is dangerous to operate recursively on '/'
Rm:use--no-preserve-root to override this failsafe

If RM-RF/* Deletes the file under the root, not the root

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.