Ubuntu – Can’t find the trashcan

trash

I have tried to find my trashcan in order to free some space on the disc.
I have tried the suggested commands How can I empty the trash using terminal? but it seems like I don't have any local folder.
I have tried to list all hidden folders aswell, without finding any local or trash folder.
Are removed files stored somewhere else or how to restore space from the delete files if no trashcan found?

I'm using the terminal.

Best Answer

Pre-Author's Note:

Read through all of this post until you find a satisfactory solution. If not, add a comment telling me I am the worst wannabe in the world. ;) Also, the Trash is not what is taking up all of your space. You do not have a Trash Can created, below are instructions of how to make one. In the terminal, when you delete something it is gone forever, except if you use a recovery program like foremost (see below.)

The Location of the Trash Folder

The trash folder is located at /home/username/.local/share/Trash/. This folder may not be there because of you running from terminal, but keep reading! It is only created once a file has been moved there with a GUI (I'm not 100% about this part, but my LXDE setup only created it when I moved a file to there with the file manager).

Explanation:

Due to @Zacharee1, I have realized the true nature of your question. Thank you for that @Zacharee1. So, a Trash Folder doesn't exist in terminal-land, so you have to either create your own or be OK with having the danger of losing important files forever. Of course, that means that the space usage is not caused by that.

If you have a Trash Folder Already Created:

The items inside the Trash folder will be inside another folder, the items folder. Now, if you want to clear this use two separate commands.

rm /home/username/.local/share/Trash/items/*
rm /home/username/.local/share/Trash/info/*

If You Just Want To Restore Some Files:

Take a look into the forensics program foremost. You can download with

sudo apt-get install foremost

Look at online instructions for using it, use the man page or look below at my extremely limited understanding of how this works. Let me stress that, I just found this and am not knowledgeable in this area, so do not think everything I say is true. On HowToForge (https://www.howtoforge.com/recover-deleted-files-with-foremost) it tells you to run

foremost -t filetype -i /dev/sda1

(Obviously) Replace filetype with the type of file you need to recover. For example, if I wanted to recover pdfs I would do

foremost -t pdf -i /dev/sda1

You will find what is recovered in a folder in the directory you are in called output. If you want to do it multiple times in the same directory, do

foremost -t filetype -T -i /dev/sda1

The extra -T stands for timestamp so the separate outputs won't mess eachother up. For a better understanding of foremost, check out the link provided or do your own research.enter code here

If You Don't Have a Trash Folder Created (And You Want One):

This one is probably you! So, you might have to try two separate things.

The first, and probably most unappealing, is to figuratively make your own Trash folder, set up a timer for it and a system for the files inside to be deleted. You can do this by adding a script to your crontab, which has a timer of 1 month. When the timer gets high enough, BAM,

rm /path/to/trash/*

If you Don't Want to Do It Yourself:

Alright soldier! There are a couple of things you need to know. The crontab. A useful tool which lets you run scripts and commands at startup. We probably will be using this. There is a big flaw to the idea that I just proposed. The timer will it only run if your computer is on. AHA, I've got a (slightly) better idea!

The Slightly Better Idea!

Alright, this will involve a python script and a .txt! Hurray! You will need an empty txt file in the same folder as this one called garbage.txt. So, basically, these are the contents:

#!/usr/bin/env python3
#Comment: This Will Be Called Trash.py

import datetime
import subprocess

with open("garbage.txt", "r+") as garbage:
     x = int(garbage.read(1))
     now = datetime.datetime.now()
     month = now.month
     if month != x:
         subprocess.Popen(['rm', '-rf', '/where/ever/trash/folder/is/)
         subprocess.Popen(['mkdir', '/where/ever/trash/folder/is/'])
         with open("garbage.txt", 'w+') as sadness:
         sadness.write(str(month))

Now then, add this script to the crontab. I'll assume for benefits of the reader that you don't know how to do this. So, create a bash script in the same directory as trash.py. Call it trashshell.sh. In it write:

#!/bin/bash
python3 trash.py

Save that, then type in the command crontab -e to the terminal. Select the terminal editor nano and then write

@reboot sh /path/to/trashshell.sh

Hope this helped!

Optional: An Easy Delete!

Put this:

function trasher(){
     mv "$1" /path/to/trash
}

into your .profile or your .bashrc (Do bashrc if it exists). This will all you to move items to trash with trasher itemname. For example, trasher new.txt

A probably False Idea!

Try recreating a Trash folder in the spots it would be, like the Trash folder, the expunged folder, the files folder, and the info folder. Wait 30 days. This probably won't work!!!

Author's Note:

Do not copy and paste the code I wrote. The indentation is almost 100% messed up, because cannot do formatting on Stack Overflow! Some one teach me please!!! If you made your own trash folder and you're feeling adventurous you can change some stuff up a bit, like the length of the timer.