mount ISO file in linux

In this article we will describe the procedure to mount an ISO image file as a physical device

1) You must login as a root user, if not root user then switch to root user using following command:

$ su -

2) Create the directory i.e. mount point:

# mkdir -p /mnt/disk

3) Use mount command as follows to mount iso file called disk1.iso:

# mount -o loop disk1.iso /mnt/disk

4) Change directory to list files stored inside an ISO image:


# cd /mnt/disk
# ls -l

I hope you enjoy!

Centos – change hostname

To permanent change your hostname you have to edit the /etc/sysconfig/network file and set the variable HOSTNAME to your needs.

vi /etc/sysconfig/network

give the value you want to HOSTNAME variable like the following example:

HOSTNAME=myhost1.example.com

now this change will take effect after a reboot. There is a way to avoid reboot. You have to run the following command:

echo "myhost1.example.com" > /proc/sys/kernel/hostname

and that’s all!!!

set locale terminal settings on Mac OS X

One of my first experiences with Mac OS, was the locale errors and warnings when using ssh connections. Then I understood, that this was a problem occurred by mac os terminal. Locale settings by default are accepted from ssh client.

Then I run:

$locale

and the output was:

LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I then edited /etc/profile and added these two lines:

export LC_ALL=en_US.UTF-8  
export LANG=en_US.UTF-8

Then I opened a new terminal session and run:

$locale

and the output was:

LANG="en_US.UTF-8"  
LC_COLLATE="en_US.UTF-8"  
LC_CTYPE="en_US.UTF-8"  
LC_MESSAGES="en_US.UTF-8"  
LC_MONETARY="en_US.UTF-8"  
LC_NUMERIC="en_US.UTF-8"  
LC_TIME="en_US.UTF-8"  
LC_ALL="en_US.UTF-8"

After these committing these changes, I transfer my locale settings to my ssh connections and all problems solved.

How to disable ipv6 networking – CentOS

There are some simple steps to follow, in order to disable ipv6 networking on CentOS. This simple guide is about CentOS 6.4, but I think that it will work on both a little older or next versions of this Operating System.

Step 1: add this rule in /etc/sysctl.conf : net.ipv6.conf.all.disable_ipv6 = 1

Step 2: add this rule in /etc/sysconfig/network: NETWORKING_IPV6=no

Step 3: add this setting for each nic X (X is the corresponding number for each nic) in /etc/sysconfig/network-scripts/ifcfg-ethX: IPV6INIT=”no”

Step 4: disable the ip6tables service : chkconfig ip6tables off

Step 5: reboot

See how nfs client is connected to nfs server

Find out the configuration with which the nfs client is connected to the nfs server.

 

Bouncing my head to my keyboard while trying to find out where is the bottleneck on an nfs client-server relationship, I found out how to see the configuration with which the nfs client is connect to the server:

 

nfsstat -m

 

And the output is:

/nfsshare from nexenta.nfs-servers.example.com:/volumes/datastore/dataset/
 Flags: rw,relatime,vers=4,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.0.2.21,minorversion=0,local_lock=none,addr=10.0.2.245

 

Knowing exactly how the client is connected to the server, you can find more easily where the problem is.

 

Using the nfsstat -m command, you get the information about all nfs mounts. The -m switch is present on centOS, but abscent on FreeBSD, in which I do also performance tests.

 

You can also find all this information and also all the information about all mounts ( not only nfs mounts) if you execute:

 

cat /proc/mounts

 

I am trying to get this info on FreeBSD,  if everyone knows everything about this, please post a comment. I also asked a question at http://unix.stackexchange.com/questions/91594/nfs-mount-properties-options-in-freebsd to help me find the solution.

FQDN – Fully Qualified Domain Name

What is exactly the meaning of the term Fully Qualified Domain Name (FQDN). I was thinking that www.webplay.pro is a FQDN for example. While reading the great book Pro DNS and BIND 10 By Ron Aitchison I found out that technically an FQDN unambiguously defines a domain name to the root and therefore must terminate with the normally silent dot.

So the valid FQDN for www.webplay.pro domain is:

www.webplay.pro. 

 

How to see the output of a program and simultanesously write it to a file

In order to collect the stdout and stderr of a command into a single file and see the output interactively, run the following”

some_command 2>&1 | tee filename

this is usually called, io redirection and it is very usefull to all linux users, so I decided to add it to my blog.

To get some deeper, I refer that there are three types of I/O, which each have their own identifier, called a file descriptor:

  • standard input: 0
  • standard output: 1
  • standard error: 2

so, now it’s getting clear what the 2,1 arguments means in the redirection and notice that the ampersand here is not used to run a process in the background but, it merely serves as an indication that the number that follows is not a file name, but rather a location that the data stream is pointed to. Also note that the bigger-than sign should not be separated by spaces from the number of the file descriptor.

