Examples not working?

Clean Up Files #

Method 1. Permanently and instantly remove files (danger zone; slow) #

The most direct way to remove files and folder permanently is to use the rm command. This removes the files immediately, which can be a rather slow process if you remove a large number of files. More importantly, using rm is irreversible – there is no way to recover files deleted by mistake.

Method 2. Move files to global scratch for automatic deletion after two weeks (temporarily recoverable; fast) #

An alternative to removing files, is to move them to global scratch. Contrary to removing files, moving files is very fast.

  1. Create your personal global scratch directory, if it doesn’t exist: mkdir -p /wynton/scratch/$USER

  2. Manually move files and folders to your global scratch directory for temporary staging, where they will be automatically deleted after two weeks.

This approach gives you some leeway to undo deletions done by mistake.

Method 3. Clean up files using your Trash folder (recoverable; fast) #

These instructions show how to delete files by moving them to your personal Trash folder, without deleting them permanently. This gives you a second chance if you happen to delete files by mistake. There are tool for recovering files from the Trash folder. Your Trash folder will only be wiped when you explicitly say so. A good strategy is to empty the trash folder later - days or weeks - that will give you a chance to see what files are missing.

Key to working with with the Trash folder, is the trash-cli toolbox available via:

[alice@dev2 ~]$ module load CBI trash-cli

Alt 3a. Manually moving files to Trash folder #

Analogously to using rm to manually remove files (danger; that’s irreversible), you can use the trash tool to move files and folders to your Trash folder. For example, say you want to clean out a specific file and a specific folder, then you can use:

[alice@dev2 ~]$ trash ~/projects/some-file
[alice@dev2 ~]$ trash ~/projects/superduper/
[alice@dev2 ~]$ 

These have now been moved to your Trash folder, which you can see by using trash-list, as in:

[alice@dev2 ~]$ trash-list
2025-12-23 11:07:29 /wynton/home/boblab/alice/projects/some-file
2025-12-23 11:07:33 /wynton/home/boblab/alice/projects/superduper
[alice@dev2 ~]$ 

Alt 3b. Interactively moving files to Trash folder #

If you have a lot of files and folders to delete, or you do not have a good overview where they are and how big they are, you can use the interactive text-based user interface (TUI) ncdu tool to quickly navigate around and move files to the Trash folder. The ncdu tool is available as:

[alice@dev2 ~]$ module load CBI trash-cli ncdu

With this, you can then go to the folder you wish to clean up and run ncdu from there, e.g.

[alice@dev2 ~]$ cd ~/projects/
[alice@dev2 projects]$ ncdu --one-file-system --enable-delete --delete-command "trash --"

This will launch the TUI, and then it starts to scan all the content, which can take several minutes to complete for large folders. When the scan is complete, you can use the TUI to interactive find files and folders to delete.

Now, because the scan takes a long time, we recommend a two step approach; (a) pre-scan files, then (b) navigate and delete files, which you can do as:

[alice@dev2 ~]$ cd ~/projects/
[alice@dev2 projects]$ ncdu --one-file-system -o ncdu.cache

When the scanning is done, there will be a file ncdu.cache in the current directory, which is a database index of all your files and their sizes. From now on, the ncdu TUI will be fast and responsive. Launch it as:

[alice@dev2 projects]$ ncdu -f ncdu.cache --enable-delete --delete-command "trash --"

This will open up a text-based user interface (TUI) displaying the size of files and folders. This TUI makes it easy to navigate in and out of folders and delete files. Press ? to see available keyboard shortcuts. The most useful ones are:

When you delete, you will be asked to confirm with “yes”, “no”, or “don’t ask me again”, after which the files are swiftly moved to your personal Trash folder. Keep deleting files this way until you are done. Press q to exit ncdu when you are ready.

When you’re done, remove the temporary ncdu.cache file;

[alice@dev2 ~]$ rm ncdu.cache

Recovering files from Trash folder #

If you regret some of the deletions in your Trash folder;

[alice@dev2 ~]$ trash-list
2025-12-23 11:07:29 /wynton/home/boblab/alice/projects/some-file
2025-12-23 11:07:33 /wynton/home/boblab/alice/projects/superduper
2025-12-23 11:09:32 /wynton/home/boblab/alice/projects/another-file
[alice@dev2 ~]$ 

you can restore them using trash-restore;

[alice@dev2 ~]$ trash-restore ~/projects/some-file
   0 2025-12-23 11:07:33 /wynton/home/boblab/alice/projects/some-file
What file to restore [0..0]: 0
[alice@dev2 ~]$ 

If there are older versions of the same file, then you will be asked to select which version you wish to restore.

Permanently erase Trash folder (danger zone; slow) #

Before wiping your Trash folder, think twice, because after this step it is impossible to recover the deleted files. A good strategy is to let files sit in your trash folder for some days or weeks and keep doing your regular work. That gives you a chance to detect if you deleted too many files by mistakes.

To permanently remove parts of your Trash folder;

[alice@dev2 ~]$ trash-list
2025-12-23 11:07:29 /wynton/home/boblab/alice/projects/some-file
2025-12-23 11:07:33 /wynton/home/boblab/alice/projects/superduper
2025-12-23 11:09:32 /wynton/home/boblab/alice/projects/another-file
[alice@dev2 ~]$ 

use the trash-rm command, e.g.

[alice@dev2 ~]$ trash-rm ~/projects/superduper/
[alice@dev2 ~]$ 

This results in:

[alice@dev2 ~]$ trash-list
2025-12-23 11:07:33 /wynton/home/boblab/alice/projects/superduper
2025-12-23 11:09:32 /wynton/home/boblab/alice/projects/another-file
[alice@dev2 ~]$ 

That file is now permanently gone. To permanently remove all content of your Trash folder, use the trash-empty command, as in:

[alice@dev2 ~]$ trash-empty
Would empty the following trash directories:
    - /wynton/home/boblab/alice/.local/share/Trash
Proceed? (y/N) 

If you have a lot of files in your Trash folder, this may take several minutes to complete.

It is only when you empty your Trash folder that your disk quota decreases.

Appendix #

The default location of your personal Trash folder is ~/.local/share/Trash/. The above instructions move deleted files to this Trash folder, because we used ncdu ... --delete-command "trash --". Moving files and folders is very fast, regardless of file system. The command trash-empty is slow, much like rm is slow, because it removes the files.