Deleting temporary files from system

Hello,
I am currently using Windows and I am using Manjaro in my VM ware. While exporting files from Manjaro to windows I noticed that my system drive just exhausted. I have to clear my temporary file by going to run and typing %temp%. But I am planning to switch to Manjaro. Is there any way out in Manjaro like windows have %temp% to remove temporary file? I am asking for KDE plasma and GNOME.
Thanks & Regards

Welcome to the forum!

Temporary files are kept in /tmp and are automatically deleted either on shutdown — given that /tmp is a filesystem in virtual memory — or every 24 hours if the system remains up that long.

They are commonly also only very small files — usually just a few KiB, sometimes a few MiB — so that cannot be filling up your drive. Windows on the other hand is terrible in how it handles temporary files, so I suspect the problem lies in Windows.

1 Like

Thank you for the solution. I was not aware of /tmp files. Will take care of it.

1 Like

You cannot go and manually delete everything in there. Some of those files are needed by running processes.

1 Like

Okay, so the best way is to wait for sometime or for next time system turn on. It will automatically delete it. Right?

Yes, the directory will be empty upon the next boot, but right away some processes will create small files in there of only a few KiB worth. Do not delete those files. The system will automatically delete all temporary files that have not been accessed in the last 24 hours.

Besides, GNU/Linux is very well-behaved in that regard. Every program that creates temporary files will delete those files again when the program exits.

Your problem lies not with GNU/Linux, it lies with Windows.

Got it. Thanks.

Regarding system temporary files, it is taken care of for the user.


The rest is for educational purposes.

The systemd service is systemd-tmpfiles.

List systemd timers. Should see: “systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service”

systemctl list-timers --no-pager

Show the service (default) and timer config files

systemctl cat systemd-tmpfiles-clean.{service,timer} --no-pager

# same as the above, except no bash brace expansion
systemctl cat systemd-tmpfiles-clean  --no-pager
systemctl cat systemd-tmpfiles-clean.timer --no-pager

Show journal messages associated with the service systemd-tmpfiles-clean

journalctl -b -u systemd-tmpfiles-clean

The timer config file contains:

OnBootSec=15min    
OnUnitActiveSec=1d 

The first is relative to boot - 15 minutes after boot. The second is relative to OnBootSec - every 24 hours.

The service config file contains:

ExecStart=systemd-tmpfiles --clean

Where does a linux user find documentation for these keywords. Start by looking at the most
important systemd man page, systemd.directives. It’s an index of systemd’s directives (keywords), so you can find the real man page.

Learn everything you can about systemd and its’ utilities.

It’s better to forget about those Windows habits, there are a lot of things in the Linux world that don’t need to be done.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.