[GTALUG] suggestion: naming temp files

Lennart Sorensen lsorense at csclub.uwaterloo.ca
Tue Apr 17 15:01:38 EDT 2018


On Tue, Apr 17, 2018 at 11:43:38AM -0400, D. Hugh Redelmeier via talk wrote:
> I often want temp files.
> 
> Putting them in /tmp means that they will automatically be discarded
> on reboot -- kind of handy.  But it means that they are public: they
> are in a space shared with all other users (if you have other users).
> I consider it a bad habit for that reason.
> 
> Lots of people put temp files in the current directory or in their home 
> directory.  That's what I do.  But then, when you come back a week later, 
> how do you know that this file is garbage?  The best way is to have a 
> naming convention.
> 
> Many people use tmp, tmp2, tmp3 as names.  I find those visually too like 
> real filenames and longer to type than I want.  The names I use are 0, 1, 
> 2, 3.  They are short, distinctive, and unreasonable as permanent 
> filenames.
> 
> You can find the litter you left behind with:
> 	locate -r '/[0-9]$'
> You will notice that the system does have some files that match too so
> you cannot blindly delete all matches.
> 
> To me, it is obvious.  But I didn't think of it.  I copied this from Chris 
> Sturgess almost 30 years ago.

Well on my current Debian system I see a neat variable that looks like this:

XDG_RUNTIME_DIR=/run/user/1000

That is a tmpfs (ram disk) and each user gets their own.

mount shows:
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=404280k,mode=700,uid=1000,gid=1000)

-- 
Len Sorensen


More information about the talk mailing list