Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I rarely use Trash. (I use Shift+Delete) But recently, I found I often remove some important files by mistake. So I want to use Trash now.

But as we all know, my limited disk space will be filled with files in Trash if I don't clear the Trash by myself.

So I have an idea. I want to move my Trash into /tmp , so that I won't have to clear it myself.

I wrote some code into ~/.bash_profile like this:

mkdir /tmp/my-trash

I made a symbol link pointing to /tmp/my-trash. I removed the directory ~/.local/share/Trash/files, and moved my symbol link into ~/.local/share/Trash, and renamed it into files.

But it doesn't work! I put some files into /tmp/my-trash, clicked the Trash icon in the lower right corner. But there is nothing. I chose a file and pressed Delete , but it said that it cannot move the file into Trash and asked me to permanent remove the file.

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

Why don't you use another approach:

Crontab combined with command line client for trash

  • Install trash-cli Install trash-cli / sudo apt-get install trash-cli, which will allow you to control your trash folder from shell.
  • Open your crontab with crontab -e in shell (will open your default shell editor chosen by select-editor)
  • Add an entry like

    # In your crontab
    @reboot    empty-trash > /dev/null
    

Now on every reboot your trash will be emptied. You can specify other times to empty trash. Just look at a crontab tutorial to learn how.


Of course you can use your link approach from above just as well. The problem with your approach was that you copied the link. Most likely that broke the link. Also your newly created folder /tmp/my-trash/ didn't have the proper directory structure of a trash folder specified by the free desktop standard. That can be remedied in the following way: (FIRST empty the trash manually)

mv -r ~/.local/share/Trash/ ~/.trashcopy
cp -r ~/.trashcopy /tmp/.trashcopy
ln -s /tmp/.trashcopy ~/.local/share/Trash

To make that change persistent, you have to include the following line in your user's crontab with crontab -e or just the part without @reboot in your ~/.bashrc.

@reboot  rm -r ~/,local/share/Trash; cp -r ~/.trashcopy /tmp/.trashcopy; ln -s /tmp/.trashcopy ~/.local/share/Trash
share|improve this answer
    
Oh. Maybe I could also put some code into .bash_profile to clear Trash when login.Like rm -rf ~/.local/share/Trash/files/* –  Ibe Kaoet Aug 7 '11 at 9:45
    
+1 for the select-editor command. I couldn't find out how do I change the default editor! –  Rafał Cieślak Aug 7 '11 at 9:48
1  
@Mr.Phone .bashrc is sourced whenever you start a new shell session. That is for instance whenever you open a gnome-terminal, login to one of your ttys or another program opens a shell. So that would be a bit too often for my taste. Also rm does not delete the file information in your trash and will lead to corruption. Use empty-trash, that's simpler and more secure. –  con-f-use Aug 7 '11 at 11:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.