Jan 08

File Structure On Linux

Linux Mint as all Linux based systems have different from Windows, file system structures. Let’s review the Linux file system structures and understand the meaning of individual directories.

[source : http://mintnext.blogspot.com/2012/10/linux-filesystem-structure_23.html ]

  • / – Root directory that forms the base of the file system. All files and directories are logically contained inside the root directory regardless of their physical locations
  • /bin – Contains the executable programs that are part of the Linux operating system. Many Linux commands, such as cat, cp, ls, more, and tar, are locate in /bin
  • /boot – Contains the Linux kernel and other files needed by LILO and GRUB boot managers
  • /dev – Contains all device files. Linux treats each device as a special file. All such files are located in /dev/etc – Contains most system configuration files and the initialisation scripts in /etc/rc.d sub directory
    • /dev/null – is a special directory that discards all data written to it (but reports that the write operation succeeded) and provides no data to any process that reads from it
  • /home – Home directory is the parent to the home directories of users
  • /lib – Contains library files, including loadable driver modules needed to boot the system
  • /lost+found – Directory for lost files. Every disk partition has a lost+found directory
  • /media – Directory for mounting files systems on removable media like CD-ROM drives, floppy disks, and Zip drives
  • /mnt – A directory for temporarily mounted file-systems
  • /opt – Optional software packages copy/install files here
  • /proc – A special directory in a virtual file-system. It contains the information about various aspects of a Linux system
  • /root – Home directory of the root user
  • /sbin – Contains administrative binary files. Commands such as mount, shutdown, demount, reside here
  • /srv – Contains data for services (HTTP, FTP, etc.) offered by the system
  • /sys – A special directory that contains information about the devices, as seen by the Linux kernel
  • /tmp – Temporary directory which can be used as a scratch directory (storage for temporary files). The contents of this directory are cleared each time the system boots
  • /usr – Contains sub-directories for many programs such as the X Window System
    • /usr/bin – Contains executable files for many Linux commands. It is not part of the core Linux operating system
    • /usr/include – Contains header files for C and C++ programming languages
    • /usr/lib – Contains libraries for C and C++ programming languages
    • /usr/local – Contains local files. It has a similar directories as /usr contains
    • /usr/sbin – Contains administrative commands
    • /usr/share – Contains files that are shared, like, default configuration files, images, documentation, etc
    • /usr/src – Contains the source code for the Linux kernel
  • /var – Contains various system files such as log, mail directories, print spool, etc. which tend to change in numbers and size over time
    • /var/cache – Storage area for cached data for applications
    • /var/lib – Contains information relating to the current state of applications. Programs modify this when they run
    • /var/lock – Contains lock files which are checked by applications so that a resource can be used by one application only
    • /var/log – Contains log files for different applications
    • /var/mail – Contains users emails
    • /var/opt – Contains variable data for packages stored in /opt directory
    • /var/run – Contains data describing the system since it was booted
    • /var/spool – Contains data that is waiting for some kind of processing
    • /var/tmp – Contains temporary files preserved between system reboots

Permanent link to this article: http://serangku.net/?p=408

Jan 06

Setup Icecast2 KH on Debian

Setup Icecast2 KH on Debian

Permanent link to this article: http://serangku.net/?p=399

Jan 05

OpenVZ Partition Guide for Debian

Here is standar virtuozzo based install partionn

/boot – 2G-10G – boot partition

swap – 2xRam Memory – swap partition

/ – all the space left – main root partition


/boot – 2G-10G – boot partition

swap – 2xRam Memory – swap partition

/ – 2G-10G(or more) – main root partition

/vz – all space left – virtuozzo partition, all vps’s files will be here


Personally I prefer the second step configuratio

*****If you run LVM, leave some space unallocated for snapshots (if you want to take advantage of this feature for hot server backups).*****

Permanent link to this article: http://serangku.net/?p=387

Nginx On Debian Squeeze

Source : http://www.kathirvel.com/install-config-optimize-nginx-debian-linux-server

Nginx (pronounced “engine-x”) is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. According to BuiltWith, it is used on 9.92% of the top 1 million websites, and its growth within the top 10k, 100k and 1 million segments is increasing.
- Wikipedia

The purpose of this tutorial is to install and configure NGINX (to host WordPress sites) on a low end cloud server (256MB instance from Rackspace).

Step 1 : Add the Dotdeb repository

The version of NGINX in the Debian repository is slightly outdated. We need to grab the latest version of NGINX to benefit from all new updates and bug fixes. Read this article on Adding the Dotdeb repository to your Rackspace Cloud (Debian Squeeze) Server.

Step 2 : Install NGINX

The following command will do it all. It will also start the NGINX service and add it to the server startup.

apt-get install nginx

Step 3 : Configure & optimise NGINX

The NGINX package from Dotdeb comes bundled with all the key modules. The configuration file is pretty good too. We’ll still need to make some changes as our cloud server instance is just 256MB. Open


using your preferred editor. The following are some settings that you can change / add.

worker_processes 2
worker_connections 1024
server_tokens off;
# Timeout Settings
client_body_timeout 10;
client_header_timeout 10;
keepalive_timeout 5 5;
send_timeout 10;
# Gzip Settings - For improving (SEO) page speed
gzip on;
gzip_static on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_vary on;
gzip_types text/plain text/css text/xml text/javascript application/json application/x-javascript application/xml application/xml+rss;
gzip_proxied expired no-cache no-store private auth;
gzip_buffers 16 8k;
gzip_http_version 1.1;

The above are just a few critical ones. You can refer to the NGINX documentation if you would like to further optimise NGINX.

Step 4 : Create virtual hosts for multiple domains

Create the following folders to store the website’s files, scripts and logs. The third command will make NGINX (www-data user) own the website files.

mkdir -p /var/www/domain/httpdocs
mkdir /var/www/domain/logs
chown -R www-data:www-data /var/www/

Create a domain vhost configuration file at this location.


The filename can be anything. e.g. domainname.conf, domainname, domainname.tld, etc. Create a symlink to this domain’s vhost configuration file from


using the following command.

ln -s /etc/nginx/sites-available/filename /etc/nginx/sites-enabled/filename

The following content should go into the domain’s vhost configuration file.

server {
  # This redirects the non-www version of the domain name to the www version
  server_name domain.com;
  rewrite ^ $scheme://www.domain.com$request_uri? permanent;
server {
  server_name www.domain.com;
  root /var/www/domain/httpdocs;
  index  index.html index.htm index.php;
  access_log /var/www/domain/logs/access.log;
  error_log /var/www/domain/logs/error.log;
  location ~ \.php$ {
    # The next two lines address a security flaw in NGINX.
    # https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    include /etc/nginx/fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/domain/httpdocs$fastcgi_script_name;
  # Disable index.php and make WordPress permalinks work
  location / {
    try_files $uri $uri/ /index.php?$args;
  # Expires header to improve SEO (Google Page Speed) 
  location ~* \.(ico|css|js|gif|jpg|jpeg|png|xml|pdf)$ {
    expires 1w;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    log_not_found off;
  location = /favicon.ico {
    log_not_found off;
    access_log off;
  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store
  location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
  # Don't log and deny access to files which end with ~, as these are usually backup files.
  location ~ ~$ {
    access_log off;
    log_not_found off;
    deny all;

The above settings should be sufficient to run a WordPress based website. We have also taken care of some key page speed improvements that Google recommends.

Step 5 : Restart NGINX

Once you have completed the above steps, you will have to restart NGINX for the new settings to take effect. You can use the following command to restart NGINX.

service nginx restart

Step 6 : Point the domain’s A record to the server’s IP address

For the domain and the hosting to work together, you need to edit your domain’s DNS records and point the A records (@ and www) to your server’s IP address. Once the DNS change gets propagated around the web, you will be able to enter your domain name in the address bar of the browser and reach your website stored under the folder (/var/www/domain/httpdocs).


another usefull from this site http://library.linode.com/web-servers/nginx/php-fastcgi/debian-6-squeeze

Permanent link to this article: http://serangku.net/?p=220

Dec 27

Install Webmin on Debian Squeeze

The easiest way install Webmin from repository

If you like to install and update Webmin via APT, edit the /etc/apt/sources.list file on your system and add the lines :

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

get GPG key with which the repository is signed, with the commands :

cd /root

wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc

You will now be able to install with the commands :

apt-get update
apt-get install webmin


root@debian:~# apt-get install webmin
Reading package lists… Done
Building dependency tree
Reading state information… Done
webmin is already the newest version.
You might want to run ‘apt-get -f install’ to correct these:
The following packages have unmet dependencies:
webmin : Depends: libnet-ssleay-perl but it is not going to be installed
Depends: libauthen-pam-perl but it is not going to be installed
Depends: libio-pty-perl but it is not going to be installed
Depends: apt-show-versions but it is not going to be installed
E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).


solution :

root@debian:~# apt-get -f install

All dependencies should be resolved automatically. Done !

Permanent link to this article: http://serangku.net/?p=215

IP Address Config on Deb


Just reminder for myself

nano /etc/network/interfaces

for dhcp

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inte loopback

#The primary network interface
auto eth0
iface eth0 inet dhcp



for static

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inte loopback

#The primary network interface
auto eth0
iface eth0 inet static

dont forget to set dns-server at /etc/resolv.conf
on one day … forget to set it and ruin my half day … :(

Permanent link to this article: http://serangku.net/?p=210

Install Virtualization With OpenVZ on Debian Squeeze x64 [part 3]

On Install Virtualization With OpenVZ on Debian Squeeze x64 [part 2]  explain how to use openvz container with command on console. Hey … thats to complex. Is there a way for simpliciity to manage openvz container ? With GUI interface if possible.

Unfortunately …

There is a way that more simple to manage openvz container and also have GUI interface. A community project that called OpenVZ Web Panel.

OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.

Just only single line comand on console to install OpenVZ Web Panel

type this on your console :

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

It will install automatically OpenVZ Web Panel on your machine.

Next step is access it from remote computer with url


Default user : admin and password : admin

Done !



Permanent link to this article: http://serangku.net/?p=205

Dec 27

Install Virtualization With OpenVZ on Debian Squeeze x64 [part 2]

Before we can create virtual machines with OpenVZ, we need to have a template for the distribution that we want to use in the virtual machines in the /var/lib/vz/template/cache directory. The virtual machines will be created from that template.

You can find a list of precreated templates on http://wiki.openvz.org/Download/template/precreated. For example, we can download a minimal Debian Squeeze template (x86_64) as follows:

cd /var/lib/vz/template/cache
wget http://download.openvz.org/template/precreated/contrib/debian-6.0-amd64-minimal.tar.gz

(If your host is an i386 system, you cannot use an amd64 template – you must use i386 templates then!)

I will now show you the basic commands for using OpenVZ.

To set up a VPS from the debian-6.0-amd64-minimal template (you can find it in /var/lib/vz/template/cache), run:

vzctl create 101 –ostemplate debian-6.0-amd64-minimal –config basic

The 101 must be a uniqe ID – each virtual machine must have its own unique ID. You can use the last part of the virtual machine’s IP address for it. For example, if the virtual machine’s IP address is, you use 101 as the ID.

If you want to have the vm started at boot, run

vzctl set 101 –onboot yes –save

To set a hostname and IP address for the vm, run:

vzctl set 101 –hostname test.example.com –save
vzctl set 101 –ipadd –save

Next we set the number of sockets to 120 and assign a few nameservers to the vm:

vzctl set 101 –numothersock 120 –save
vzctl set 101 –nameserver –nameserver –save

(Instead of using the vzctl set commands, you can as well directly edit the vm’s configuration file which is stored in the /etc/vz/conf directory. If the ID of the vm is 101, then the configuration file is /etc/vz/conf/101.conf.)

To start the vm, run

vzctl start 101

To set a root password for the vm, execute

vzctl exec 101 passwd

You can now either connect to the vm via SSH (e.g. with PuTTY), or you enter it as follows:

vzctl enter 101

To leave the vm’s console, type


To stop a vm, run

vzctl stop 101

To restart a vm, run

vzctl restart 101

To delete a vm from the hard drive (it must be stopped before you can do this), run

vzctl destroy 101

To get a list of your vms and their statuses, run

vzlist -a

root@server1:~# vzlist -a
101          8 running   test.example.com

To find out about the resources allocated to a vm, run

vzctl exec 101 cat /proc/user_beancounters

server1:~# vzctl exec 101 cat /proc/user_beancounters
Version: 2.5
uid  resource           held    maxheld    barrier      limit    failcnt
101:  kmemsize         500737     517142   11055923   11377049          0
lockedpages           0          0        256        256          0
privvmpages        2315       2337      65536      69632          0
shmpages            640        640      21504      21504          0
dummy                 0          0          0          0          0
numproc               7          7        240        240          0
physpages          1258       1289          0 2147483647          0
vmguarpages           0          0      33792 2147483647          0
oomguarpages       1258       1289      26112 2147483647          0
numtcpsock            2          2        360        360          0
numflock              1          1        188        206          0
numpty                1          1         16         16          0
numsiginfo            0          1        256        256          0
tcpsndbuf         17856      17856    1720320    2703360          0
tcprcvbuf         32768      32768    1720320    2703360          0
othersockbuf       2232       2928    1126080    2097152          0
dgramrcvbuf           0          0     262144     262144          0
numothersock          1          3        120        120          0
dcachesize            0          0    3409920    3624960          0
numfile             189        189       9312       9312          0
dummy                 0          0          0          0          0
dummy                 0          0          0          0          0
dummy                 0          0          0          0          0
numiptent            10         10        128        128          0

The failcnt column is very important, it should contain only zeros; if it doesn’t, this means that the vm needs more resources than are currently allocated to the vm. Open the vm’s configuration file in /etc/vz/conf and raise the appropriate resource, then restart the vm.

To find out more about the vzctl command, run

man vzctl


:::Credit goes to : Falko Timme <ft [at] falkotimme [dot] com>:::

Permanent link to this article: http://serangku.net/?p=202

Dec 27

Install Virtualization With OpenVZ on Debian Squeeze x64 [part 1]

In this HowTo I will describe how to prepare a Debian Squeeze server for OpenVZ. With OpenVZ you can create multiple Virtual Private Servers (VPS) on the same hardware, similar to Xen and the Linux Vserver project. OpenVZ is the open-source branch of Virtuozzo, a commercial virtualization solution used by many providers that offer virtual servers. The OpenVZ kernel patch is licensed under the GPL license, and the user-level tools are under the QPL license.

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!


1 Preliminary Note

I’m using an x86_64 (amd64) system here. If you are on an i386 system, a few commands will be slightly different – I have added annotations to that parts.


2 Installing OpenVZ

An OpenVZ kernel and the vzctl, vzquota, and vzdump packages are available in the Debian Squeeze repositories, so we can install them as follows:

apt-get install linux-image-openvz-amd64 vzctl vzquota vzdump

::::::—if something goes wrong like this :
Setting up vzquota (3.0.12-3) …
Setting up vzctl (3.0.24-12) …
The kernel do not support openvz, do not start vz.
The kernel do not support vzevent, do not start vzeventd.
Setting up linux-image-2.6.32-5-openvz-amd64 (2.6.32-46) …

take this option :
# echo -e “\ndeb http://download.openvz.org/debian-systs etch openvz” >> /etc/apt/sources.list
# wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add – && apt-get update —::::::

(If you are on a i386 system, the kernel package is named linux-image-openvz-686.)

Create a symlink from /var/lib/vz to /vz to provide backward compatibility:

ln -s /var/lib/vz /vz

Open /etc/sysctl.conf and make sure that you have the following settings in it:

vi /etc/sysctl.conf

net.ipv4.conf.default.proxy_arp = 0
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

If you need to modify /etc/sysctl.conf, run

sysctl -p


The following step is important if the IP addresses of your virtual machines are from a different subnet than the host system’s IP address. If you don’t do this, networking will not work in the virtual machines!

Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all:

vi /etc/vz/vz.conf

# Controls which interfaces to send ARP requests and modify APR tables on.

Finally, reboot the system:


If your system reboots without problems, then everything is fine!


uname -r

and your new OpenVZ kernel should show up:

root@server1:~# uname -r


:::Credit goes to : Falko Timme <ft [at] falkotimme [dot] com>:::

Permanent link to this article: http://serangku.net/?p=199