Pages

Wednesday, December 19, 2007

no space left on /var/lock/subsys while restarting a application Postifix

Found Postifix is giving an error saying no space left on /var/lock/subsys and Postfix stoped running, failing to create files onto /var/.

culprit was no free Inode left on /var ( use command to find Inode Status "tune2fs","df -hi" )

solution is delete /var/lib/amavis/spam* files ( keep in mind what to be deleted )

Tuesday, December 11, 2007

linux command's

linux commands to get use of OS



apropos - search the manual page names and descriptions


example:

localhost:~# apropos network
/etc/network/interfaces (5) [interfaces] - network interface configuration for ifup and ifdown
dhclient-script (8) - DHCP client network configuration script
ifconfig (8) - configure a network interface
ifdown (8) - take a network interface down
ifup (8) - bring a network interface up
interfaces (5) - network interface configuration for ifup and ifdown
nameif (8) - name network interfaces based on MAC addresses
netdevice (7) - Low level access to Linux network devices
netstat (8) - Print network connections, routing tables, interface
statistics, masquerade connections, and multicast memberships
networks (5) - network name information
nmap (1) - Network exploration tool and security scanner
ping (8) - send ICMP ECHO_REQUEST to network hosts
ping6 (8) - send ICMP ECHO_REQUEST to network hosts
pngtopnm (1) - convert a Portable Network Graphics file into portable anymap
pnmtopng (1) - convert a portable anymap into a Portable Network Graphics file
pppoe-sniff (8) - examine network for non-standard PPPoE frames
services (5) - Internet network services list
slattach (8) - attach a network interface to a serial line
wget (1) - The non-interactive network downloader.
X (7x) - a portable, network-transparent window system



df -hi

This command will gives statistic of Filesystem, Inodes,IUsed, IFree, IUse% and Mounted on.

tune2fs - adjust tunable filesystem parameters on ext2/ext3 filesystems

dumpe2fs - dump ext2/ext3 filesystem information
slocate - Security Enhanced version of the GNU Locate

rename - renames multiple files

Wednesday, December 5, 2007

shell script to mirror data on network using rsync , ssh-key

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ssh keys
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

First of all we need to generate ssh key on localhost and copy the key to remote machine. so in future communication happen without supply password to remote machine.

here steps follows to genereate ssh keys :

localhost # ssh-keygen -t dsa

localhost # file ~/.ssh/id_dsa

localhost # file ~/.ssh/id_dsa.pub

localhost # ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.0.50

locahost # ssh root@192.168.0.50


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
how to rsync ( man rsync )
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

I love rsync to mirror data , just cos of its wast features that it provides.here goes some sample of how to use rsync.note that more than this can be done with rsync.

localhost# rsync -avz /home/file root@192.168.0.50:/home/.

above rsync program copies /home/file to targeted machine .

-a, --archive
-v, --verbose
-z, --compress

localhost# rsync -avz -e ssh /home/file root@192.168.0.50:/home/.

-e, --rsh=COMMAND specify the remote shell to use

localhost# rsync -avz --delete /home/dir/ root@192.168.0.50:/home/dir/.

Note : be careful to use --delete option .this will exactly sync source and target dir and keep exactly copy of source to target deleting rest of modufyied files into that dir.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
shell script to run in cron for regular updates
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/bash

echo " ">>nohup.out
echo " ">>nohup.out

echo "*******Start of `date` ***********" >>nohup.out
echo "Start of /var/spool/mail directory " `date` >>nohup.out
nohup rsync -az --delete /var/spool/mail/ root@192.168.0.50:/var/mail
echo "End of /var/spool/mail directory " `date` >>nohup.out
echo "===================================" >>nohup.out

echo " ">>nohup.out
echo "Start of /home directory " `date` >>nohup.out
nohup rsync -az --delete /home/ root@192.168.0.50:/home
echo "End of /home directory " `date` >>nohup.out
echo "===================================" >>nohup.out

echo " ">>nohup.out
nohup rsync -avz /etc/group root@192.168.0.50:/etc/mailhost
nohup rsync -avz /etc/passwd root@192.168.0.50:/etc/mailhost
nohup rsync -avz /etc/shadow root@192.168.0.50:/etc/mailhost

echo "*********End of `date` *************" >>nohup.out

echo " ">>nohup.out
echo " ">>nohup.out

Tuesday, December 4, 2007

httpd default charset

