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.

PlayOnLinux – Run Windows Application on Linux

PlayOnLinux is a piece of software which allows you to easily install on your Linux box and it will just like running on Microsoft Windows.

It come with numerous games and apps that could just run with cost-free from your Linux box.

Now, you can visit them by http://www.playonlinux.com/

Linux Shell Script to backup MySQL database to remote server

Database is the most important file other than web file, hence the backup is very important for the web developer and web owner.

By referring to the current post, you may backup your database automatically from your Linux box.

###START###

#!/bin/bash

# Specify the temporary backup directory
BKUPDIR=”/home/mickgenie/tmp”

# Database Name
dbname=”dbname_here”
dbuser=”user_here”
dbpasswd=”password_here”

# store the current date
date=`date ‘+%Y-%m-%d’`

# Specify Ftp details
ftpserver=”FtpServerIP”
ftpuser=”username”
ftppass=”password”

# Dump the mysql database with the current date and compress it.
/usr/bin/mysqldump -u$dbuser -p$dbpasswd $dbname | gzip > $BKUPDIR/$date.$dbname.sql.gz

# Change directory to the backup directory
cd $BKUPDIR

# Upload the backup
ftp -n $ftpserver <<!EOF!
user $ftpuser $ftppass
binary
prompt
mput *.sql.gz
quit
!EOF!

# Remove the local backup file
/bin/rm -f /$BKUPDIR/$date.$dbname.sql.gz

###END###

With the above script, you may save it as file.sh and just schedule a cronjob to run it as your needed time.

Useful Linux Monitoring Tools

If you still remember Mick Genie ever post on how to monitor RAM/Memory on Linux earlier from http://www.mickgenie.com/monitor-rammemory-on-linux/, you should have an idea on the basic command to monitor Linux server.

Today I would like to share some useful monitoring tools from Linux box. With Linux monitoring tools, it uses to analysis and debugging the Linux box.

1. Top Process
– Top process is the most used by the Linux user as it come with many useful information such as it’s server load, memory, iostat, etc.

With top command, it do comes with some hotkey.
t – Displays summary information off and on.
m –    Displays memory information off and on.
A –    Sorts the display by top consumers of various system resources. Useful for quick identification of performance-hungry tasks on a system.
f –    Enters an interactive configuration screen for top. Helpful for setting up top for a specific task.
o –    Enables you to interactively select the ordering within top.
r –    Issues renice command.
k –    Issues kill command.
z –    Turn on or off color/mono Continue reading Useful Linux Monitoring Tools

Understand and read core.xxxx files

With Apache Linux box, sometimes you might get lots of file named core.xxxx where xxxx is some number. You might wonder what is these file.

Normally core.xxxx file was generated from Linux box and holds the current state of a process working memory when a process is crashed. To read the file, run the command as below from your shell.

strings core.1234

From the strings reading, each line represent different state of a process.

Install RAR and Unrar in Linux

Sometimes, you might required to compress or extract .rar file from Linux box which do not come by default, however you may install it manually.

Under Debian Linux, you need to type apt-get as follows to install unrar program:

apt-get install unrar

Under Fedora core Linux then use yum command

yum install unrar

If the above method not working, you may copy the following command and paste to your console line.

cd /tmp;wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz;tar zxf rarlinux-3.6.0.tar.gz;cd rar;cp rar unrar /bin