When you run out of disk space or want to remove unnecessary files to increase server security, you may end up deleting a lot of files in a short period of time. If you’re in the Linux terminal / SSH, you’ll likely use the rm command. But this permanently deletes files (excluding data recovery methods) and can result in you having to restore from backup files if you delete the wrong file(s). The solution may already be on your machine.
trash command will send files to your trash can for later review. It’s pre-installed on many Linux operating systems (OSs) and the successor to
It’s important to remember that
gio trash sends files to
~/.local/share/Trash/files instead of
~/.trash, used on cPanel managed servers.
.local/share/Trash directory includes three directories:
infostores deleted files’ original location and deletion time
filesstores deleted files until it’s emptied
expungedmay temporarily hold recently emptied trash
Try our Cloud Server Hosting today and upgrade your disk space anytime without downtime.
Send Files to Trash with gio trash
- Open your terminal
- Move files to
gio trash [FILE1] [FILE2]
- View the trash in
gio list trash://
- Empty the trash can:
gio trash --empty
man gio | grep trash
Below is the
gio trash information:
man gio | grep trash
trash [OPTION...] [LOCATION...] Sends files or directories to the "Trashcan". This can be a different folder depending on where the file is located, and not all file systems support this concept. In the common case that the file lives inside a users home directory, the trash folder is $XDG_DATA_HOME/Trash. Note that moving files to the trash does not free up space on the file system until the "Trashcan" is emptied. If you are interested in deleting a file irreversibly, see the remove command. Inspecting and emptying the "Trashcan" is normally supported by graphical file managers such as nautilus, but you can also see the trash with the command: gio list trash://. Options -f, --force Ignore non-existent and non-deletable files. --empty Empty the trash.
gio help trash for short a short summary.
Delete Files Permanently with gio remove
You can also permanently remove files with the
gio remove [FILE1] [FILE2]
-f option to ignore non-existent and non-deletable files:
gio remove -f [FILE1] [FILE2] [FILE3]
The trash and delete options are also available in popular GUI applications.
What lesser known Linux commands do you know? Let us know in our Community Support Center.