Commands can be categorized as harmless or harmful. Most commands fall in the first category, but there is one that is very common and that has been known to produce a lot of damage in the world of computers. The dreaded command is removed, which has wiped out numerous hard drives making precious volumes of data inaccessible. The Linux desktop has borrowed the concept of trash from other desktops and the default action when deleting a file is sending it to the trash. Sending files there is a good practice so that no unintentional removing is done. But this trash is no magic location.
It's just a hidden folder, usually located in home slash dot local. In this lesson we will be looking at the utility tool designed to work with trash. We will install it This will install multiple commands. Let's look at our current directory that contains quite a few files. In order to remove a file, we will use trash file dot txt. There is a separate command for working with a trash we'll rehash.
To reload our past, we list all the trash commands. And the command for listing the trash content is trash list. Here we see the files that are in our trash. It is only showing the files that were put there with the trash command. We can see the date when they have been deleted the hour and the exact location. If we have had multiple times with the same name and path, they would have been listed here, and we could have identified them by the deletion date.
In order to restore a file from trash, we will use the command restored trash It will show us a list of options and ask for a number responding to the file that we want restore. In this case, we will select all meaning we want to restore the JSON file. We open the file and we can see that the content has was not altered in the process. In order to remove all the files in the trash, we use trash and this is the equivalent of doing a demo in the first place. Now if we list the trash again, we see it doesn't have any content. Although the internet is full of these types of jokes, this is actually a serious issue that can cause headaches and wasted time trying to restore the damage caused.
By the way don't type that command it will erase everything. If you've been using room for a long time and can get in the habit of using trash. We suggest adding an alias for remove to actually run the trash command instead. In this case, it's a good idea to pile up stacks of files in trash, then to risk removing a file that we might that might be needed before commit or even removing the whole root partition. Don't do that.