Many operating systems and even some apps use temporary files as a means of storing data for a certain amount of time. In many cases, these files are deleted as soon as you close the program or restart the operating system (OS). Other times, temporary files are deleted after a set amount of time has passed. Sometimes, these files aren't automatically purged or deleted at all.
Temporary Files in Windows
All versions of the Windows OS use temporary files to some extent. The earliest versions of Microsoft Windows stored temporary data in the "C:\Windows\Temp" directory, but this can be difficult to find for novice users. In the latest versions - including Windows 7, 8, 10, and 11, the development team has made it easier to locate temporary files. Simply click on the Start menu and type "%temp%" to immediately open the directory in Windows Explorer.
However, this mainly applies to temp files created by Windows. Individual apps and programs might use a different directory altogether. In this case, the most common location is another folder within the Programs directory, but it's generally up to the software developers to designate a specific directory for temporary data.
Temporary Files in Mac
Although the latest versions of Windows do take some steps to purge temporary files, they're not nearly as effective as macOS. This UNIX-based operating system was specifically designed to perform automatic maintenance at certain intervals, so temporary files will be deleted on a consistent basis without manual intervention.
If you do want to access the temporary data that is currently stored on your Mac, you can do so by clicking "Go," navigating to "Utilities," and selecting the Terminal application. It's also accessible via the Finder. Next, type "open /tmp" within the Terminal app, without the quotation marks, and press "Enter." The Finder will immediately navigate to your temporary folder.
Temporary Files in Linux
Linux-based operating systems tend to use temporary files in a different manner altogether. Instead of relying on a single, standard temporary directory, temporary folders, which are generally labeled as "tmp," are associated with individual programs and utilities. As such, the temporary folders - and the temporary data within - are typically found in the program's installation folder.
In some cases, individual applications might use the "/var/cache/" directory to store temp files. Temporary data related to the Linux OS may also be kept in the "/var/" directory, but this is primarily reserved for temp data that isn't deleted when the system is rebooted.
Is it Safe to Delete Temporary Files?
Generally speaking, modern operating systems and programs do a great job of minimizing and maintaining temporary data. If you find that your OS is accumulating an excess amount of temporary data in any of the folders and directories mentioned above, it's generally okay to delete the files found therein. Individual programs, however, might use temporary files to store custom settings and options. Removing these files could cause these apps to revert to their default state, but it shouldn't affect their overall functionality or their ability to load properly in the first place.
You may read more about temporary files in Wikipedia: Temporary file.