Search This Blog

Monday, March 28, 2011

All about Application and Port.

Check below url for finding port number associated with an application.
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Above listing helps to identify which applications are using which port.

In Linux a command line utility netstat is used widely for identifying port.
a good articles over netstat can be found on below links.
http://www.thegeekstuff.com/2010/03/netstat-command-examples/

Tuesday, March 22, 2011

Apache Server Hardening .

Found Nice article of securing apache server.

Please check all the articles from thegeekstuff they are very useful.

http://www.thegeekstuff.com/2011/03/apache-hardening/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29

Please Leave us with your comments and Queries/Suggestions.
I will try to reply asap.

Friday, March 18, 2011

How to Monitor network traffic using TCPDUMP.

There is a very useful utility provided in linux to monitor the network traffic between two hosts.

Example : To monitor network traffic between Machine A and Machine B .
run following command on Machine A.

#tcpdump -npi eth0 host (MACHINEB)HOSTNAME/IP -vvvs0 -w /var/tmp/network_traffic.cap

once the command is executed just use any analysis tool to monitor the logs.

Thursday, March 17, 2011

All about rpm.

RPM (Redhat package Manager).
There have been lot of changes since it was named .So RPM doesnt only relates to redhat distribution of linux .Now most of linux distributions supports RPM package manager.


Topic covered so far

1) RPM Naming convention.
2) How to check list of installed rpm(s).
3) How to list file(s) stored in rpm.


1) RPM Naming convention.

name-version-release.architecture.rpm
for example.

samba-32bit-3.4.2 -1.1.3.1.x8664.rpm

2) How to check list of installed rpm(s).  

run rpm -qa to list all the installed rpm.
-q : Query rpm.
-a : Query all installed packages. 


 3) How to list file(s) stored in rpm. 

use rpm -qpl to find the list of files included in rpm. 
$ rpm -qpl myrpm-1-0.noarch.rpm
/usr/local/bin/myscript.sh
 


 -p, --package PACKAGE_FILE :
              Query  an  (uninstalled) package PACKAGE_FILE.  The PACKAGE_FILE may be specified as an ftp or http style URL, in which case the package header will be downloaded and queried.  See  FTP/HTTP  OPTIONS for information on rpmâs internal ftp and http client support. The PACKAGE_FILE argument(s), if not a binary package, will be interpreted as an ASCII package manifest.  Comments are permitted, starting  with  a  â#â,  and each line of a package manifest file may include white space separated glob expressions, including URLâs with remote glob expressions, that will be expanded to paths that  are substituted in place of the package manifest as additional PACKAGE_FILE arguments to the query.


-l :
              List files in package.

In above example rpm myrpm-1-0.noarch.rpm contains script named /usr/local/bin/myscript.sh

Wednesday, March 16, 2011

Update time of machine specifying ntpserver

Just run following command on the server .

#ntpdate NTPSERVER_HOSTNAME/IP

(Note:You must configure NTPSERVER for the above command to work).

Configure mail Client (Internal Mail Server)

Today i was configuring mail for one of our Linux server .

After following the normal steps for configuring the mail client i wasn't able to send mail .

following were the steps taken for configuring the mail client.

Make sure you have following rpms installed.
# rpm -qa| grep sendmail
sendmail-cf-8.13.8-2.el5
sendmail-8.13.8-2.el5

(Note:Most linux distributions comes with sendmail rpm but most of the time you need to install sendmail-cf rpm according to your distribution).

Modified below parameter from /etc/mail/sendmail.mc file.

dnl define(`SMART_HOST', `internalmail.XXX.com')dnl

Here you define the name of your internal mail server.
(Note : Make sure you can ping the mail server from client machine).

Now its time to compile the /etc/mail/sendmail.mc file to /etc/mail/sendmail.cf.
the command used is.
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

After compiling its time to send the mail.

mail -s "test" myemailid@XXX.com , relay=root@localhost
Mar 16 10:58:13 XXX sendmail[5220]: p2G5SCCf005220: from=, size=389, class=0, nrcpts=1, msgid=<201103160528.p2g5scga005219@xxx.xxx.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Mar 16 10:58:13 XXX sendmail[5219]: p2G5SCgA005219: to=XXX@XXX.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30073, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p2G5SCCf005220 Message accepted for delivery)
Mar 16 10:58:15 XXX sendmail[5222]: STARTTLS=client, relay=XXX.XXX.com., version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
Mar 16 10:58:16 XXX sendmail[5222]: p2G5SCCf005220: to=, ctladdr= (0/0), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120389, relay=XXX.XXX.com. [XXXX], dsn=5.1.8, stat=User unknown
Mar 16 10:58:17 XXX sendmail[5222]: p2G5SCCf005220: p2G5SHCf005222: DSN: User unknown
Mar 16 10:58:17 XXX sendmail[5222]: p2G5SHCf005222: to=, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31656, dsn=2.0.0, stat=Sent

It was bit clear from the log that machine was sending the email to itself but not able to send it to internal mail server.

Later i checked that the machine wasn't registered in DNS.so it was not returning its ip address after i issue following command.
host HOSTNAME.XXX.com
when i added the machine in dns it was successfully resolving the ip address.
host HOSTNAME.XXX.com
HOSTNAME.XXX.com has address XX.XXX.XXX.XXX

So it was all due to DNS not having our server entry and nothing wrong with Configuration of mail.


Monday, March 14, 2011

How to reduce size of Virtual image (.img) In OVM?

I had created a template of win2k3 machine having size of 80 GB (C drive=30GB,D drive =50GB).

But To cater a request for new VM Machine having size of 1 TB (C drive=30GB, D= 1 TB-30GB)
I had to come up with something .
So i created a machine from template of win2k3(above mentioned one).
Then i deleted d drive partition of 50 GB using Disk management.

Then i shutdown the machine.
Logged in to Server hosting VM guests.

Ran following command
#dd if=/OVS/running_pool/vm_machine_name/System.img of=/OVS/running_pool/vm_machine_name/System1.img bs=1024 count=31457280

Which has reduced the size of System.img to 30 gb.
Modified vm.cfg to include System1.img Instead of System.img.

Started the VM machine.
(Note:It is not advised to do as most of the time you end up getting blue dump for window machines.Not checked on linux machine.)

Linux useful Links

With lot of website claiming to teach you Linux I would like to recommend some of them here .
Each one having unique way describing Linux.

I Love to spend some of my time reading.

http://www.linuxuser.co.uk

My Favorite Linux Forums.

http://www.linuxquestions.org


http://www.unix.com

My Favorite Linux Blog.

http://www.thegeekstuff.com

My Favorite Place for Searching RPMs.

http://search.rpmseek.com

A Must Read Article for Linux Performance Monitor.My personal favorite.

http://www.thegeekstuff.com/2011/03/linux-performance-monitoring-intro/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29

Good way to learn linux from scratch

http://www.linuxfromscratch.org/lfs/

Wednesday, March 2, 2011

Fdisk and parted.

Both the commands are used for partitioning the disks ,creating and managing Linux file systems.
choice of command is personal preference.


Note:

Why should you use parted instead of fdisk?
1) Starting from RHEL 6, Redhat recommends use of parted.
2) fdisk doesn’t understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted(8).
3) You can't use fdisk for drives greater than 2TB size. you need to use parted utility for that.
source:

http://www.linuxquestions.org/questions/linux-newbie-8/fdisk-v-s-parted-864481/

For all the system administrators fdisk is more common but considering Linux future Admin dudes should learn parted .

Lets learn How the same task can be performed using different fdisk and parted commands.