What temporary files are and why they pile up

Temporary files are scraps of data your programs create while they run — cache from websites you visit, fragments of documents you edit, installation leftovers, crash reports. Your operating system stores these in a dedicated folder so programs can access them quickly without cluttering your main files. The problem is that Windows, macOS, and Linux rarely clean these folders on their own, so they grow until they consume gigabytes of space you could use for actual work.

Most temporary files are safe to delete because they are meant to be temporary. A web browser keeps cached images so pages load faster next time, but if you delete the cache, the browser straightforward downloads them again. A program that crashes may leave behind a recovery file; once you restart the program, that file serves no purpose. The operating system itself creates temporary files during updates and system maintenance, and these can be removed once the task finishes.

The risk of deletion is very low if you follow the steps in this guide, because you are removing only files the system marks as temporary — not your documents, photos, or settings. However, if a program is actively running and using a temporary file, deleting it can cause that program to crash or behave oddly. The solution is straightforward: close all programs before you delete, and the system will not be using those files.

Key Takeaways

  • Temporary files accumulate in system folders over months or years and can consume several gigabytes, but deleting them is safe because the system recreates them as needed.
  • On Windows, use the Disk Cleanup tool or navigate to the Temp folder manually; on macOS, use the Storage settings or a third-party tool like CleanMyMac; on Linux, use the terminal to remove files in /tmp.
  • Close all open programs before deleting temporary files, because running programs may be using those files and could crash if you remove them while they are active.
  • You can schedule automatic cleanup on Windows using Disk Cleanup's scheduled task feature, so temporary files do not accumulate again.

Deleting temporary files on Windows

Windows stores temporary files in two main locations: the system Temp folder and the user Temp folder. The fastest way to clear both is through Disk Cleanup, a built-in tool that identifies temporary files and removes them safely. Open the Start menu, type "Disk Cleanup" and press Enter. The tool will scan your drive and show you a list of file types it can delete — temporary files, recycle bin contents, and others. Check the box next to "Temporary files" and any other categories you want to remove, then click "Delete Files". Windows will ask for confirmation; click "Delete" again and the process completes in seconds.

If Disk Cleanup does not appear or you want more control, you can delete temporary files manually. Open File Explorer and paste this path into the address bar: C:\Users\[YourUsername]\AppData\Local\Temp (replace [YourUsername] with your actual Windows username). Press Enter. You will see a folder full of numbered directories and files — these are all temporary. Select all of them using Ctrl+A, then press Delete. Windows may tell you that some files are in use and cannot be deleted; that is normal. Click "Skip" for those files and delete the rest. The files that are in use will be cleaned up the next time you restart your computer.

For a more thorough cleanup, you can also clear the system-wide Temp folder at C:\Windows\Temp, though this requires administrator permission. The process is the same: navigate to the folder, select all, and delete. Again, Windows will skip files that are currently in use, and that is expected.

Deleting temporary files on macOS

macOS does not have a built-in tool like Disk Cleanup, but you can view and delete temporary files through the Storage settings. Open System Settings (or System Preferences on older versions), click "General", then "Storage". macOS will scan your drive and show you a breakdown of what is using space. Look for a category called "Caches" or "Temporary Files" — the exact name varies by macOS version. Click on it and you will see a list of applications and the cache they have created. You can select individual apps and click "Delete" to clear their cache, or select all and remove everything at once.

If you want to delete temporary files manually, open Finder and press Cmd+Shift+G to open the "Go to Folder" dialog. Paste this path: ~/Library/Caches and press Enter. You will see folders for each process that has created cache files. You can delete entire folders or individual files inside them. Another common location is ~/Library/Saved process State, which holds recovery files from programs that crashed. Deleting this folder is safe and frees up additional space.

For the system-wide temporary folder, paste this path in the "Go to Folder" dialog: /var/tmp. This folder contains temporary files created by the operating system and background processes. You can delete most of what you find here, though some files may be in use and cannot be removed — that is normal and safe to ignore.

Deleting temporary files on Linux

