Clean trash in linux

Linux: Command to empty recycle bin

It should work with any linux desktop environment compliant with FreeDesktop.org Trash Specification. On newer versions, the command may be:

rm -rf ~/.local/share/Trash/files 

If not under .local/share, it may be under ~/.Trash

Thanks for your answer, but in .local/share/ I have just «applications» and «mime», no Trash to be found :(.

In case you would like to empty the trash of the currently logged in user:

rm -rf ~/.local/share/Trash/files/* 

After installing the OS if you haven’t deleted/moved anything to Trash from GUI, then the Trash folder under user’s directory wont get created at all. So if you search for Trash directory from command line you wont find. Now lets say you move/delete a file into Trash from GUI, that’s when the directory Trash gets created and is accessible from command-line. If you restore the file or delete the file permanently either from GUI or from command line the Trash folder still stays and is accessible from GUI and command-line.

command line Trash directory:- «/root/.local/share/Trash» under Trash you got two directories again, one with «files» and one with «info». files :- actual data info :- metadata of the data

Checked this on Centos 6.8

Edit :- the files in the thrash can be either deleted from GUI or by getting into /root/.local/share/Trash/files and remove everything

As written, this is useful supplementary information, but doesn’t directly answer the question of what is the command. Can you run this answer to the finish line?

Источник

How to Empty Trash in Ubuntu Linux

Every Linux distribution provides a certain way to empty the trash. You can even empty trash from the terminal. I’ll show you both ways in this quick tutorial.

Method 1: Empty trash using GUI

Some Linux distributions (or more accurately desktop environments) have the trash bin aka the recycle bin on the desktop itself. You can empty the trash from here by right-clicking on it.

In other desktop environments, you can empty the trash from the file manager. Just look for ‘Trash’ icon and right click on it and empty the trash.

That’s how I clean the recycle bin in Ubuntu.

Empty Trash Linux

But the other day I ran in to an issue while emptying trash in Ubuntu. I right clicked on the trash icon and chose Empty Trash option, like I always do. It took some time with a progress bar showing that it was in the process of deleting the files in trash. But it just got stuck at it and I got ended with a frozen Nautilus File manager. I had to kill the process terminal.

But this was painful because the files in trash were still there. And my repeated attempts to delete the trash resulted in same frozen window.

Method 2: Empty trash from terminal in Linux

Honestly, I do not know what caused this issue in the first place. But I do have a solution for you if you too are facing issue in deleting the trash via GUI in Ubuntu.

Читайте также:  What is runlevels in linux

The location of the trash in Ubuntu (and other Linux) is .local/share/Trash/ in your home directory. To empty trash, you can delete the contents of this directory.

Open a terminal and use the following command:

Now, be careful in what you type with rm -rf. You are using the remove command. I trust you that you won’t be deleting any other files or directory. Otherwise recovering deleted files in Linux is a painful job.

You could cd into trash first and then remove the content of the directory.

The above mentioned command is deleting all the files in Trash directory. In other words, it is emptying the trash in command line way. Once you use that command, you’ll see that the Trash has been emptied. If you delete any new files, you should not be having the same freezing Nautilus issue again.

Keep in mind that if you delete files in Linux using the rm command, it doesn’t go to the recycle bin.

Worked for you?

I hope this little tip worked for you and you can empty the trash without any further issue in Ubuntu or any other Linux distribution. Do let me know if you face any issue.

Источник

How to empty trash from Ubuntu terminal

Ubuntu is the widely used desktop operating system in the open-source community. The “Recycle Bin” in Windows and “Trash” in Ubuntu are both utilized to store deleted files and restore them at any time. While working in an Ubuntu, if you delete a file or directory from your system, the system moves that file to the trash folder. You can also empty your system trash to get rid of unwanted folders and files. This operation will also free up some space from your system that can store other crucial data.

Each Linux distribution has its methods for emptying the trash. This article will show you how to empty trash from Ubuntu terminal using two different methods. So let’s start!

How to empty trash from Ubuntu terminal using rm command

Deleting files from GUI trash can take a long time, or it can also cause your computer to hang up. In this situation, removing a single file will be a time-consuming process. Instead of utilizing the Ubuntu GUI, you can use the popular “rm” command for erasing all of the contents present inside the trash in a single go. In the Ubuntu terminal, the “rm” command is used for removing or deleting the files that are no longer required. If you want to empty your system trash using the rm command in the terminal, then follow the below-given procedure:

First of all, we will open up our Ubuntu terminal by pressing “CTRL+ALT+T“; you can also type “terminal” in the application’s search bar as follows:

Files and directories present in a user’s trash are stored in the “.local/share/Trash/” directory. This directory is also known as the “Ubuntu trash directory”. First of all, we will check the content of our trash directory. For that, we will switch our current working directory to the trash directory by utilizing the “cd” command. The “cd” command permits its users to move between directories. You can access the trash directory as “current working directory” by executing this command in your Ubuntu terminal:

Now, write out the “ls” command to list out the content of the trash directory:

Читайте также:  Линукс создание файловой системы

The output declares that we have two directories inside of the trash directory: info and files. Firstly, these directories perform specific background tasks which the GUI trash does not reveal. For instance, you can check out the below-given image of our GUI trash, where GUI trash is not showing “files” or “info” directories, which we retrieved during the execution of the “ls” command:

So, here comes another benefit of emptying trash using the Ubuntu terminal that you can look into what is going on inside the trash directory. The “files” directory contains the deleted files in the trash directory, while “info” contains the path of every deleted file, its permissions, and deletion date. Now, move into the “files” directory”:

Again, execute the “ls” command for listing the deleted files present inside the “files” directory:

Now, the terminal will show the deleted file names, which GUI trash was displaying first hand:

In your Ubuntu terminal, empty your trash at once by executing the below-given “rm” command:

Here, the “r” option indicates “recursive removal“, the “f” option is used to “force the action,” and “*” is used to delete all files:

To confirm that the trash is empty, list out its content:

Now, your Ubuntu terminal will show you nothing:

You can also open up the trash directory using Ubuntu GUI to verify the performed action:

How to empty trash from Ubuntu terminal using trash-cli

Another method to empty trash from your terminal is to use the “trash-cli“. This utility offers you the option to remove the deleted files from the trash. Many popular desktop distributions, including Ubuntu, have this command-line utility in their software repositories. In your Ubuntu terminal, write out below-given command for installing “trash-cli”:

Enter “y/Y” to permit the installation process to continue:

For the demonstration of the working of trash-cli utility, we have deleted some unnecessary files from our system:

The “trash-cli” utility provides five commands which you can use for performing various operations through the terminal, such as:

  • trash-list” command is used to display the trash content.
  • trash-put” command is used to delete specified files or directories from the trash.
  • trash-empty” command is used to delete all files and directories from the trash at once.
  • trash-rm” command is used to delete individual files or directories.
  • restore-trash” command is used to restore a directory or file from the trash.

In our case, we will utilize the “trash-empty” command to empty trash at once:

The error-free output declares that files have been successfully removed from the trash. You can also verify that now the trash is empty or not by opening up the GUI trash:

Conclusion

In Ubuntu, when you delete unnecessary files or folders, it directly goes to the “trash” folder. Emptying trash can free up system space that can be utilized for other important data. If you want to empty your Ubuntu trash, then go for the command-line method because the GUI trash can get hung any time. This article showed how to empty trash from the Ubuntu terminal using the “rm” command and the “trash-cli” utility. Choose your favorite one between these simple methods and try it out on your Ubuntu!

Читайте также:  Команда завершения работы линукс

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.

Источник

Four Ways to Empty the Trash/Recycle Bin in Ubuntu

Empty trash on Ubuntu

When we delete a file or folder from our system, it moves to the Trash folder(Linux) or the Recycle Bin(Windows). Time and again, we need to get rid of these mostly useless files and folders residing in our system trash in order to vacate space for other important data.

In this article, we will describe several ways to empty your system trash, both through the UI and the command line.

We have run the procedure and commands mentioned in this article on a Ubuntu 22.04 and Ubuntu 20.04 system.

Emptying Trash Through the UI

For a person who does not like to use the command line much, the UI provides the following ways to empty your deleted files from Trash:

Method 1: Use Trash-Folder Icon context menu

Open the File Manager from the Activities bar and locate the Trash folder from the list of folders in the left panel. Right-click the Trash folder and select the Empty Trash option from the menu as follows:

Use Trash-Folder Icon context menu

All the files and folders will be removed from your trash can.

Method 2: Use Ubuntu File Manager

Another way of deleting the Trash is to open the Trash folder from the File Manager and then press the Empty button located at the top-right corner of the window.

Empty trash from within Ubuntu File Manager

This way your Trash will be emptied, deleting all the files and folders simultaneously.

You can also right-click an individual item and select the Delete from Trash option in order to permanently remove it from your system but deleting items one by one is a time-consuming task.

Emptying Trash Through the Command Line

Emptying the Trash through the Command Line is a lot easier and faster. Even if you are not a command line pro, the following simple methods will enable you to empty your trash can very easily:

Method 1: Delete files in the Trash folder with the rm command

Open the Linux command line application, the Terminal, through the Ubuntu Dash or through the Ctrl+Alt+T shortcut. The files and folders of a user’s trash are located in that user’s /local/share/Trash folder, files sub-folder. So we need to enter the following commands to reach there:

You can then remove all the files through the following command:

Use rm to empty the trash

You will see that your Trash can is completely emptied.

Method 2: Use empty-trash command

The Trash CLI utility also lets you empty your trash effectively and very easily. First, you need to install it through the following simple command as a root user:

$ sudo apt install trash-cli

You will be asked to provide the password for the root user. When you enter the correct password, the installation process will begin.

You can then enter the following command in order to delete the Trash contents:

Use empty-trash command

In older versions of the utility, you could use the following command to empty the trash:

So you can try whatever works for you and you will be able to see your Trash emptied.

Among the four above-mentioned methods to empty the Trash on a Ubuntu system, you can try whichever method suits you. You will then be able to delete the unwanted files taking system resources and making space for more important files and data.

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

Оцените статью
Adblock
detector