While migrating web server (apache2 ) from desktop server to blade server. was found a problem in my web pages. was not able to view charset other than default UTF-8. And got to know that we can make use of different charset my enabling AddDefaultCharset on in httpd.conf.here follows step to change to default charset UTF-8 to new charset.

leo@gnu # vi /etc/httpd/conf/httpd.conf

do as follows

#AddDefaultCharset UTF-8 ( comment out this line and add following line )
AddDefaultCharset on

Friday, November 30, 2007

desktop and firefox shortcuts

Desktop shortcuts
ctl-alt-L : screen lock

alt-f1 : launch applications menu

alt-f2 : launch “run application” dialogue

ctrl-alt - right/left arrow : move to the next virtual desktop

ctrl-alt-shift - right/left arrow : take current window to the next virtual desktop

firefox: <
ctrl-t : new tab

alt-home : jump to home folder

ctrl-k : firefox search field

ctrl-l : firefox address bar

ctrl-pgup : next tab (left to right)

ctrl-pgdn : previous tab (right to left)

ctrl-r / f5: reload page

ctrl-u : view page source

No volume control GStreamer ... found — no sound on Ubuntu

Go to below URL :

linux.dsplabs.com.au

Thursday, November 29, 2007

Quick how-to sudoers file ubuntu

sudoers file to give permission to some users to act as if they were root.


To edit it, use the command

# visudo /etc/sudoers

You will see a file more or less like this.

 

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL) ALL



As you can see there is basically one line

root ALL=(ALL) ALL

This lines means that the user root can execute from ALL terminals, acting as ALL (any) users, and run ALL (any) command.

Wednesday, November 28, 2007

NTP Server/Client/Router RHEL4

===========================
NTP Server setting on RHEL4
===========================
The Network Time Protocol (NTP) is a protocol used to help synchronize your Linux system's clock with an accurate time source. There are that allow the general public to synchronize with them.

Installation:

step 1: leo@gnu# rpm -ivh ntp-4.2.0.a.20040617-6.el4

Configuration:

The /etc/ntp.conf file is the main configuration file

step 2: leo@gnu# vi /etc/ntp.conf

(add/edit following lines into main configuration files)

# -- CLIENT NETWORK -------
restrict xx.xx.0.0 mask 255.255.0.0 nomodify notrap

# --- OUR TIMESERVERS -----
server ntpserver.youdomain.com # A stratum 1 server
server ntpserver.youdomain.com # A stratum 2 server

# --- NTP MULTICASTCLIENT ---
restrict xx.xx.0.0 mask 255.255.0.0 nomodify notrap


logfile /var/log/ntpd
broadcast xx.xx.1.255





step 3:leo@gnu# chkconfig ntpd on

step 4:leo@gnu# date

step 5:leo@gnu# ntpdate -u ip_of_ntpserver

step 6:leo@gnu# service ntpd start



Determining If NTP Is Synchronized ?

step 7:leo@gnu# ntpq -p

===========================
NTP Server setting on RHEL4
===========================

step 1: leo@gnu# ntpdate -u ip_of_ntpserver

step 2: leo@gnu# vi /etc/ntp.conf

(add/edit following lines into main configuration files)

# --- OUR TIMESERVERS -----
server ntpserver.youdomain.com # A stratum 1 server
server ntpserver.youdomain.com # A stratum 2 server

step 3: leo@gnu# /etc/init.d/ntpd start

Determining If NTP Is Synchronized ?

step 4:leo@gnu# ntpq -p


-----------------------------------

ADD NTP server to Cisco Router

-----------------------------------

leo@gnu# telnet router.domain.com

router> enable
router# config t
router(config)# ntp update-calendar
router(config)# ntp server xx.xx.xx.xx
router(config)# exit
router# wr mem


---------------------------------

Thursday, November 22, 2007

shell script to convert .rm files to .mp3

#copy this script to downloaded audio files (i.e .rm) directory and execute.
#note at end script removes all .rm files after covertting them to .mp3.
#download latest hindi songs from blogspot.com


#!/bin/sh
for i in `ls *.rm`
do

tmp=$i

mplayer $tmp -ao pcm

mp3=`echo $tmp | cut -d. -f1`

lame -h -b 128 audiodump.wav $mp3.mp3

done

rm *.rm
rm audiodump.wav

Recover root privileges in Ubuntu 7.04