Linux temporary files live in the /tmp directory, which is designed to be cleared regularly. Open a terminal and run this command: rm -rf /tmp/*. This removes all files in the /tmp folder. Linux will skip any files that are currently in use by running programs, so it is safe to run this command even if applications are open (though closing them first is still a good idea).

For user-specific temporary files, you can also clear the ~/.cache directory, which holds process cache similar to macOS. Run: rm -rf ~/.cache/*. This removes cached data for all your applications without affecting your settings or documents.

If you want to automate this cleanup so temporary files do not accumulate, you can add a command to your crontab (a scheduler for automated tasks). Open a terminal and type crontab -e, then add a line like: 0 2 * * * rm -rf /tmp/* ~/.cache/*. This runs the cleanup command at 2 AM every day. Save and exit, and the cleanup will run automatically from then on.

What to do if you cannot delete a file

If Windows or macOS tells you a file is in use and cannot be deleted, it means a program is actively accessing that file right now. The solution is to close all programs and try again. On Windows, you can also restart your computer in Safe Mode, which loads only essential system files and allows you to delete temporary files that would otherwise be locked. To restart in Safe Mode, open the Start menu, hold Shift, and click "Restart". When your computer boots, you will see a menu; select "Safe Mode" and log in. Then run Disk Cleanup or manually delete the Temp folder as described above.

On macOS, restarting your computer usually solves the problem, because most temporary files are released when programs close. If a file still will not delete after restart, it may be a system file that macOS needs to keep. In that case, leave it alone — the Storage settings will not let you delete files the system requires, so if it is showing up as deletable, it is safe to remove.

On Linux, if a file will not delete because it is in use, you can find which process is using it by running: lsof /tmp/filename (replace "filename" with the actual file name). This shows you the program holding the file. Close that program and try deleting again.

Preventing temporary files from building up again

On Windows, you can set up automatic cleanup so you do not have to manually delete temporary files every few months. Open Disk Cleanup as described above, but instead of clicking "Delete Files", click "Options" or "Schedule". Windows will let you set a frequency — daily, weekly, or monthly — and Disk Cleanup will run automatically at that schedule. Most people find that running it monthly is enough to keep temporary files under control without slowing down the computer.

On macOS, the Storage settings can show you which applications are creating the most cache, so you can decide whether to uninstall apps that are hoarding space. You can also enable "Optimize Storage" in System Settings, which automatically removes old files and temporary data over time, though this works best if you have iCloud enabled.

On Linux, adding the cleanup command to your crontab (as described in the Linux section above) is the standard approach. Once set up, it requires no further action and keeps your /tmp and cache folders clean automatically.

How much space you will actually free up

The amount of space temporary files consume varies widely depending on how long your computer has been running and which programs you use. A computer that has been in use for a year or more might have 500 MB to 2 GB of temporary files accumulated. Web browsers are usually the biggest contributors, especially if you visit many sites or watch videos online. Deleting temporary files typically frees up between 500 MB and 5 GB, though some computers may have more or less.

If you are running low on storage space, deleting temporary files is a good first step, but it is usually not enough to solve the problem on its own. You will also want to look at large files you no longer need, old downloads, and duplicate photos. The Storage settings on Windows and macOS can show you which folders and file types are using the most space, so you can prioritize what to delete.

Frequently Asked Questions

Will deleting temporary files slow down my computer or cause programs to crash?

No. Temporary files are meant to be deleted, and your programs will recreate them as needed. The only exception is if you delete temporary files while a program is actively using them — which is why closing all programs first is important. After deletion, programs may run slightly slower the first time you use them (because they need to recreate their cache), but this effect is temporary and usually unnoticeable.

Is it safe to delete files in the Temp folder if I do not recognize what they are?

Yes. If a file is in the Temp folder, it is meant to be temporary. The operating system and programs put files there specifically because they are safe to delete. If you are unsure about a particular file, you can look up its name online to see what created it, but in general, everything in Temp can go.

Do I need to use a third-party cleanup tool, or is the built-in method enough?

The built-in methods (Disk Cleanup on Windows, Storage settings on macOS, terminal commands on Linux) are sufficient for most people. Third-party tools like CCleaner or CleanMyMac offer more features and scheduling options, but they are not necessary. If you prefer simplicity, stick with the built-in tools.

What is the difference between temporary files and the Recycle Bin?

Temporary files are created by programs and the operating system while they run. The Recycle Bin holds files you have deleted but not yet permanently removed. Emptying the Recycle Bin is a separate step from deleting temporary files, though Disk Cleanup on Windows can do both at once.

Can I delete temporary files while my computer is running, or do I have to restart?

You can delete temporary files while your computer is running, as long as you close all programs first. Restarting is not required, though it can help if some temporary files are locked by running processes. On Windows, if you want to delete files that are currently in use, restarting in Safe Mode makes it easier.