Categories: TutorialsUbuntu

How to Empty Trash in Ubuntu from Command Line

When you delete a file in your system, it goes to Trash. Its purpose is to enable the users to restore the files that were deleted accidentally. However, when you empty the trash, all the files are deleted permanently. Emptying the trash on regular basis can help you to free up some disk space on your system. On Linux systems, you can empty trash both using the graphical interface and the command line.

In today’s post, we will show how to empty trash in Ubuntu from the command line (Terminal). This post is intended for the users who prefer the command line for handling their everyday tasks.

Note: The files or directories deleted by the rm command do not go into Trash. Instead, they are permanently removed from the system. Therefore, you should be careful before deleting a file or a directory through the rm command.

Table of Contents

Toggle

Method#1

In this method, we will empty the trash in Ubuntu through the Terminal using the rm command. You can open the Terminal in Ubuntu using the Ctrl+Alt+T shortcut. Let’s get started.

1. Navigate to the directory where trash files are stored. You can do so through the command below:

$ cd ~/.local/share/Trash/files/

2. To view the deleted files that are stored in Trash, run the command below:

$ ls

3. To empty the trash, run the command below:

$ rm -rf *

Make sure you are in the ~/.local/share/Trash/files/ directory before running the above command.

This command will empty the Trash. You can verify this through the command below:

$ ls

Method#2

In this method, we will empty the trash in Ubuntu through the Terminal using the trash-cli utility. You can open the Terminal in Ubuntu using the Ctrl+Alt+T shortcut. Let’s get started.

1. Install trash-cli utility through the command below:

$ sudo apt install trash-cli

Enter the sudo password. After you have entered the password, it will ask if you want to carry on the operation. Hit y and then the Return key.

This will install the trash-cli utility on your Ubuntu system.

2. To view the deleted files that are stored in Trash, run the command below:

$ trash-list

3. To empty the trash using the trash-cli utility, run the command below:

$ trash-empty

This command will empty the trash. You can verify this through the command below:

$ trash-list

This is how you can empty trash in Ubuntu from the command line. This task should be done regularly in order to free up some space in your system. If you find this task tedious, you can automate the procedure of emptying the trash. Visit this post for the complete procedure.

Ubuntu Server Admin

Recent Posts

Advantech AOM-2721 is now Ubuntu Certified

Canonical announces that the Advantech AOM-2721 is officially joining the list of Ubuntu Certified Hardware.…

4 hours ago

Ruby and Rails Performance Roundup: The Backlog Edition

Yet again instead of tweets, a blog post. The backlog got out of hand -…

4 hours ago

How to Deploy OpenProject on Ubuntu VPS

This article provides a guide demonstrating how to deploy OpenProject on Ubuntu VPS. What is…

5 hours ago

Canonical integrates NVIDIA Nemotron 3.5 Lightning with Ubuntu for always-on AI agents

Canonical is pleased to announce that  NVIDIA’s newly introduced NVIDIA Nemotron 3.5 Lightning, an open,…

2 days ago

Xfwl4’s Second Preview Release

I’m pleased to announce the second preview release of xfwl4, Xfce’s Wayland compositor, version 4.21.1.…

2 days ago

How to Install, Secure, and Set Up MySQL on Ubuntu 26.04 LTS

If you have been using an ecommerce store to place online orders or have been…

3 days ago