Ubuntu retains the history of accessed files which are then shared between different applications to provide a better user experience. By default, this is enabled, but can be changed if needed.
Also, you can auto-delete temporary files and deleted files that are in the trash for better privacy and optimization.
Here is how to do these in Ubuntu 22.04:
Open Ubuntu dash and click Settings.
From the settings list, select Privacy.
From the Privacy menu, click on File History & Trash.
This opens the file history and trash/temporary files settings.
File History: By default, the file history is turned on. You can change it to off. There is also the default duration for which this file history is retained, the default being forever.
If you would like to lower the retention period while keeping the file history on, select from the drop-down menu for File History Duration. It ranges between 1 day to Forever.
Trash and Temporary Files: This setting is off by default. Enable this auto-deletion for trash and temporary files.
Also, when enabled, trash and temporary files will be auto deleted after 30 days but you can change this period. The drop-down menu for Automatically Delete Period ranges from 1 hour to 30 days.
Choose any of the values as needed.
You can also choose to manually delete these by clicking the Empty Trash or Delete Temporary Files buttons.