The Vanishing Cache
In Ubuntu (and most Linux distributions), the `/tmp` directory is a crucial scratchpad used by applications to store temporary data—like extracted archives during an installation, or temporary rendering files for a video editor. Modern Ubuntu systems utilize `systemd` to manage background tasks, and by default, `systemd-tmpfiles` runs a regular automated cleanup routine. This routine scans the `/tmp` directory and automatically deletes any files that have not been accessed within a specific timeframe (often 10 days, but sometimes upon every reboot depending on the specific configuration). If you intentionally paused a massive compilation project and left the temporary object files in `/tmp`, this automatic cleanup will silently wipe out all your progress.
Preserving the Scratchpad
To ensure your temporary files survive reboots and time limits, and to stop Ubuntu from automatically deleting data in the `/tmp` directory, you must override the default `systemd-tmpfiles` configuration.
You should never edit the system default files directly, as updates will overwrite them. Instead, you create a custom override. Open your terminal (Ctrl+Alt+T). You need to copy the default temporary file configuration to the local admin directory by typing: sudo cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/. Now, open this new local copy in a text editor with root privileges: sudo nano /etc/tmpfiles.d/tmp.conf. Look through the file for lines beginning with `v /tmp` or `q /tmp`. You will see time limits listed at the end of these lines (like `10d`). To completely disable automatic deletion for that directory, change the time limit (e.g., `10d`) to a single dash character (-). It should look something like `q /tmp 1777 root root -`. Press Ctrl+O to save, Enter to confirm, and Ctrl+X to exit. The cleanup routine will now ignore the `/tmp` directory.