Linux Delete files and directories and restore details

Source: Internet
Author: User
Tags touch touch command

You've learned to use the Touch command to create a file, and to use the mkdir command to create a directory Tigger.

Now, you need to learn how to delete files and directories. Using the RM command to delete files and directories is a straightforward process. Please refer to RM Specification page for details. Options for deleting files and directories include:

»-i-interaction. Prompt you to confirm the deletion. This option will help you avoid accidentally deleting files.
»-f-coercion. Instead of interactive mode, delete files without prompting. Unless you know what you're doing, it's not always advisable to use this option.
»-v-details. Displays the progress of the file deletion.
»-r-recursion. A directory and all of its files and subdirectories will be deleted.
To delete a file piglet.txt using the RM command, type:

RM piglet.txt

Warning
Once the file or directory is deleted using the RM command, it is gone forever.

Using the-I option will give you another chance to decide if you really want to delete the file.

Rm-i Piglet.txt
RM: Do you want to delete the general file ' Piglet.txt '?

You can also use the wildcard "*" to delete files, but you have to be careful as it is easy to delete files that you do not want to delete.

To use wildcards to delete files, you can type:

RM pig*

The above command deletes all files in the directory that are pig letters.

You can also use the RM command to delete multiple files. For example:

RM Piglet.txt Sneakers.txt

You can use RmDir to delete a directory (such as: RmDir foo), but the directory must be an empty directory. To remove a directory using RM, you must specify the-r option.

For example, if you want to delete a directory Tigger recursively, you can type:

Rm-r Tigger

If you want to combine options, such as forcing a recursive deletion, you can type:

RM-RF Tigger

Another command to delete a directory that is more secure than using RM is the RMDIR command. This command does not allow you to use recursive deletion, so you cannot delete the directory containing the files.

Warning
The RM command can remove your entire file system! If you log in as root, then type this simple command: RM-RF/, you're in a lot of trouble; This command will recursively delete everything on your system.

Read RmDir's manual page (man rmdir) For more information on this command


Linux file mistakenly delete recovery operation

First, use the SECURECRT remote to the operating system, view the current system version number, and file system format

Second, in order to facilitate this experiment, we create a new document.

Third, to perform the delete operation,

IV. application, System self-tooling Debugfs to repair

V. Open, the partition where the file is just deleted

Use the LS plus-d parameter to display the directory where the file was just deleted

Seven, the display has <> the angle bracket is we are looking for the file inode number executes logdump–i <393289>

Eight, after executing the command, display a screen of information, we need the following line, and to remember that the next value

Nine, Exit Debugfs

Ten, execute the following command

11, the above results indicate the success of the recovery we look at the/tmp directory in the end there is no

12, the TMP directory has we show it,


Delete garbled files under Linux


Modify or delete Linux garbled files according to the Inode

1. Create Test files:
Touch 1? Txt

2. Query Inode:
[Oracle@test]$ Ll-i
Total 14694452
17956913-rw-r--r--1 Oracle Oinstall 0 18 20:24 1? Txt

3. Modify the test file name:
Find. -inum 17956913-exec mv {} file.txt;

4. Check the result of the change
[Oracle@test]$ LL
Total 14694452
....
-rw-r--r--1 Oracle oinstall 0 20:24 file.txt

Record: Delete garbled files to use Find. -inum 17956913-exec rm {};

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.