Posts

Showing posts from 2010

A Shell Script to print domain ip address and its hosting information.

How to use this script:- 1. Extract the script from arin.tar.gz using following command:- $ tar -xzvf arin.tar.gz 2. Give the execution permission to the Script. $ chmod u+x arin 3. Execute the script:- $./arin domain1.com domain2.com ...... domainN.com Download : arin.tar.gz

How to Convert ext2 partition into ext3?

Suppose you want to convert your /tmp partition into ext3 then follow the following step:- 1. # init 1(Single user mode) 2.# umount /tmp or # mount -o remount,rw /tmp 3.# tune2fs -j /dev/sda9(Here /dev/sda9 represent /tmp partition.you must check using fdisk -l command) This command add .journal file into /tmp partition. 4. Open /etc/fstab file change partition type of /tmp into ext3. 5.Now check file system type using following command:- # file -s /dev/sda9 6.# init 6(Restart)

How to Convert ext3 partition into ext2?

Suppose you want to convert your /tmp partition into ext2 then follow the following step:- 1.# init 1(single user mode) 2.# umount /tmp or # mount -o remount,ro /tmp(better choice) 3.# tune2fs -O^has_journal /dev/sda9 (Here /dev/sda9 represent /tmp partition) 4.# e2fsck /dev/sda9 5.# rm -f /tmp/.journal (Removing .journal file) 6.Open /etc/fstab file change partition type of /tmp into ext2. 7.Check partition type of /dev/sda9 using following command:- # file -s /dev/sda9 8.# init 6(Restart)

Create a Partition having size 100MB and mount it on /data

1.# fdisk -l to see the partition table. 2.Now used following command:- # fdisk /dev/sda i>now type n for new partition. ii>It will ask you for primary or logical partition.Press l for logical partition. iii>It will ask for starting cylinder:Use defaults by pressing enter key. iv>Type the size:+100M (You also can specify last cylinder size here) v> Press P to verify partition lists and remember partition name. vi>Press w to write on partition table. 3.# init6 (restart) 4.# mkdir /data(Create a new directory name /data) 5.# mkfs -t ext3 /dev/sda10 (Here /dev/sda10 is a partition name) or # mke2fs -j /dev/sda10 (Create a ext3 partition) 6.Open /etc/fstab file:- write following line:- /dev/sda10 /data ext3 defaults 1 2 (Save the file) 7.# mount /dev/sda10 /data

Few tips for Linux User related to MAN page

To read a man page general command is:- #/$man example :-$man ping The above command gives you a name synopsis and short description about that command , list of option with that command and the author name. it also display ping(8).Here 8 is a section. The manual page categorized into several section. 1 - user commands 2 - System calls 3 - Subroutines 4 - Devices 5 - File Formats 6 - Games 7 - Miscellaneous 8 - System Administrator n - New x - X Window For ubuntu man page configuration file is : /etc/manpath.config for other system (Red Hat) /etc/man.config 1.Search a string with in man page: $man -k command 2.Convert man page to other format(by default post script format) $man -t command suppose you want to convert it into pdf format then $man -t ping|ps2pdf -> ping.pdf 3. Find a command form a particular section:- $man command eg. $man 3 printf 4. Small description(One sentence) about any command. $man -f command eg. $man -f ifconfig

SEND Mail Using JAVA Mail API

