Posts

Showing posts from June, 2011

Some Scripting Excersises

1.) Using Test Command to find Wether entered Argument is File or Directory. [root@server2 ~]#cat test.sh test -d $1 ks=`echo $?` if [ $ks -eq "0" ];  then  echo $1 is Directory;  else  echo "Entered Argument is not Directory" fi [root@server2 ~]# [root@server2 ~]#./test.sh /etc /etc is Directory [root@server2 ~]# [root@server2 ~]#./test.sh /etc/passwd Entered Argument is not Directory [root@server2 ~]# 2.) Bash For Loop Example for Unzip all the Zip file The following example finds the list of files which matches with “*.zip*” in the root directory, and creates a new directory in the same location where the zip file exists, and unzip the zip file content. # cat zip_unzip.sh #! /bin/bash # Find files which has .zip for file in `find /root -name "*.zip*" -type f` do # Skip the extension .zip dirname=`echo ${file} | awk -F'.' '{print $1}'` # Create the directory mkdir $dirname # Copy the zip file cp ${file} ${dirnam...

Yum groupinstall !

Yum groupinstall may save your hours! Today I was creating some kind of setup, So during performing those installation steps, I have found one interesting and time saving option that is used with yum command  and can make our tasks really easy. The option is groupinstall and the whole command is "yum groupinstall <"package name">". Though I was little aware of this But have never gone through this. So today I have just done some R&D on this and here is the result. The option "groupinstall" is used to install all the package related to particular type of software. Suppose I want to install all Mysql Database Packages, then instead of installing packages one by one you can make the use of command given below. [root@server2 ~]#yum groupinstall "MySQL Database"  Now question may arise from where I have got string <"MySQL Database">, So answer is before running above command use following command for listing available group...

Identifying main traffic sources with netstat and awk (one-liner explained)

This is line command to get rid of All the hosts using web server. For this we can make the use of handy netstat command. Sample of eventual output: #netstat -natp | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | tail      25 195.150.23.130      25 67.222.164.140      28 95.34.20.117      31 72.45.232.204      34 209.56.4.6      36 64.27.200.208     106 50.17.245.114     112 209.234.226.230     247 216.242.75.236     283 184.106.21.219 You can use this command on any other port that you want to search. Let me break this long command and explain the things to make them more understandabe. First of all – how many connections are there to the web server: #netstat -natp | grep :80 | wc -l 459 netstat is a very versatile tool. In this case, the flags being used state the following: “ -n ” Numerical representation of th...

Some Useful Info about Firefox's "about" Protocal

Image
Firefox "about" Protocol First of all : What is Protocol in Firefox?                        A protocol is the part of a web address before the colon. For example, web pages are normally http or https protocols. If you click on a link that specifies a protocol other than http: or https: (such as aim:goim?screenname=MozillaSupport ), you may receive an error message like: Firefox doesn't know how to open this address, because the protocol (aim) isn't associated with any program .             Today I have found some interesting thing about firefox.After that I have found that we can do a lots of things with firefox or we can make some changes in in "about:config" section to increase performance of Firefox. In Detail I'll write in Next post. In this post I will just show the different options with about protocol wit...