Understand Linux-based RAM and it’s cache

Linux Operating System that powered by Linux kernel have an advanced disk cache algorithm that used to store frequently access data from Hard disk.

This is to explain why some Linux server’s RAM still getting high memory usage even you upgrade your RAM.

To find out how much memory using by the Linux-based server, you may use the linux command “free” to track it. To get the detailed/actual memory usage, you may run the following command from your Linux box.

free -m

You should get some result as below,

             total       used       free     shared    buffers     cached
Mem:         15905       2879      13026          0        384        900
-/+ buffers/cache:       1593      14311
Swap:         3999          0       3999

With the result above, you may see that the used memory is 2879MB and free memory is 13026MB. However, the cached memory is 1593MB while the actual free memory will be 14311MB.

MickGenie.com Linux Cheat Sheet

MickGenie.com Cheat Sheet:
Arrow up – list the history command that just done.
Ctrl + Z – Put the current process to the background.

date – display the server date and time.
df – show the disk space detail.
dmesg – print the boot message.
du – estimate the disk usage for the path.
finger – similar to who but you could use ‘finger <username>’ to show the selected user.
free – show free memory on the server.
hostname – show the hostname of your current server.
last – display who ever logged into the server and information
ps – showing all CPU processes.
pwd – show the current path.
uname – showing server information such as kernel, operating system, etc.
uptime – showing the server up time.
w – advance who option to show the server uptime, load and who is logged into the server.
who – show who is logged into the server.
whoami – show your current username.

man [command] – show the description of a command.
whatis [command] – show short description of a command.

more [filename] – show one screen of the file and you are able to scroll it.
less [filename] – similar to more but you are allow to scroll back.
head [filename] – show first 10 line of the file content.
tail [filename] – show last 10 line of the file content.
cat [filename] – print all file content.

top – show top process with server information.
kill – kill a certain process
killall [processname] – kill all of the process such as httpd, mysql, etc.
skill – kill all of the process from a user.

ls – list file.
dir – simple list file.
cd – change directory.
rm – remove a file
mkdir – create a folder.
rmdir – remove a folder.
touch – create a file.
mv – move or rename a file.
cp – copy a file.

tar zcf – create tar.gz file
tar cf – create tar file
tar zxf – untar tar.gz file
tar xf – untar tar file
gzip – create gz file
gunzip – unzip gz file

Monitor RAM/Memory on Linux

Memory (RAM) is known as an important component on the server to make sure that the server is running smooth and the running process could run in normal state. With Linux environment, it come with several tool to allow server administrator to check it’s memory such as free, top, vmstat, etc.

Today, Mick Genie will teach you on how to monitor them through several component that easily to understand by a server administrator or end user.

1. top – top command use to monitor the server performance, information, etc in real time. The rows of the memory and swap show that the total available, used and free memory and swap for your server.

2. /proc/meminfo – by open this file, it will show you the actual server properties information such as it’s memory, virtual memory, buffer, etc.

cat /proc/meminfo

3. free – one of the easier way to monitor and check the available memory from the server where you could use several command to control your needed information.

free -m
– use to monitor the physical memory

free -m -t
– use to monitor the physical memory plus it’s total usage

4. sar – sar command included ‘sysstat’ used to collect system activity information and saves it in a file before displaying it on a standard output.

You may use the command as below to show memory/swap/buffer information with human readable.

sar -r