From LQWiki
Contents |
FAQ - Linux problems
Q: Where can I get support for Linux?
Q: Linux feels slow - why?
A: Under some circumstances, people might feel that their Linux system is acting slow. This can be caused by many things, so start by asking yourself, "exactly what is it about the way that the system's behaving right now which makes me say that?"
While distributions have gotten a lot better at automatically optimizing a system and get better with each release, there are some things that through choice, licenses, or simply lack of feedback are not optimal in terms of performance. Here are some things to try to increase the responsiveness of the system:
- Reduce the number of graphical effects in the desktop manager. Animated menus, window effects and other eye candy can easily make a system feel slower. Simply adjust the number of effects in the Gnome or KDE configuration. You can also change the graphical interface for a lighter-weight window manager. If you don't need all the fancy icons and GUI effects provided by Gnome and KDE, try a less resource-intensive window manager such as Fluxbox, Blackbox, IceWM, or XFCE and your desktop will fly, even on outdated 100MHz processors!
- Turn off unneeded services. Most distributions, especially the more popular ones, often come with a lot of services (also called daemons) that you don't really need. Find out which ones you have running, and disable the ones you know you don't need. Common things you can switch off are sendmail, sshd and apache.
- Make sure you have the right video drivers installed and configured. Your graphics performance is strongly influenced by the video drivers you are using. Often there are two sets of drivers for a device, one open source version from the Xorg/XFree86 developers, and one proprietary from the makers of the device or chipset. Usually, a distro will configure open source drivers when it is installed, for philosophical reasons or license issues. The open source drivers usually have good 2D support, but only some 3D functionality. Since no one knows the hardware better than the designers, the proprietary drivers will usually give a fair to large performance boost for 3D. The glxgears program can be a nice, quick indicator on the effect of various configuration options.
- Make sure that disks are properly utilized. If applications load slowly and tend to 'hickup', occationally stopping for a split second and then continuing, check that DMA is enabled using the hdparm tool. If
hdparm -t /dev/hda(on an IDE system) shows 1-6MB/s, this is usually the problem. If it shows 15+, it should be fine. - Add more memory (RAM) to your computer. Although Linux is noted for its ability to run on very old machines that would not be able to support current versions of Windows, it does require a certain amount of ram to do it. To avoid frustration you should use a computer with at least 32Mb RAM to run the command-line, 64Mb RAM for a light-weight graphical interface and 128Mb RAM for Gnome or KDE desktops. To see if you could use more RAM, check with free to see if swap is used. If it is, chances are you could use some more. Also, having more than you strictly need is not a bad thing at all, since Linux will use the rest for cache to drastically speed up disk access and thus improving overall performance.
- Customize your kernel. Some kernel options and patches allows a degree of performance tweaking. On a modern distribution, the benefits of customizing a kernel are small and often imaginary, though it is a neat learning experience. Turn off all the hardware support you don't need, and compile in only what you do need. Apply some experimental patch sets. You probably don't need support for all those obscure network and sound cards, support for ancient hardware or strange filesystems that your computer will never see, or half the other stuff that comes with a stock kernel, so trim them out! Just don't benchmark too accurately, or it might take the thrill out of it :P
Q: Why is Linux using up all my memory?
A: You may notice as you use Linux that a lot of RAM is in use, even when you're not running very many programs. You may be thinking that there are problems with memory leaks, or that your available RAM is being used inefficiently.
To Linux, physical-RAM is a resource that is meant to be used; 100% of it (if possible), all the time (if possible). It is, after all, the only resource that the CPU can access without any waiting at all. If the RAM space isn't needed right now to hold user-programs, Linux will fill it with "buffers" and "cache," which are simply copies of information that has recently been read from the hard-drive... the idea being that if the same information is needed again soon, it won't have to be read twice.
One quick and easy way to find out how much RAM you really have available, though, is to use the command-line utility 'free.' If you are running Gnome, KDE, or another graphical interface, open up a terminal window and type 'free' (without the quotes). Its output looks something like this (edited for brevity):
total used free Mem: 515364 497208 18156 -/+ buffers/cache: 352512 162852 Swap: 497972 176 497796
The significant row in this output is the one labelled -/+ buffers/cache. Notice that out of 512MB of RAM, only 352MB is in use---even though it appears from the first line that 497MB is in use.
Unless you experience significant slowdowns and hard drive activity, it's unlikely that you are experiencing any problems with memory usage. Besides, if you paid good money for all the RAM you have, you might as well be using it---it's no good to you sitting around doing nothing.
Another tool that you may find useful, if you find that a lot of your RAM is being used, is 'top.' Again, from a terminal window or console, type 'top' (without the quotes). You will see a dynamically-updated list of the currently-running programs on your computer. The name of each program is shown on the far right, along with information about how much CPU and memory each program is using. If you press 'M' while 'top' is running, the programs will be shown in decreasing order of memory usage. This may help you to pinpoint what programs are using the most memory. In some cases, those programs can be shut down (if you do not need them running), or configured to use less memory.
But remember this, when you look at "top" ... what really matters, in terms of system performance, is not "how much memory is used," but "what are processes being forced to wait for?" If you see a large number of swaps per second, on a continuous basis, then (and only then) do you have a genuine memory-related problem. And the first response should probably be to purchase more of it. If you see little or no swaps-per-second, the root cause of your system-performance problem is unlikely to be memory.
A2:
Linux likes to use up however much memory you give it. When looking at the face value of the output from programs like top or free it may look like that 512M of memory are being sucked up by only a few applications. As an example my current laptop shows:
Mem: 255500k total, 243660k used, 11840k free, 8680k buffers Swap: 2047984k total, 193680k used, 1854304k free, 44040k cached
Looks like I have used up all my memory and am swapping constantly. In reality I have a large amount of unused application data in swap and 44M of disk cache and 8M of buffers.
To get a better view of the actual memory usage use the command:
free -m
total used free shared buffers cached
Mem: 249 240 9 0 8 43
-/+ buffers/cache: 188 61
Swap: 1999 189 1810
The Mem: section will show the total used including buffers and cached.
The -/+ buffers/cache: section will show a more usable picture of the memory used and free. Buffers and cache are assigned to block devices to speed access, mainly, to hard drives. This space is freed quickly in case an application needs it.
The new 2.6 kernel has an option to help balance the difference between buffers and swap space. vm.swappiness is a kernel parameter that can be tuned to help you adjust how the kernel balances between using block device cache or swapping application memory to disk. The default is 60 and the scale is 0-100. With 0 being use up all cache before swapping applications, and 100 being swap as much as you can before using block device cache. To view this use the command sysctl |grep swappiness to change it use
sysctl -w vm.swappiness=x
where x = the new value.

This page is available under a