While trying to change username of admin user who is listed in suderos. I edited /etc/passwd of that particular user of my machine. Afterwards found that not able to do any administrative tasks as I changed user anilkumar to leo and leo was not in suderos group.

To gain back admin privileges
-------------------------------
step 1 # rebooted system with ubuntu live CD

step 2 # mounted root file system

ubuntu@ubuntu$ sudo -s

ubuntu@ubuntu$ mount -t ext3 /dev/sda2 /home/ubuntu (to find device use "fdisk" )

ubuntu@ubuntu$ vi /etc/passwd

step 3 # reboot


We can also edit grup i.e /boot/grub/menu.list (if it got crashed ).

convert .rm to .mp3 format

To convert .rm to .mp3, required utilities are mplayer (movie player) and lame (create mp3 audio files)

leo@gnu$ sudo apt-get install mplayer


leo@gnu$ sudo apt-get install lmae


leo@gnu$ mplayer thefiletobeconverted.rm -ao pcm

creates file audiodump.wav

leo@gnu$ lame -h -b 128 audiodump.wav myconvertedfile.mp3

Saturday, November 17, 2007

Wine is an Open Source implementation of the Windows API on top of X,

Wine is an Open Source implementation of the Windows API on top of X, OpenGL, and Unix.

Think of Wine as a compatibility layer for running Windows programs. Wine does not require Microsoft Windows, as it is a completely free alternative implementation of the Windows API consisting of 100% non-Microsoft code, however Wine can optionally use native Windows DLLs if they are available. Wine provides both a development toolkit for porting Windows source code to Unix as well as a program loader, allowing many unmodified Windows programs to run on x86-based Unixes, including Linux, FreeBSD, Mac OS X, and Solaris.

Wednesday, November 14, 2007

GPARTED (linux utility )

GPARTED (GNOME Partition Editor)
http://gparted.sourceforge.net

A utility to be used for device and partition info at system end.

Features
------------
* Create New/Resize/Move/Copy/Format/Delete partition.
* Get Device info

Invoking Gparted requires root privileges,so invoke by $sudo gparted.

Wednesday, October 31, 2007

units - unit conversion program

was spent time to convert one scales to their equivalents in other scales. (ex:lbs to kgs).similary for other SI units too.finally found a units conversion program.


step1>anilkumar@gnu# sudo apt-gets install units

step2> anilkumar@gnu:~$ units (invoke program)

2438 units, 71 prefixes, 32 nonlinear units

You have: lbs
You want: kgs
* 0.45359237
/ 2.2046226
You have:


step 3> look at FILES
/usr/share/misc/units.dat - the standard units data file

Tuesday, October 23, 2007

Defaults for the useradd command

#!/bin/bash
#
##
# Defaults for the useradd command
##
#GROUP=100 # Default Group
HOME=/home/users # Home directory location (/home/username)
SKEL=/etc/skel # Skeleton Directory
INACTIVE=0 # Days after password expires to disable account (0=never)
EXPIRE= # Days that a passwords lasts
SHELL=/bin/bash # Default Shell (full path)
SKEL=/etc/skel
##
# Defaults for the passwd command
##
PASSMIN=0 # Days between password changes
PASSWARN=14 # Days before password expires that a warning is given
##
# Ensure that root is running the script.
##
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1
fi
##
# Ask for username and fullname.
##
echo ""
echo -n "Username: "
read USERNAME
echo -n "Full name: "
read FULLNAME
echo -n "Group ID: "
read GROUP
#
echo "Adding user: $USERNAME."
#
# Note that the "" around $FULLNAME is required because this field is
# almost always going to contain at least on space, and without the "'s
# the useradd command would think that you we moving on to the next
# parameter when it reached the SPACE character.
#
/usr/sbin/useradd -c"$FULLNAME" -d$HOME/$USERNAME -e$EXPIRE \
-f$INACTIVE -g$GROUP -m -k$SKEL -s$SHELL $USERNAME
##
# Set password defaults
##
/usr/bin/passwd -n $PASSMIN -w $PASSWARN $USERNAME >/dev/null 2>&1
##
# Let the passwd command actually ask for password (twice)
##
/usr/bin/passwd $USERNAME
##
# Show what was done.
##
echo ""
echo "Entry from /etc/passwd:"
echo -n " "
grep "$USERNAME:" /etc/passwd
echo "Entry from /etc/shadow:"
echo -n " "
grep "$USERNAME:" /etc/shadow
echo "Summary output of the passwd command:"
echo -n " "
passwd -S $USERNAME
echo ""

