Bash Script to get public ip

#!/bin/bash




pubip=$( curl http://ip4.me 2>/dev/null | sed -e 's#<[^>]*>##g' | grep '^[0-9]' )



echo $pubip



you can replace curl command with



curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' 

Apache hardening tips - Subhash C

# Server banner


ServerSignature Off // will not show apache version etc
ServerTokens Prod // Will hide OS version etc

# Disable TRACE requests

TraceEnable off

### Security Fixes

RewriteEngine on

RewriteCond %{REQUEST_METHOD} ^(TRACE
TRACK)

RewriteRule .* - [F]

Some Find commands regularly used for finding disk usage


find . -size +500000 -print

du -ch | grep total ( total size of directory)

du -sk * | sort -nr | head -3

find /home -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head

find / -type f -size +300000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

du -hs /home/* | grep G

du -hs /home/* | grep M

Command to import SSL certificate need for java applications

keytool -import -alias anotherdomainname -file /tmp/certificatename.cer -keystore $JAVA_HOME/jre/lib/security/cacerts

How to reset winsock entries and reset TCP/IP stack in windows7


goto command prompt then enter below two commands

netsh winsock reset catlog

netsh int ip reset reset.log hit


then reboot your pc

Step by Step method to install Media Wiki

Step-By-Step Installation Procedure of Mediawiki on Ubuntu Server 9.04 or Other Distribution as well (If it is rpm distribution replace aptitude/apt-get to yum)

Ubuntu installation using these commands:
aptitude Update
aptitude install apache2 mysql-server php5 php5-mysql mediawiki php5-gd -y

After installation Make sure that Apache is up and running

gedit /etc/apache2/apache2.conf 

(Note that it’s a good idea to back up any system configuration file before editing it. You can do so quickly by using sudo cp /etc/apache2/apache2.conf ~/Desktop to save a copy to your Desktop. You can of course use vi or emacs or the editor of your choice, but most new users seem to prefer gedit’s GUI.)

Once you are in gedit, add the following line to the end of the file:

AddType application/x-httpd-php .html 

Save the file and exit gedit.
Now we’ll need to prepare MySQL for use with MediaWiki. First, you’ll need to run MySQL’s install script:
sudo mysql_install_db
Once this is completed, log into the MySQL command-line client:
mysql -u root –p
Enter your MySQL root user password from above, and you’ll find yourself at the MySQL> local client prompt. First, create a database for MediaWiki to use:
CREATE DATABASE mediawiki;
(Note that all commands entered in the MySQL local client must end with a semicolon to denote the end of the statement.)

Once the database is created, you’ll need to create a database user so MediaWiki can access your newly created database. While still in the MySQL command line client, type this:

CREATE USER mediawikiuser; 

Then create a password for your new user (note that your password will actually go within the quotation marks, and is case-sensitive):

SET PASSWORD FOR mediawikiuser = PASSWORD(“password”); 

Now that you’ve got your MediaWiki database and your MediaWiki database user, you’ll need to grant the user all permissions on the database (again, the password goes within the quotation marks, and is case sensitive):

GRANT ALL PRIVILEGES ON mediawiki.* TO mediawikiuser@localhost IDENTIFIED BY ‘password’; 

(Make sure to append “@localhost” to mediawikiuser; otherwise you might get a database error later on when MediaWiki tries to run its installation script.)
Configure MediaWiki
gedit /etc/mediawiki/apache.conf
Remove the '#' on the third line so that line reads:

Alias /mediawiki /var/lib/mediawiki
/etc/init.d/apache2 restart 
http://localhost/mediawiki ( Follow up the Index page Configuration U need to give the database username and password etc)
Note: makesure user the username, password and Database should be correct