Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am not an advanced Linux user. I have a VPS with 768MB of RAM running CentOS.

I executed the lsof command as root and I see that there is a list of 3000 files. Usually, how many files should be there? My system is getting very slow, so is this list too long?

How do I know which files to keep and which to close?

I have seen that there are multiple copies of the same files with different PIDs. There are many log files in the list that I have not opened. Is this normal?

             total       used       free     shared    buffers     cached
Mem:        104287        492     103794          0          0          0
share|improve this question
    
@DragonLord, why did you re-capitalize lsof? It's a command and it is typed without caps. –  MaxMackie Jul 10 '11 at 13:32
    
I didn't see your edit, sorry. Corrected. –  DragonLord Jul 10 '11 at 13:33
    
No problem, I thought maybe you meant something different than the command. –  MaxMackie Jul 10 '11 at 13:39
add comment

2 Answers

up vote 2 down vote accepted

If you're running slow and you want to make your computer a little faster, you generall shouldn't be worried with the output of lsof. You should be looking at your processes and seeing (1) what they are using and (2) the current levels of your memory and CPU.

If you regularly find processes consuming 70%+ of memory, it might be time for an upgrade.

share|improve this answer
1  
1) How can i find how much total memory i am using 2) So u mean lsof has nothing to do with memory –  Moorage Jul 10 '11 at 13:52
1  
You can use the command "top", which will display an up-to-date list of all processes and what they are using. On the top, you can see your total memory and used memory (in kilobytes). If not, I'm sure CentOS has a task-manager style of GUI. –  MaxMackie Jul 10 '11 at 13:55
    
And lsof simply lists all the open files, it doesn't really let you know what they're doing and how much res sources they are using. –  MaxMackie Jul 10 '11 at 13:55
    
Find total memory with the free -m command. Keep in mind that your total free RAM is the amount listed in "free" plus the amount directly under it on the next line where it says "-/+ buffers/cache". I have 1595 open files on my 512MB RAM 1.2Ghz system and it isn't slow. Open files take a few bytes of memory but don't in and of themselves consume a lot of CPU. –  ultrasawblade Jul 10 '11 at 13:59
    
Thanks for that command @ultrasawblade, I forgot about it. –  MaxMackie Jul 10 '11 at 14:00
show 3 more comments

I wouldn't be worried about the number of open files. As the lsof man page tells, "open file" can be almost any readable file, stream or device, so the unfiltered listing can be long.

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

If no parameters are given to lsof, it lists all open files, including those opened by system daemons - such as the log files you mentioned not having opened. An open file reference consumes very few system resources, so that's no issue in itself.

I've just booted a live Ubuntu 11.04 from a USB stick and lsof shows over 4500 open files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.