Friday, November 26, 2010

How to automount in linux

We use /etc/fstab to automount directories in linux.
The default format of /etc/fstab is as follows:

1st column : Device (example /dev/sda1)
2nd column : Mount point (example /home)
3rd column : Filesystem type (example ext3)
4th column : Mount options (example defaults)
5th column : Dump (usually 0)
6th column : fsck (usually 0)

Since this is a short tutorial, we will not be discussing things in detail

Example:

1. Edit the /etc/fstab file

2. Add the directory that you want to automount
/dev/sda1 /home/test ext3 defaults 0 0

3. mount -a (if you want to mount the filesystems specified in /etc/fstab without restarting linux)

Read More !

Wednesday, November 24, 2010

How to mount ntfs filesystem in Linux

Mounting NTFS file system on Linux (read only mode)

1. First check for ntfs kernel support
cd /lib/modules/2.6.18-92.el5/kernel/fs/ | grep ntfs

2. List the partitions
fdisk -l
to list only ntfs partitions
fdisk -l | grep NTFS

3. Mount ntfs parition

mount -t ntfs /dev/sda1 /mnt/windows
replace /dev/sda1 with the respective parition on your harddisk
replace /mnt/windows with the respective mount on your harddisk


Read More !

Tuesday, June 8, 2010

How to count files in a directory in linux

count files in a directory : ls -1 | wc -l
count files including hidden files : ls -1a | wc -l

Read More !

Tuesday, June 1, 2010

How to resolve Squid error

Error message when restarting squid :

Error message : squid: ERROR: Could not send signal 0 to process 20348: (3) No such process

Solution :

Executed the following command for detailed squid log /path/to/sbin/squid -DNYCd3 .
Error was due to /var partition being full where squid creates the pid file and other logs.
Cleared the /var parition and squid started working perfectly fine.

Read More !

Monday, May 24, 2010

How to configure LVM (Logical Volume Management)

A 5 Step guide to LVM (logical volume management)

1. Prepare partitions for lvm

pvcreate /dev/hardisk /dev/hardisk

example : pvcreate /dev/sda1 /dev/sdb1

pvdisplay - to display physical volumes

2. next create volume group with each physical volume

vgcreate
/dev/hardisk /dev/hardisk
example : vgcreate fileserver /dev/sda1 /dev/sdb1

vgdisplay - to display volume group

3. next create logical volumes

lvcreate --name --size xxG

example : lvcreate --name share --size 25G fileserver

4. create filesystem

mkfs.ext3 /dev//

example : mkfs.ext3 /dev/fileserver/share

5. mount the logical volume

mount /dev/fileserver/share /var/share
Read More !

Nagios client installation guide

if xinetd is not installed, install it.

1. add nagios user and set a password.

2. create nagcmd group and add nagios and apache to it.
(used to issue commands directly from web interface)

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache


3. download and install nagios plugin

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar xfv nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.11

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


4. change the permissions

chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec


5. download and install nrpe plugin (nrpe uses 5666)

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar xfv nrpe-2.12.tar.gz
cd nrpe-2.12

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd


6. nrpe configuration

vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1 (change to nagios server ip address)

7. add nrpe port to services file

vim /etc/services

nrpe 5666/tcp # NRPE


8. service xinetd restart

9. testing nrpe

netstat -at |grep nrpe

output : tcp 0 0 *:nrpe *.* LISTEN

Read More !

Nagios server installation guide

Nagios is network monitoring tool used to monitor servers ,routers , switches and other devices.

Server Installation

Prerequisites : Apache, PHP, GCC compiler, GD development libraries

yum install httpd php gcc glibc glibc-common gd gd-devel

1. add nagios user and set a password.

2. create nagcmd group and add nagios and apache to it.
(used to issue commands directly from web interface)

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache


3. download nagios core and nagios plugin from nagios website.

4. extract the nagios core into a directory and configure with the group option.

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
tar xfv
nagios-3.2.1.tar.gz
cd nagios-3.2.1
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

5. start apache

6. Next install nagios plugin with nagios user and nagios group

cd /home/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
tar xfv
nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


7. service nagios start

8. to view the webinterface

http://ipaddress/nagios/

To monitor remote server, you need to install nrpe plugin

1. download and install nrpe plugin (nrpe uses 5666)

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

