Pages

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