Friday, October 19, 2007

escape code for few special characters into your HTML code

many characters should NEVER be typed directly into HTML code... for example the "<", ">", the "©", "&", and the " itself. Instead, type &escape_code; (Ampersand, Escape Code for Character, then a semicolon). For these 5 characters, here are the escape codes...



o For the < type & lt; (no space between & and lt)
o For the > type & gt; (no space between & and lt)
o For the © type & copy; (no space between & and lt)
o For the & type & amp; (no space between & and lt)
o For the " type & quot; (no space between & and lt)

execute perl scripts in CGI-BIN

To execute perl scripts using apache2 in cgi-bin.


step 1#cp /etc/apache2/mods-available/cgi* /etc/apache2/mods-enabled/.

step 2#vi /etc/apache2/sites-available/default

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
< Directory "/var/www/cgi-bin/" >
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
< /Directory >


step 3#/etc/init.d/apache2 restart

step 4#vi hello.pl

add following line into file hello.pl
-------------------------
#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "< html > < head > \n";
print "< title > Hello, world! < /title > < /head > \n";
print "< body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#8000
00\" > \n";
print "< h1 > Hello, PERL world! < /h1 > \n";
print "< a href=\"../perl/tutorial.html\" > < b > Back </b > < /a > to the Tutorial\n";
print "< /body > < /html > \n";


step 5#cp hello.pl /var/www/cgi-bin/.


step 6#http://localhost/cgi-bin/hello.pl

step 7#for error do check into /var/log/apache/error.log

Thursday, October 11, 2007

ssl certs

https certs
===========
Setp 1> Generate ssl certificates

#openssl genrsa -des3 -out hostname.key 1024

#openssl req -new -key hostname.key -out hostname.csr

#openssl x509 -req -days 365 -in hostname.csr -signkey hostname.key -out hostname.crt

step 2> Add Certificate to /etc/httpd/conf.d/ssl.conf


# vi /etc/httpd/conf.d/ssl.conf

(note: just remove comment "#" from SSLCertificate and add filename)

# Server Certificate:
SSLCertificateFile /etc/httpd/conf/cert/hostname.crt
# Server Private Key:
SSLCertificateKeyFile /etc/httpd/conf/cert/hostname.key




dovecot ssl certs
==================
Setp 1> Generate ssl certificates


#openssl genrsa -des3 -out /usr/share/ssl/private/dovecot.pem 2048

#openssl req -new -x509 -key /usr/share/ssl/private/dovecot.pem -out /usr/share/ssl/certs/dovecot.pem -days 1095

step 2> modify into /etc/dovecot.conf

Monday, September 3, 2007

apt-get install for RHEL4

apt-get installation for rhel4 (Update 4)
----------------------------------------
apt-get - APT package handling utility.

apt-get, that I use a lot that made my life easy going on Debian.So now using same on RHEL.This is how one can use apt-get on RHEL.


#rpm -ivvh http://apt.sw.be/redhat/el4/en/x86_64/dag/RPMS/apt-0.5.15lorg3.2-1.el4.rf.x86_64.rpm

#vi /etc/apt/sorces.list.d/os.list (add following mirror )

repomd http://apt.sw.be redhat/el4/en/x86_64/dag/

#apt-get update
#apt-cache search pkg
#apt-get install pkg
#apt-get remove pkg

partition using fdsik

fdsik ( Partition table manipulator for Linux )
------------------------------------------------
(login with root privilege )

# fdisk /dev/device

# fdisk ( m help):m

# fdisk ( m help):p

# fdisk ( m help):n

# fdisk ( m help):w

inform the OS of partition table changes with following command
----------------------------------------------------------------

# partprobe (to sysnc partation table into kernel)



create an ext3 filesystem
------------------------------



# mkfs.ext3 -b 1049 /dev/device


fstab file
----------
fstab is a configuration file that contains information of all the partitions and storage devices in your computer.

# vi /etc/fstab

Here's an example of the contents of /etc/fstab:

/dev/sda6 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/fd0 /floppy auto noauto 0 0
/dev/cdrom /cdrom iso9660 ro,noauto 0 0
/dev/sda12 /tmp ext3 defaults,nodev 0 2
/dev/sda13 /usr ext3 defaults 0 2
/dev/sda14 /home ext3 rw,auto,async,nouser,noexec,nodev,nosuid 0 2