Fedora: delete files from the command line to the recycle bin.

Source: Internet
Author: User

Yesterday, I tried to use the RM command to find the directory where the file to be deleted is located, and then run the RM-V * command, then the deleted data is displayed on the terminal and suddenly stops. Are you sure you want to delete a read-only file? I think there should be no read-only files in my directory? Let's take a closer look. If it is bad, the system prompts whether to delete some files in the downloads directory (downloads is ~ /Directory), I will check again. The files in the documents directory are deleted, and all my learning documents are under this directory, at that time, I was too keen to check whether the CD was in the directory where the file to be deleted is located. how can this problem be solved?
Then I checked the Internet to see if there were any tools for replying. The most talked online was the debugfs tool.
After that, I quit the current user, press CTRL + ALT + F2 to enter the terminal, and log on to the root user.
Run the DF-H command to check whether the partition where the deleted file is located is/dev/sda9, and then unmount the partition.
Use the debugfs command: debugfs/dev/sda9 -- restore-all
But I still haven't completely recovered it. I just restored a few irrelevant files. It may be the reason why I have performed the write operation after the deletion (I created the documents directory immediately after the deletion)
Forget it. I don't want to recover it. Fortunately, there are some backups on the lab computer. Although not all, this is the only thing I can do.
Then I log on to my account again and find that my desktop directory is gone. It seems that I deleted the desktop directory first, as a result, many files in the user folder are displayed on the desktop, which is so awkward. What should I do?
I checked it online and found that I could do this:
In ~ There is a user-dirs.dirs file under the. config directory under the directory, after entering the know how to modify

Xdg_shorttop_dir = "$ home/desktop"
Xdg_download_dir = "$ home/downloads"
Xdg_templates_dir = "$ home/templates"
Xdg_public1__dir = "$ home/Public"
Xdg_documents_dir = "$ home/Documents ents"
Xdg_music_dir = "$ home/music"
Xdg_pictures_dir = "$ home/pictures"
Xdg_videos_dir = "$ home/videos"

Add the desktop directory, log out of the user, and then log on.

To prevent such accidental deletion in the future, I have to find a way to delete all the files to the recycle bin.
Then I went to the Internet to find three methods.
(1) Use trash-CLI:
This software operates the recycle bin under the command line (its directory is ~ /. Local/share/trash/files ).
Installation (in fedora14): Yum-y install trash-cli
Usage: (http://code.google.com/p/trash-cli)
To remove move foo in the trash can, use
$ Trash-put foo
To list all the contents of the trashcan
$ Trash-list
2007-08-30 12:36:00/home/Andrea/foo
2007-08-30 12:39:41/home/Andrea/Bar
12:39:41/home/Andrea/bar2
2007-08-30 12:39:41/home/Andrea/foo
Search for a specific file in the trashcan
$ Trash-list | grep foo
2007-08-30 12:36:00/home/Andrea/foo
2007-08-30 12:39:41/home/Andrea/foo
To restore a trashed File
$ Trash-Restore
0 2007-08-30 12:36:00/home/Andrea/foo
1 2007-08-30 12:39:41/home/Andrea/Bar
2 2007-08-30 12:39:41/home/Andrea/bar2
3 2007-08-30 12:39:41/home/Andrea/foo2
4 2007-08-30 12:39:41/home/Andrea/foo
What file to restore [0 .. 4]: 4
$ Ls foo
Foo
To remove all trashed files
$ Trash-empty
To remove files that have been in the trash more than a given number of days
$ Trash-empty <days>
For example
$ Date
Tue Feb 19 20:26:52 CET 2008
$ Trash-list
2008-02-19 20:11:34/home/Einar/today
2008-02-18 20:11:34/home/Einar/yesterday
2008-02-10 20:11:34/home/Einar/last_week
$ Trash-empty 7
$ Trash-list
2008-02-19 20:11:34/home/Einar/today
2008-02-18 20:11:34/home/Einar/yesterday
$ Trash-empty 1
$ Trash-list
2008-02-19 20:11:34/home/Einar/today
Note: to restore a file, you must use the trash-Restore command in the deleted directory.
(2) Use the gvfs-trash command
Http://www.unix.com/man-page/OpenSolaris/1/gvfs-trash/
The gvfs-trash command can send files to the recycle bin.
You can use "gvfs-trash file path" to delete an object.
Use alias del = gvfs-trash to create an alias.
(3) Use the MV command
Alias del = 'mv-T ~ /. Local/share/trash/files -- backup = t'

The deleted file will be placed in the system recycle bin. Location :~ /. Local/share/trash/Files

This method is equivalent to directly moving the file to the recycle bin, but you cannot use the recovery command in the recycle bin. You can only copy or cut the file.
I prefer the first method.

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.