In my personally opinion the reaping period is way too long, especially for /tmp/ as only few people really have an actual uptime that long but it does make somewhat sense for /var/tmp/ as it currently is "persistent".
In Debian /tmp was backed by the disk. Trixie will come with RAM based /tmp. Update is pushed.
I'm OK with a RAM-backed /tmp getting cleaned every boot simply because that's part of the technical tradeoff, however "on boot" is a bad trigger because its behavior is unreliable and can easily backfire and harm a user.
A classic example would be if the power is interrupted and the computer restarts. Unless the user is present and savvy enough to block it somehow, all of their short-term "throwaway" project/data just got deleted before they actually finished with it.
In other words, the difference to users between "I won't need this after tomorrow" versus "I won't need this by next boot" can be very important.
That's on them.
I use /tmp like this, because I'm lazy and don't want to have to mess with a directory I need to routinely clean up, but I know that if the computer crashes, it's gone. That's on me.
If you don't like this risk, you need to work in persistent storage.
/tmp is for programs' temporary files. Manually using it like this is abusing it. That's fine, it doesn't hurt anyone beside the user doing it, but they need to bear the consequences of doing it.
Which is literally what /var/tmp is and what the parent is advocating for.
However, clearing /tmp at boot is not the greatest technical choice. There's nothing really special about rebooting the system. The idea that files in /tmp are kept around for anywhere between minutes, hours, and days makes for bad policy which systemd-tmpfiles fixes quite elegantly. You shouldn't lose your temp file after 30 seconds because your machine lost power. You should be able to say "files created here are cleared after $short_time of inactivity."
IMO setting the expectation of 'wont survive a reboot' is more consistent. but even that fails with private tmp files that could be tied to ephemeral units
Small you say? The block size in that device is the size of the memory page: 4K by default. That's 8 times the very typical 512b for persistent storage.
I've been bitten many times when trying to start in-memory only VMs with a disk image that measured smaller than available memory only to run out of memory on boot :)
Let's say it's not really for small files. It's for few files. ;)
Or it's useful system behaviour.
To-MAY-to, to-MAH-to.
> […] should exist under a proper /var/{cache,lib} directory.
Are these directories available to regular users like the tmp dirs are?
Yes, system users tend to not have a home directory. But you are fully able to create one for a new system user if this is what you want to do.
You are also able to create all kinds of temporary directories and read-only filesystems for a process (e.g. using systemd) if this is what you want do to.
Yes there is a lot of fragmentation and no real standard, which is a little disappointing, but you sure have options to work with. And these options do not have to involve any legacy-ish filesystem components like /var/tmp that nobody knows the purpose of.
The purpose of /var/tmp is temporary files that should survive a reboot. A potential example where that would make since is a partial download file. It is only needed temporarily but if a reboot happens while the download is in progress, you probably don't want to have to start over.
Also if /tmp is or might be a tmpfs, it is probably desirable to use /var/tmp for larger temporary files that don't fit in RAM.
/var was originally for network booting machines. / is read-only fileshare and /var is for user storage. /home -> /var/home too. It's campus wide workstations installation type of thing.
So, /var/tmp is kind of wrong, and so is /var/log/messages on a laptop, and besides the entire /var is useless on most systems. But it's not a huge waste of resources either, so it's left as it is along the rest of directories under / for years.
/var wasn't originally intended to be a system directory, it's just a variables directory. Almost by definition it's writable.
I have run (Sun) workstations off of NFS, including completely diskless ones. /var was often done on a per-workstation basis.
(I'm actually planning out a diskless HPC cluster that will be deployed in the coming months.)
Honestly, we should probably abandon the hope that we will ever get full universal adoption. It stinks even worse with the half-adoption state we are in now, with some apps writing to those directories and other apps not. If it wasn't for arch Linux folks trying to drive apps to adopt it more, I don't think it would be. Hell, default Debian/Ubuntu still doesn't set XDG_* directory ENVs by default (some flavors do), and some apps ignore the prescribed "if not set, use this default" nonsense in the spec and do what they have always done because it doesn't break compatibility for users.
Part of the spec stinks, too, like the spit between cache/config/data config where the spec has no written rules specified on when anything is expected to be cleaned up and when or what can or should be backed up by the user.
Let's move to containerizing most apps, putting everything in little jails so we don't have to deal with where they want to write to. They can have their own consistent and expected behaviors on their own island. Snapcraft, flatpack, or any of a bunch of other solutions are already available to solve this problem. Don't have to worry about what some app left behind or wrote to your system when it's all contained.
It stinks about half as much as it used to.
> Part of the spec stinks, too, like the spit between cache/config/data config where the spec has no written rules specified on when anything is expected to be cleaned up and when or what can or should be backed up by the user.
Caches don't have to be backed up and can be deleted if you need space. Most people will want to back up configs. What other data should be backed up is a question different people will answer differently. And containers don't solve this.
Otherwise, you're directly heading for a nasty surprise at the worst moment.
Or even go take a look at Nix/NixOS and how they pull it off in another way. They have hermetic isolation down to a science.
Or heck, just look at what Android does, running each app under its own uid/gid, sandboxing 3rd party code, and keeping each app from reading and writing outside their little jails. Can't pollute a user directory or even write to /tmp if your user can't even enumerate it.
Hell, even built a whole sandboxing capability-based security model inside of Fuchsia at Google, which I worked on for 5+ years.
I've been building OSs for 20+ years, between Fuchsia and Android at Google and mobile/embedded products at Texas Instruments, so I hope I know what I'm talking about.
Snaps should not exist. Flatpak and appimage should exist, but should not be used except in extreme cases.
You can have bad judgement for 20+ years easily.
General purpose just means that it's generally useful for a wide range of applications. Android is that. Hell, you can find Android running small appliance server infrastructure and powering IoT devices. Even in 2024, iOS/iPadOS is general purpose at this point, and they have VERY different application models from legacy app models you find on Windows and Linux. You wouldn't not call NixOS a general-purpose OS, and it's like flatpak for literally every process down to things like bash, grep, and vim.
Snaps are fine. Aversion is only from how it was introduced to people in Ubuntu, but conceptionally, is great. cgroups wrapping user processes to box them is not only good for security but also for stability and solving dependency versioning issues. It's brilliant. It's similar to what we did in Fuchsia at Google (we took it to another level because we had no legacy to deal with).
And sure, maybe I have bad judgment on some things. I contributed a ton to GNOME in the early 2000s both code and ideas that were horrible in hindsight, but I'm not still stuck in an outmoded mental model for thinking about my user environment.
AppImages are not containers at all. They bundle up the program data into a single archive but do not do any sandboxing and leave programms to write their user/config/cache files to wherever they would be written without AppImages, i.e. in xdg-basedir locations. As it should be.
> Or even go take a look at Nix/NixOS and how they pull it off in another way. They have hermetic isolation down to a science.
NixOS's packaging is also completely orthagonal to the xdg-basedir spec.
> I've been building OSs for 20+ years, between Fuchsia and Android at Google and mobile/embedded products at Texas Instruments, so I hope I know what I'm talking about.
None of those are desktop operating systems. Please stay away from those with your anti-user opinions.
I love the pith of your comment, but it wasn't very nice.
Like the Churchill quip about being called drunk.
n = 1, but, uh, this is one major reason I don't use Linux. It really bugs me.
Actually AppData can get a bit polluted too.
Typical of our society, we want to make everything someone else's problem.
I guess we deserve some of the SaaS enshittification and it's spending obesity ;-)
Yes, this.
> Typical of our society, we want to make everything someone else's problem.
I don't think that's a fair analogy.
It's more like moving junk from the living room to the attic. I'd prefer to have a clean living room and a messy attic.
> Yes, this.
Like "My Documents" (or "Documents" nowadays)? Now that's some dumping ground.
~/Library also isn't something that is used to be; it was good idea, but mostly ignored. Basically similar idea as XDG_(CONFIG|CACHE|DATA)_DIR.
What's worst, is that many projects ignore any effort to move them to XDG schema. They take the approach, that they always did it this way, it works, so why changing it.
Dot files in my homedir on Sonoma machine:
.CFUserTextEncoding
.DS_Store
.Trash/
.Xauthority
.amt
.android/
.anyconnect
.bash_history
.cache/
.cargo/
.config/
.cups/
.degit/
.deno/
.docker/
.eclipse/
.emacs.d/
.gitconfig
.gitignore_global
.grass7/
.hex/
.homeassistant/
.ipython/
.java.login.config
.jupyter/
.kube/
.lemminx/
.lesshst
.local/
.matplotlib/
.mix/
.mume/
.node/
.notable.json
.npm/
.nvm/
.oh-my-zsh/
.oracle_jre_usage/
.pip/
.profile
.psql_history
.python_history
.rest-client/
.rustup/
.sqitch/
.ssh/
.subversion/
.swiftpm/
.thumbnails/
.viminfo
.vscode/
.wget-hsts
.wine/
.yarn/
.yarnrc
.zcompdump
.zsh_history
.zsh_sessions/
.zshenv
.zshrcYou are supposed to leave them unset if they match the defaults.
Programs ignoring the spec is another matter and should be fixed in those programs not by needlessly bloating the environment of every process with meaningless data.
Things like .git and .ssh not are not meaningless data even though they are not in ~/.config/ssh/ or ~/.local/shared/git.
That being said, all my systems have /var/tmp as just a symlink to /tmp, regardless of what the FHS may have to say about it -- and it's cleaned weekly, not just on reboot.
[0] https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.htm... is the current home, apparently
The XDG base directory spec (https://specifications.freedesktop.org/basedir-spec/basedir-...) was supposed to solve all of this...