2. nrpe configuration

vim /etc/xinetd.d/nrpe

only_from = 127.0.0.1
(change to nagios server ip address)

3. add nrpe port to services file

vim /etc/services

nrpe 5666/tcp # NRPE

4. service xinetd restart

5. testing nrpe

netstat -at | grep nrpe

output : tcp 0 0 *:nrpe *.* LISTEN


Read More !

Tuesday, May 18, 2010

Boot Linux Grub Boot Loader into single user mode

1. At grub boot screen, select the kernel
2. Press the e key to edit the entry
3. Select the option that starts with kernel
4. Press the e key to edit kernel entry and add the letter S or word Single at the end of the line
5. Press enter key
6. Press the b key to boot the Linux kernel into single user mode
Read More !

Thursday, May 6, 2010

Retreive email passwords from plesk

login to mysql as root;

mysql> use psa;

mysql> select CONCAT(mail_name,"@",name) as email_address, substring(accounts.password, '1') from mail left join domains on domains.id=mail.dom_id left join accounts on accounts.id=mail.account_id;

This displays all the email address with their passwords.
Read More !

Wednesday, May 5, 2010

How to install Ghostscript?

Download source at http://www.ghostscript.com/awki/Releases

./configure
make
make install

Example :

cd /usr/local/src/
wget http://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs863/ghostscript-8.63.tar.gz
tar zxf ghostscript-8.63.tar.gz
cd ghostscript-8.63
./configure
make
make install
Read More !

Monday, May 3, 2010

Useful link for upgrading to new release of bugzilla

Found a nice link for upgrading to new release of bugzilla,

http://tldp.org/LDP/bugzilla/Bugzilla-Guide/upgrading.html
Read More !

Sunday, April 25, 2010

To find zombie process

Use the following commands to view zombie process:

ps auxw | grep -i "z"

or

ps aux | awk '{ print $8 " " $2 }' | grep -w Z
Read More !

Thursday, April 22, 2010

Useful ls commands

sort output by file modication time : ls -lt
sort output by file modication time (reverse order) : ls -ltr
sort output by file size : ls -lS
sort output by file size (reverse order) : ls -lSr
sort output by filename extension : ls -lX
sort output by filename extension (reverse order) : ls -lXr
sort output by filename extension (show only files) : ls -1X
Read More !

Friday, April 9, 2010

To set line number in vi or vim

To display line number :set number
To turn off line number :set nonumber
Read More !

Sunday, April 4, 2010

Determine if given date is in DST

GNU date can give you the timezone for a date...
date -d '2009-03-02' '+%Z'
Read More !

Monday, January 18, 2010

samba and htpasswd

to create smbpasswd : smbpasswd -a $USER
to delete user : /usr/bin/htpasswd -D /path to htpasswd file/file $USER
to add new user : /usr/bin/htpasswd -mb /path to htpasswd file/file $USER $PASS
Read More !

Thursday, September 24, 2009

To view System Information

Print system information, print information about the machine and operating system it is run on.

uname -a

To view hostname : cat /proc/sys/kernel/hostname
Read More !

Friday, September 18, 2009

How to setup sender policy framework (spf) in plesk

Login to Plesk
Goto Domains -> your Domainname.com -> Dns Settings -> Add record
Choose Record type as : Txt
Leave the domain name as blank
(generate spf record from any online wizard or by default you can add "v=spf1 a mx ~all")
Enter Txt record value : "v=spf1 a mx ~all"
Read More !

Wednesday, September 16, 2009

How to reset mysql root password in linux

Stop the mysqld daemon process:
/etc/init.d/mysql stop

Start the mysqld daemon process with the --skip-grant-tables option:
/usr/bin/mysqld_safe --skip-grant-tables

Start the mysql client with the -u root option:
mysql --user=root mysql

Execute the query:
update user set Password=PASSWORD('new-password-here') WHERE User='root';

Execute the FLUSH PRIVILEGES; command:
flush privileges;

Exit the mysqld daemon process:
exit

Start the mysqld daemon process:
/etc/init.d/mysql start

Read More !

How to create symlinks in linux

How to creating Symbolic Links in linux

ln -s source destination
example: ln -s httpdocs httpsdocs

This creates a symlink for httpsdocs -> httpdocs

To change permission of symlinks
chown -h owner:group directory

Read More !