tmp

Is it ok to delete the tmp files in Linux to speed up the system and clearing cache memory?

cd /var/tmp
rm -r*
Why do you think deleting files in /var/tmp would speed up the system?
I dont think anything here, Im just asking . I know that clearing cache memory would slow down the system (short term) but , when I use Stacer application to clear the files, the performance of OS would be affected like (Libre office going to be faster when it is in use).
I dont know maybe I just asked stupid question :)
I know that clearing cache memory would slow down the system (short term)...
I'm not sure what you think "cache memory" is. Are you referring to the stuff you see in Android phones, where tools will tell you how much "memory cache" is in use?

I dont know maybe I just asked stupid question :)
The stupid question is the one you don't ask when you want to know.
Are you referring to the stuff you see in Android phones, where tools will tell you how much "memory cache" is in use?


ofcourse not, as I understand the cache memory is what should CPU do and what the instructions that should be done , I mean the CPU bring this info to execute(hit or miss) the processes from the cache memory, but after executing the files may remain useless files and we can clean them, that is what I know about the cache memory in short ofc.
ofcourse not,
ok, ...

as I understand the cache memory is what should CPU do and what the instructions that should be done , I mean the CPU bring this info to execute(hit or miss) the processes from the cache memory, but after executing the files may remain useless files and we can clean them
Not sure how you've gone from CPU instructions and cache memory, to files.

There are some fundamental misunderstandings here, not sure where to begin.

A computer does it's computations in the CPU. The CPU is connected to memory via a memory bus. It doesn't know what a file is, what a network connection is, ... any of that stuff. It only operates on instructions that are stored in memory and on data that's stored in memory or CPU registers. To the hardware, instructions and data the same thing. Give some memory as an instruction, it'll be executed, treat an instruction as data, it'll treat it as such.

Over the years, the CPU speed has grown much faster than memory. But that means the CPU is mostly waiting for data transfers to/from memory. What to do?

One solution is to build memory into the CPU that's quicker to access. Of course, there isn't much of it, so it's just used to keep copies of sections of the real memory behind it. That's a cache. And that idea can be used again with even different faster/smaller memory, hence multilevel caches.

Note, none of this has anything to do with files. A file is a concept used by the operating system, the computer hardware doesn't know about files. Cleaning, clearing, moving, deleting, creating files has no direct consequence for the hardware, besides the time it takes to process them.
Last edited on
A program may "cache" data in files. For example, a browser could store downloaded content in files with the assumption that you will request the same content again and that the cached copy remains valid. If both are true, then there is no need to reload the content over (much slower) network. Another example, a large computation does not keep all the data in RAM all the time (if RAM is smaller than data).

However, whether some part of disk is allocated to data (files) or not does not affect the speed of the disk.
Well, it might, when you have filled the filesystem to brim. Then fragmentation and wear could show.

Note that both /tmp and /var/tmp have sticky bit set. Whoever owns files in them is the only one who can remove them.

Also note that active processes can have files there. Opened files. For example graphical desktop sessions tend to do that. If you wipe their data, what do you expect to happen to those processes?

You could have /tmp in tmpfs. That filesystem uses RAM, not disk. Makes accessing files in /tmp faster too. (But, if /tmp was used because there was not enough RAM, then you can't fit the files in tmpfs that by definition is smaller than RAM.)

Finally, Linux distro probably has service that deletes old&unused files from tmp (periodically or during boot). Configure that service, if you think that programs that do use tmp do not clean up when they are done. It is smarter than blunt rm.
as I understand here ,it not recomended to delete these files in the /var/tmp or in /tmp
this may be led to kill the currenet processes we working in
thanks anyway for your efforts guys :)
Registered users can post here. Sign in or register to post.