Getting ready

We briefly mentioned that temporary files can reside inside the /tmp directory. Often, /tmp is home to short lived files such as lock files or information that can be volatile (destroyed on a power event without any detriment to the system). It is also usually RAM-based, which can offer performance benefits as well, especially if used as part of an inter-process communication system (more on this later in another recipe).

However, it is important to know that other programs can access your file in /tmp, so it should be secured with the sufficient permissions. It should also be given a name that is suitably random so that a filename collision does not occur.

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.