Install Nagios to Centos 6.4

In this step by step guide, we will install nagios. Nagios is a great (if not the greatest) opensource monitoring tool. You can use to monitor your hole datacenter, or lot’s of datacenters, services and networks.

1. Install the epel repository

Supposing you have not allready installed epel repository, run the following command:

# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

2. Disable selinux, iptables

In order to disable selinux edit /etc/selinux/config

# vi /etc/selinux/config

and set

SELINUX=disabled

I do not recommend to disable iptables, but setting correctly it depends on your servers configuration

I disabled iptables here just to ensure that everything works and then I will apply my firewall policy.

To disable iptables you have to run the following command:

# service iptables stop
# chkconfig iptables off

To confirm that the service is not running, run the following command:

# service iptables status

and the output should be like this:

iptables: Firewall is not running.

Then run the following command to ensure that is turned off, on boot

# chkconfig --list iptables

and the output should be this:

iptables        0:off   1:off   2:off    3:off    4:off    5:off    6:off

reboot your system to take effect selinux configuration.
To confirm that your system has disabled selinux run:

# sestatus
SELinux status: disabled

Be carefull if you didn’t run

# chkconfig iptables off

then after the system reboots, the iptables service will be up.

3. Nagios Installation

Now you can install nagios using yum

# yum install nagios

When the installation completes it’s procedure, you should run:

# service httpd restart
# service nagios restart

and then visit:

http://your-ip/nagios/

there will be a basic authentication, and you can login giving the following default credentials for nagios:

username: nagiosadmin
password: nagiosadmin

You can also change these credentials to whatever you want:

# htpasswd /etc/nagios/htpasswd nagiosadmin

and here enter the password you want.

 4. Change the theme of nagios

You can stay with the nagios default theme, but you can also change it to one of your choice. I like this theme:

http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip

and here I will describe how to install it.

# cd /tmp
# wget http://www.be-root.com/downloads/nagios/vautour/vautour_style.zip
# mkdir vautour
# mv vautour_style.zip vautour
# cd vautour
# unzip vautour_style.zip
# mv vautour/ /usr/share/nagios/.
# cd /usr/share/nagios/
# mv html html-backup
# mv vautour/ html
# chmod 775 html

if you miss unzip package install it via yum.

# yum install unzip

5. Install check_mysql_health

I found this plugin very helpfull to monitor my MySQL server.

to install it follow these instructions:

# cd /tmp
# wget http://labs.consol.de/download/shinken-nagios-plugins/check_mysql_health-2.1.8.2.tar.gz
# gtar -xzpf check_mysql_health-2.1.8.2.tar.gz
# cd check_mysql_health-2.1.8.2
# ./configure -prefix=/usr/lib64/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl --with-mymodules-dir=/usr/lib64/nagios/plugins --with-mymodules-dyn-dir=/usr/lib64/nagios/plugins
# cp -p /usr/lib64/nagios/libexec/check_mysql_health /usr/lib64/nagios/plugins/.

 

6. Configure nagios

In order to organize better your configuration files, I recommend that you should separate each configuration file for each purpose.

I add a file in /etc/nagios/conf.d/

hostgroups.cfg

and a file

servicegroups.cfg

where I include the declaration of the hostgroups and servicegroups respectively.

Then I create files for each servicegroup in /etc/nagios/objects/ for example I have a hostgroup of webservers, then I create a file webservers.cfg in this directory where I declare hosts and services. Then I add this file path to /etc/nagios/nagios.cfg as here:

# Definitions for monitoring the webservers
cfg_file=/etc/nagios/objects/webservers.cfg

7. Validate Configuration

Before restarting the nagios service, you should check the configuration spelling. This can be done, by run:

nagios -v /etc/nagios/nagios.cfg

I ‘ll try to update this post, and describe how to use check_mysql_health and other tools of nagios.

view files permissions in octal format

I was wondering which is the way to list file’s permissions in octal format. I tried to find out how to do it, using ls, but I conclude that a way to do it is to use stat command:

stat -c '%A %a %n' file

Upgrade from Centos 6.3 to Centos 6.4

Supposing that you have a clear installation of a Centos 6.3 and you want to upgrade it to Centos 6.4, you have to do two steps to complete this process. The first step is to run a yum update command:

yum update

The second step is to remove the deprecated matahari, as proposed from Centos 6.4 Release Notes

To ensure that you have successfully upgraded to 6.4 run the command:

cat /etc/redhat-release

if Centos Relsease 6.4 (Final) is the content of the /etc/redhat-release file then you can continue to the next step:

yum erase matahari*

If it’s a clean installation, possibly there is no remains of matahari packages on the system.