Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
The memory currently used for buffers and cache (as shown in the first line of the output from free) can be considered "almost free" memory, i.e., memory that could be immediately used to satisfy requests from a process for additional memory. The "cached" memory holds data that was recently read from or written to a block device and is kept around because (a) there is some chance that this data might be accessed again, and (b) keeping track of what is there costs almost nothing. The "buffers" memory is similar, but is used for file system metadata and data that is "in flight" to or from a block device, and the amount of memory allocated for that purpose is highly flexible.
So, the free command shows two calculations for "used" and "free" memory. In the first line, the amount shown for "buffers" and "cached" is included in the "used" total. In the second line, that memory is considered "free", i.e., subtracted from the previous "used" amount and added to the previous "free" amount.
Swap is virtual memory. It is disk-storage that gets 'swapped' in and out of real memory by the kernel on an as-needed basis. Strategically, it is a last resort for allocation of memory, since it requires the relatively slow access to disk hardware. Showing that your system has never used swap memory means that your system has as much or more real memory than required for the applications you are using (a good thing).
Swap space is space on disk used as secondary storage when there is high demand for physical RAM. If you have plenty of RAM on your machine, it is normal to see little or no use of swap space, but if your system is running for a long time there will almost always be a few megabytes of memory pages that some process allocated when the machine was booted and never referenced since then, and those pages will eventually end up in swap.
The other time that swap space is used is if you use the "hibernate" (suspend to disk) feature of the OS. Then, all of the allocated non-cache pages of physical memory get saved in the swap space so that they can be reloaded when the machine is restarted. For that to work, you need swap space (which could be one or more partitions and/or files) that is at least as large as physical memory. If you're not using hibernate, then swap space of 1X to 2X physical memory (but not more than 2GB to 4GB) is a useful safety net for that time you're editing a couple of huge image files and need a lot more memory than usual. (A system that is actually using more swap than that would be so slowed by paging as to be almost useless, though there are undoubtedly some special use cases where huge amounts of swap make sense.)
If this area is not ever used , allocated ram memory is waste.
am i right ?
A 2GB swap space, that is never needed, is a good safety net for an ordinary Linux system. Just in case some process uses an unexpected large amount of ram, you will have just a slow down rather than a failure.
Yes, that 2GB of disk space is probably "wasted". How big is your hard drive? With an obsolete 80GB hard drive, I'd be a little upset about wasting 2GB. I have a fairly old 500GB hard drive, so wasting 2GB of it doesn't bother me at all. I have no clue what size hard drive you have, so I don't know whether wasting 2GB of it should bother you.
All the 1x ram or 2x ram nonsense frequently suggested was always an unsound "rule of thumb" to apply in cases where you have no clue how much swap you need. But really the amount of swap you might need has no real correlation with the amount of ram. Unless your hard drive is tiny, I think 2GB is a good swap size for an ordinary Linux system, regardless of ram size.