You need mail.jar to add your project ----------------------------------------------------- ----------------------------------------------------- import javax.mail.*; import javax.mail.internet.*; import java.util.Properties; public class SimpleSSLMail { private static final String SMTP_HOST_NAME = "smtp.gmail.com"; private static final int SMTP_HOST_PORT = 465; private static final String SMTP_AUTH_USER = "arinengg@gmail.com"; private static final String SMTP_AUTH_PWD = "password"; public static void main(String[] args) throws Exception{ new SimpleSSLMail().test(); } public void test() throws Exception{ Properties props = new Properties(); props.put("mail.transport.protocol", "smtps"); props.put("mail.smtps.host", SMTP_HOST_NAME); props.put("mail.smtps.auth", "true"); Session mailSession = Session.getDefaultInstance(props); mailSession.setDebug(true); Transport transport = mailSession.getTransport(); MimeM

Scrollable RESULTSET

import java.sql.*; public class Arin { public Arin(){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/Libary","root","password"); Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet rs=st.executeQuery("Select * from idnt"); int i=0; while(rs.next()) i++; System.out.println("Result Set Length:"+i); rs.beforeFirst(); while(rs.next()) System.out.println(""+rs.getString(1)); }catch(Exception e){ System.out.println(e.toString()); } } public static void main(String ar[]){ new Arin(); } }

How to Clear browser Cache History in JSP?

Just add following line on the top of the JSP page.(Page details information is clear form Browser Cache) JSP Code:- response.addHeader("Cache-Control", "max-age = 0, s-maxage = 0,must-revalidate, proxy-revalidate, no-cache, no-store "); response.addHeader("Pragma", "no-cache");

How to install tomcat in Linux???

Installing Tomcat from a binary release (tar file) requires manual creation of the Tomcat user account. This is not necessary if you install the Tomcat RPM package on a Linux system that supports RPMs. For security reason I create a user account with no login shell for running tomcat server. #groupadd tomcat #useradd -g tomcat -s /usr/sbin/nologin -m -d /home/tomcat tomcat Now I extracted tar file to /var/lib and change ownership of all files and directories to tomcat: #cd /var/lib #tar -zxvf apache-tomcat-6.0.28.tar.gz #chown -R tomcat:tomcat apache-tomcat-6.0.28 Download latest version tomcat from http://tomcat.apache.org/download-60.cgi Starting and Stopping tomcat:- # export CATALINA_HOME=/var/lib/apache-tomcat-6.0.28 # export CATALINA_BASE=/var/lib/apache-tomcat-6.0.28 # su -p -s /bin/bash tomcat $CATALINA_HOME/bin/startup.sh Using CATALINA_BASE: /var/lib/apache-tomcat-6.0.28 Using CATALINA_HOME: /var/lib/apache-tomcat-6.0.28 Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0

The Configuration a system so it does not respond to any ping and it survive a reboot.

Information about ping is stored in a file /proc/sys/net/ipv4/icmp_echo_ignore_all.If its value is 0 then its work normally in the ping.If the value is 1 then its does not respond any ping. #echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all #ping www.google.com(ping is possible) #ping localhost (not possible) now restart the machine. #init 6 #ping localhost(ping is possible) what happen??????? /proc is used to get or set kernel configuration.virtual file system not stored on hard disk,it is stored on ram.Modification apply immediately. To set any parameter change must be done in a file name /etc/sysctl.conf. #vi /etc/sysctl.conf add the following line and save the file:- net.ipv4.icmp_echo_ignore_all=1 save the file using :wq[Enter] #sysctl -p[Reload the settings from sysctl.conf file] #cat /proc/sys/net/ipv4/icmp_echo_ignore_all 1 Result is 1 so it does not respond any ping. #ping localhost[not possible] #init 6 #ping localhost [not possible] Change in a file /etc/sysctl.conf must

Hidden File in Linux

Hidden file is like a regular file with a dot "." prefixed. Syntax:- $touch .[file name] $vi/vim .[file name] Example:- suppose you want to create a file name ' tom ' then the command will be given below:- $touch .tom $vi/vim .tom now you want see the name of the hidden file in a current directory, then command will be given below:- $ls -a a-all files and directories the list will contain both hidden file and regular file. But user want to display only hidden file name in a current directory,then command will be given below:- $ls -a | grep -e "^\." [grep command is used to find regular expression from a file] or $ls -a .*

How to Lock an user account??????

Using help of usermod command we lock a user account.Only a super user can used usermod command. Syntax:- #usermod -L [username] L-Lock user account. Example:- #usermod -L john here john is a user name. Using help of usermod command we unlock a user account. Syntax:- #usermod -U [user name] U-unlock user account. Example:- #usermod -U john here john is a username.

How to know the ip address of an website??

Image
Just create a file name IAdd.java write the following code:- import java.net.*; class IAdd{ public static void main(String a[]) throws Exception{ Socket s=new Socket(a[0],Integer.parseInt(a[1])); InetAddress add=s.getInetAddress(); System.out.println(add); } } now compile the code...... $javac IAdd.java now run the code using following command................ $java IAdd [Host Name] [port number] suppose you want to know ip address of http://www.google.com then the command will be given below:- for http port number is 80 , $java IAdd www.google.com 80 suppose you want to know ip address of ftp://www.wbut.net then the command will given below:- $java IAdd www.wbut.net 21 here port number is 21 becuase control port of ftp is 21.

How to change the login shell of a user????

A normal user only change the login shell of her account.Super user may change the login shell of any account. Using finger command a user check her login shell and super user can check the login shell of any account. #finger example- suppose you want to know login shell of user john then, #finger john Using usermod command superuser can change login shell of any user.suppose super user want to change login shell (csh) of user john then, #usermod -s /bin/csh john superuser only used the usermod command. A user john want to change her login shell (bash) ,then the command will be given below: $bash -s /bin/bash john

How to see the available shell of a machine??

In a linux machine inforamation about the login shell are stored in a particular file name /etc/shells. You must open the file to see the available shell of a machine.Using following command you can see the available shell:- $cat /etc/shells or $more /etc/shells or $less /etc/shells

How to change the MAC address in Linux???????

First you must check your ip address MAC address using ifconfig command.You must open a terminal in linux and type following command: # ifconfig now check your ip address and mac address.Now if you want to change your mac address then type following command: #ifconfig eth0 down hw ether [mac address] Example: # ifconfig eth 0 down hw ether 00:00:00:ff:00:00 # ifconfig eth 0 up Now apply if config command you see that your mac address has been changed.