Tuesday, October 6, 2009

Nagios Twitter Plugin

Send your Nagios alarms to your twitter account

1-. Create a twitter bot user
2-. logon with your new twitter bot
3-. go to settings
4-. mark your updates as private
5-. logout
6-. logon with your regular twitter user
7-. follow your twitter bot
8-. logout
9-. logon again with your twitter bot
10-. accept the follow request
11-. logout
12-. logon again (Argh!) with your regular twitter user
13-. ssh/telnet to your nagios installation
14-. go to your nagios objects directory (/usr/local/nagios/etc/objects)
15-. paste this (change user and password) into commands.cfg

define command {
command_name alarma-twitter
command_line /usr/bin/curl --connect-timeout 30 --max-time 60 -u YOUR_TWITTER_BOT_USER:YOUR_TWITTER_BOT_PASSWORD -d status="$SERVICEDESC$@$HOSTNAME$ is $SERVICESTATE$ ** $SERVICEOUTPUT$ ** Date: $SHORTDATETIME$" http://twitter.com/statuses/update.xml
}

16-. paste this into templates.cfg

define contact {
name twitter_contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands alarma-twitter
host_notification_commands alarma-twitter
register 0
}

17-. paste this into contacts.cfg

define contact{
contact_name twitter_jorge
use twitter_contact
alias Twitter Jorge
}

18-. edit some service you have defined and select “twitter_jorge” as contact

define service{
use passive_service
hostgroup_name servidores_solaris
contacts twitter_jorge
service_description Prueba NSCA
}

19-. submit a passive check for this service
20-. go to your twitter homepage,

Formating a hard disk and create partition

Steps - Formating a hard disk and create partition
[ create partition first and format that partition ]
fdisk -l
fdisk /dev/sdb
    p - partition list
    n - new
    p - primary
    1
    p - partition list
    w - save
partprobe /dev/sdb
mkfs.ext3 /dev/sdb1
fdisk -l
mount /dev/sdb1 /u01
df -sh - to list disk file system
fsck.ext3 /dev/sdb1 - to check the file system

e2label /dev/sdb1 sdb1
mount LABEL=sdb1 /u01/

Create a Yum Repository from ISO Images

Fedora Core 3, Fedora Core 4, Fedora Core 6

  1. Create a yum repository from your DVD
    • # mkdir -p /path/to/your/repo/dvd
      # chcon -t mnt_t /path/to/your/repo/dvd
      # mount -r -o loop /path/to/FC-6-i386-DVD.iso /path/to/your/repo/dvd
      # cd /path/to/your/repo
      # rpm -Uvh dvd/Fedora/RPMS/createrepo*
      # createrepo .
      /!\ Be careful with your directory hierarchy; it is important that the only RPM files that live in the /path/to/your/repo directory or anywhere underneath that directory are the RPMs from your DVD ISO (i.e. the ones in the dvd/Fedora/RPMS directory); any other RPMs that may be present will also be found by createrepo and included in the repository, which is probably not what you want.
  2. Ensure that the DVD ISO image is mounted at every reboot
    • edit /etc/fstab and add new line:
      /path/to/FC-6-i386-DVD.iso /path/to/your/repo/dvd iso9660 ro,loop 0 0
  3. Configure yum to use your new repository
    • edit /etc/yum.repos.d/fedora.repo or /etc/yum.repos.d/fedora-core.repo, whichever one is present
    • comment out any line starting with baseurl or mirrorlist
    • add a new line:
      baseurl=file:///path/to/your/repo
You should then be able to use your local repository to install new packages etc.

Fedora Core 5

It's particularly useful to set up a local [core] repository in Fedora Core 5 because pirut, the standard GUI package manager application, is built on yum and will hence take files from your local repository instead of having to go to the Internet to get them - pirut currently doesn't support installation from CD/DVD natively.
/!\ The metadata on the Fedora Core 6 DVD uses media: URLs, which yum does not understand, so it's necessary to take the same approach as for Fedora Core releases 3 and 4 in Fedora Core 6.

Using DVD ISO

In Fedora Core 5, the installer is based on yum and so there is actually yum repository metadata present on the DVD. This makes the process of setting up the local repository even easier, since you don't need to create the metadata yourself.
  1. Create a directory for your repository and mount the DVD ISO there:
    • # mkdir -p /path/to/your/repo
      # mount -r -o loop /path/to/FC-5-i386-DVD.iso /path/to/your/repo
  2. Ensure that the DVD ISO image is mounted at every reboot
    • edit /etc/fstab and add new line:
      /path/to/FC-5-i386-DVD.iso /path/to/your/repo iso9660 ro,loop 0 0
  3. Configure yum to use your new repository
    • edit /etc/yum.repos.d/fedora-core.repo
    • comment out any line starting with baseurl or mirrorlist in the [core] repository section at the top
    • add a new line:
      baseurl=file:///path/to/your/repo

Using CD ISO images

/!\ Note: I don't have the CD ISO images myself so I haven't tested this procedure with Fedora Core 5.
Creating a repository from CD ISO images is somewhat more complicated, since there are multiple images. There are a number of approaches that could be taken to work around this:
  • Use something like jigdo to create a single image equivalent to the DVD ISO (jigdo templates for Fedora Core 5 can be found at http://www.jburgess.uklinux.net/jigdo/index.html)
  • Mount all of the CD images simultaneously and create a symlink farm to the packages on each CD
  • Copy the packages from the CD images and make a local repo that's independent of the original CD images
I've chosen to take the latter approach here.
  1. Create a directory on your system to hold the repository. It will need to be on a filesystem that has at least 3GB of free space. Then copy the RPM packages and comps.xml file from your CD images into it.
    • # mkdir -p /path/to/your/repo/RPMS
      # cd /path/to/your/repo
      # mkdir disc1 disc2 disc3 disc4 disc5
      # mount -r -o loop /path/to/FC-5-i386-disc1.iso disc1
      # mount -r -o loop /path/to/FC-5-i386-disc2.iso disc2
      # mount -r -o loop /path/to/FC-5-i386-disc3.iso disc3
      # mount -r -o loop /path/to/FC-5-i386-disc4.iso disc4
      # mount -r -o loop /path/to/FC-5-i386-disc5.iso disc5
      # cp disc*/Fedora/RPMS/* RPMS
      # cp disc1/repodata/comps.xml .
  2. You no longer need the CD images, so you can unmount them and remove the mountpoint directories.
    • # umount disc1 disc2 disc3 disc4 disc5
      # rmdir disc1 disc2 disc3 disc4 disc5
  3. Create the repository metadata.
    • # rpm -Uvh RPMS/createrepo*
      # createrepo -g comps.xml .
  4. Configure yum to use your new repository
    • edit /etc/yum.repos.d/fedora-core.repo
    • comment out any line starting with baseurl or mirrorlist in the [core] repository section at the top
    • add a new line:
      baseurl=file:///path/to/your/repo

Using Add/Remove Software With No Network Connection

If you want to use the Add/Remove Software application (pirut) with no network connection, you'll need to disable all of the yum repositories apart from your local one. By default, the only enabled repositories are core (which is now served by your local repository), updates, and extras. You can disable these repositories by changing the line enabled=1 to enabled=0 in /etc/yum.repos.d/fedora-updates.repo and /etc/yum.repos.d/fedora-extras.repo respectively.
If at a later time you have an Internet connection available and would like to update your system or install something from Fedora Extras, you can enable these repositories on the yum command line without needing to edit the .repo files again, e.g.:
# yum --enablerepo=updates --enablerepo=extras update
# yum --enablerepo=updates --enablerepo=extras install somepackage
 
 
iso images
==========

 
http://archive.fedoraproject.org/pub/archive/fedora/linux/core/6/i386/iso/ 

Create new SVN Repository

  Login into host.domain.org with root user credentials

  1. cd  /export/repositories/
  2. create new repository using the command "svnadmin create "
  3. cd  /etc/svn-auth/
  4. create authentication file for repository with first user using the command "htpasswd –cm svn-auth-file- "
  5. Enter the password for the username
  6. cd  /etc/httpd/svn/
  7. Create the apache .conf file for the repository in the /etc/httpd/svn/ folder with the following contents

    Server Name
    host.domain.org

    DAV svn
    SVNPath /export/repositories/
    AuthType Basic
    AuthName " Repository –host.domain.org "
    AuthUserFile /etc/svn-auth/svn-auth-file-<repo name>
    Require valid-user

  8. Restart the apache server using the command "/etc/init.d/httpd restart"
User management in the repository

  1. Login into the host.domain.org server using the root credentials.
  2. Goto the repository auth file folder using the command " cd /etc/svn-auth/"
  3. To create new user "htpasswd –m svn-auth-file- " and then give the password.
  4. To delete the user use the following command "htpasswd –D svn-auth-file- ''username"
  5. To change the user's password, use the following command "htpasswd –m svn-auth-file- " and then give the new password.
  6. To view the users in the SVN account,use the following command ''more svn-auth-file-reponame

Installing Glass Fish

Step:1

Extracting the glassfish installer jar file.

Command: java -jar fileName.jar

The above command will extract the jar file.

Step:2

Get into that extracted glassfish folder.

Step:3

Install glassfish by executing proper command for installation.

Command: lib/ant/bin/ant -f setup.xml

The above command may vary for Fedora Linux environment. Use internet to find the exact command.

Step:4

Get into glassfish/bin/

Double click asadmin file. This will open up one terminal.

Then type start-domain domain1

This will start the server.

Then GOTO browser and type http://localhost:4848

This should open up the server login page.

HTTP error/server response codes reference

Below is a brief explanation of various common HTTP browser error codes and server response codes.   
Code Number Browser
Error Message
Description
200 none This is the normal response where a page has been successfully fetched
301 none Page has moved permanently. usually a response from implementing a 301 redirect
302 none Page has moved temporarily
304 none Page has not been modified since last request (this is an OK response)
400 Bad Request The request could not be understood by the server due to incorrect syntax. 
401  Unauthorized User authentication is required.
403   Forbidden The server understood the request, but is refusing to fulfill it.
404  Page Not Found The server has not found anything matching the Request-URI.
405 Method Not Allowed The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. 
406  Not Acceptable The server cannot generate a response that the requestor is willing to accept.
407 Proxy Authentication Required  This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy. 
408  Request Timed Out  The server stopped waiting for a client request.
409  Conflict The request could not be completed due to a conflict with the current state of the resource.
410  Gone The requested resource is no longer available at the server and no forwarding address is known. This condition is similar to 404, except that the 410 error condition is expected to be permanent.
411. Length Required The server requires a content-length in the request
412 Precondition Failed The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
413 Request Entity Too Large The server is refusing to process a request because the request entity is larger than the server is willing or able to process. 
414  Request URL Too Long The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.
415 Unsupported Media Type The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method. 
500  Server Error  Internal Web server error
501 No Server Function not implemented in Web server software 
502  Server Overload Bad Gateway; a server being used by this Web server has sent an invalid response.
503 Service Unavailable Service unavailable because of temporary overload or maintenance. 
504  Gateway Timeout A server being used by this server has not responded in time.
505  HTTP Version Not Supported The server does not support the HTTP protocol version that was used in the request message.

Redhat History


1968

ARPANET founded. The precursor to the Internet, it allows researchers to share code and information.

1969

Ken Thompson, researcher at Bell Labs, writes the first version of Unix.

1979

AT&T announces plans to commercialize Unix.

1983

Richard Stallman establishes the Free Software Foundation at MIT. The GNU project to construct an operating system based on Unix but for which the source code is freely available, begins. Stallman also establishes the idea of "copyleft" and the General Public License (GPL).

1987

Andrew Tanenbaum releases Minix, a version of Unix for the PC, Mac, Amiga, and Atari ST. Source code included.

1989

Michael Tiemann (Red Hat Vice President, Open Source Affairs) co-founds Cygnus Solutions, the first business to provide custom engineering and support services for free software.

1991

Linus Torvalds releases the Linux kernel.
Bob Young introduced to free software and UNIX by the system administrators of the New York City UNIX Users Group (Unigroup).

1993

Young incorporates ACC Corporation, a catalog business that sells Linux and Unix software accessories and books and distributes a magazine called New York UNIX

1994

Marc Ewing creates his own distribution of Linux which he names Red Hat Linux. Released in October, it becomes known as the Halloween release.

1995

Young buys Ewing's business, merges it with ACC Corporation, and names the new company Red Hat Software.
Red Hat Linux 2.0 is released, officially unveils the new package management system called RPM.

1996

Red Hat opens sales and administration functions to North Carolina, opens corporate headquarters in Durham.

Saturday, September 19, 2009

mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database dbname;
Query OK, 1 row affected (0.01 sec)


mysql> grant all privileges on dbname.* to 'dbname'@'localhost';
Query OK, 0 rows affected (0.00 sec)


mysql> grant all privileges on dbname.* to 'dbname'@'%';
Query OK, 0 rows affected (0.00 sec)

Friday, September 18, 2009

Disk space usage using df command.

To get a listing of free space on all mounted filesystems execute df command with no arguments.

# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 33423168 16560892 15137044 53% /
/dev/sda1 101086 14952 80915 16% /boot
tmpfs 257560 0 257560 0% /dev/shm


Use the df command with -h option to displays the space in human-readable units , the example below show the freespace available in Mb unit:

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 32G 16G 15G 53% /
/dev/sda1 99M 15M 80M 16% /boot
tmpfs 252M 0 252M 0% /dev/shm


Note: The Use% column shows what percentage of the filesystem that currently in use.

To show space on the filesystems those directories are mounted on:

# df /boot
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 101086 14952 80915 16% /boot


The df command can be use to get information on inode usage on all mounted filesystem.  To show the inode information execute df command with the ( -i  ) option:

df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/VolGroup00-LogVol00 8633856 313455 8320401 4% /
/dev/sda1 26104 37 26067 1% /boot
tmpfs 64390 1 64389 1% /dev/shm


The following are some of the flags and arguments that can be used for the df command:
-a, --all include filesystems having 0 blocks
-B, --block-size=SIZE use SIZE-byte blocks
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si likewise, but use powers of 1000 not 1024
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local filesystems
--no-sync do not invoke sync before getting usage info (default)
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
-t, --type=TYPE limit listing to filesystems of type TYPE
-T, --print-type print filesystem type
-x, --exclude-type=TYPE limit listing to filesystems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit

NAME:
df - report filesystem disk space usage
Usage: df [OPTION]... [FILE]...

for more information on df command:
# info df
# man df
# df --help

Display the size of file and directory in Linux

[root@fedora ~]# du -h
4.0K ./.rhopenoffice1.1/program/addin
108K ./.gnome2
28K ./.nautilus/metafiles
32K ./.nautilus
6.0M ./.mozilla/firefox/1wvl2gwo.default/Cache
12K ./.mozilla/firefox/1wvl2gwo.default/chrome
12M .
 
The output from above command show the size of each file, directory and with the total size used in your system in human readable size ( -h ).
 

Get the total size of current directory.

 
   The du command can be use to determine the total size of file in current directory.  The example below show the du command use with -s (summarize) and -h (human readable format) option to summaries the size of disk space taken by current directory.
 
[root@fedora ~]# du -s
768096 .
[root@fedora ~]# du -sh
751M .
[root@fedora ~]#
 
To get the size of file and directory in current directory.
 
[root@fedora ~]# du -sh *
14M 20060524-033-x86.exe
85M labu-punyer
8.0K libjmti.odt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K yumex-0-1.0.1-1.0.fc5.html
408K yumex-1.0.1-1.0.fc5.noarch.rpm
8.0K yum install
11M zope-2.8.5-1.fc5.i386.rpm
[root@fedora ~]#
 

Display the size of specific file extension.

 
   The example below show du command execute with -c option to get the size of each file that have filename ending with .txt and then display grand total of all files in human readable format.
 
[root@fedora ~]# du -ch *.txt
4.0K create.drupal-2.txt
4.0K create.drupal.db.txt
4.0K drupal-pass.txt
4.0K joomla-bazz.txt
4.0K linux-feeds.txt
4.0K mambo_conf.txt
8.0K msql-bazz.txt
4.0K setup_mysql_mambo.txt
4.0K simple.txt
40K total
[root@fedora ~]#
 

Check the size of home directory.

 
   The example below show the use of du command to get the disk usage of each user home directory on the system.
 
[root@fedora home]# pwd
/home
[root@fedora home]# du -sh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
[root@fedora home]#
 
To produce grand total of the /home directory size.
 
[root@fedora home]# pwd
/home
[root@fedora home]# du -csh *
492K bazz
48K botol
44K hamirul
22M kambing
48K kayu
56K labu
80K sysuser
40K william
40K ycluckers
23M total
[root@fedora home]#
 
The following are some of the flags and arguments that can be used for the du command:
 
· -a, --all         write counts for all files, not just directories
· --apparent-size         print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in (`sparse') files, internal fragmentation, indirect blocks, and the like
· -B, --block-size=SIZE         use SIZE-byte blocks
· -b, --bytes         equivalent to `--apparent-size --block-size=1'
· -c, --total         produce a grand total
· -D, --dereference-args         dereference FILEs that are symbolic links
· -H like --si, but also evokes a warning; will soon change to be equivalent to --dereference-args (-D)
· -h, --human-readable         print sizes in human readable format (e.g., 1K 234M 2G)
· --si like -h, but use powers of 1000 not 1024
· -k like --block-size=1K
· -l, --count-links count sizes many times if hard linked
· -L, --dereference dereference all symbolic links
· -P, --no-dereference don't follow any symbolic links (this is the default)
· -0, --null end each output line with 0 byte rather than newline
· -S, --separate-dirs do not include size of subdirectories
· -s, --summarize display only a total for each argument
· -x, --one-file-system skip directories on different filesystems
· -X FILE, --exclude-from=FILE Exclude files that match any pattern in FILE.
· --exclude=PATTERN Exclude files that match PATTERN.
· --max-depth=N print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize
· --help display this help and exit
· --version output version information and exit
 
NAME
du - estimate file space usage
 Usage: du [OPTION]... [FILE]...
Summarize disk usage of each FILE, recursively for directories.
 
More information on du command:
# info du
# man du
# du --help

Cancel Shutdown on Fedora Linux using shutdown Command

Running Shutdown Process on Background


1.  Running shutdown process on background... The shutdown command bellow tell Fedora system to shutdown at 8:00 pm (20:00).
Cancel Shutdown on Fedora Linux using shutdown command, Running shutdown process on background
[root@fedora ~]# shutdown -h 20:00 "shutdown in progress" &
[1] 3143
[root@fedora ~]#
Broadcast message from root@fedora.linux.com
        (/dev/pts/1) at 4:11 ...

The system is going down for halt in 949 minutes!
shutdown in progress

[root@fedora ~]#

Cancel Shutdown


2.  To cancel shutdown that in progress on Fedora system, execute shutdown -c as show on example below
To cancel shutdown that in progress on Fedora system
[root@fedora ~]# shutdown -c "cancel shutdown"

Broadcast message from root@fedora.linux.com
        (/dev/pts/0) at 4:28 ...

cancel shutdown
[root@fedora ~]#

Shutdown error:


1.  If you get the "-bash: shutdown: command not found" error when execute shutdown command as show on example below...
Shutdown:
[fedora@fedora ~]$ shutdown -h 20:00 "shutdown in progress"
-bash: shutdown: command not found
[fedora@fedora ~]$

Cancel Shutdown:
[fedora@fedora ~]$ shutdown -c "cancel shutdown"
-bash: shutdown: command not found
[fedora@fedora ~]$

Shutdown error solutions:


 2.  you may need to log in as root user to execute shutdown command....or use the su command as show on example below and supply the root user password when ask...

Shutdown:
[fedora@fedora ~]$ su - -c "shutdown -h 20:00 'shutdown in progress'&"
Password:
[fedora@fedora ~]$
Broadcast message from root@fedora.linux.com
        (unknown) at 4:42 ...

The system is going down for halt in 918 minutes!
shutdown in progress

[fedora@fedora ~]$

Cancel Shutdown:
[fedora@fedora ~]$ su - -c "shutdown -c 'cancel shutdown'"
Password:
shutdown: Shutdown cancelled

Broadcast message from root@fedora.linux.com
        (/dev/pts/1) at 4:41 ...

cancel shutdown
[fedora@fedora ~]$

Note: This canceling shutdown command above have been tested on Fedora 7, Fedora 8, Fedora 9, Fedora 10

check Linux Version and System Information

Get and display all system information on Linux machine:
Dispaly Linux system information uname -a
[root@fedora ~]# uname -a
Linux fedora.linux.com 2.6.25-14.fc9.i686 #1 SMP Thu May 1 06:28:41 EDT 2008 i686 i686 i386 GNU/Linux
[root@fedora ~]#

Get and display the Linux kernel name:
Dispaly Linux kernel name uname
[root@fedora ~]# uname
Linux
[root@fedora ~]#

or
[root@fedora ~]# uname -s
Linux
[root@fedora ~]#

Get and display Linux hostname or node name:
Display Linux Hostname uname
[root@fedora ~]# uname -n
fedora.linux.com
[root@fedora ~]#

Get and display Linux kernel release or could be use to check kernel version name :
Display Linux kernel release
[root@fedora ~]# uname -r
2.6.25-14.fc9.i686
[root@fedora ~]#

Get and display Linux kernel version:
Display Linux kernel version
[root@fedora ~]# uname -v 
#1 SMP Thu May 1 06:28:41 EDT 2008
[root@fedora ~]#

Get and display Linux machine hardware name:
Display Linux hardware name
[root@fedora ~]# uname -m
i686
[root@fedora ~]#

Get and display Linux processor name:
Display Linux processor name
[root@fedora ~]# uname -p
i686
[root@fedora ~]#

Get and display Linux hardware platform:
Display Linux Hardware Platform name
[root@fedora ~]# uname -i
i386
[root@fedora ~]#

Get and display Linux operating system name:
Display Linux Operating System with uname
[root@fedora ~]# uname -o
GNU/Linux

Thursday, September 17, 2009

Adding a port to firewall

iptables -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT

To Delete the Virtual Box :

VBoxDeleteIF vbox0
VBoxDeleteIF vbox1

To List the Bridge connection in Linux

brctl show

Down the bridge connection

ifconfig br0 down

To list the networkconfiguration

cmd : ifconfig

Edit the DNS Configuration for linux

vi /etc/resolv.conf

To make Ethernet configuration up

ifconfig eth0 up (Or) ifup eth0

Adding subnet mask ,default gateway

route add -net 10.10.16.0 netmask 255.255.240.0 eth0

Adding bridge connection

VBoxAddIF vbox0 root br0

To remove the default gateway

route del default gw
route add default gw


To list the port

netstat -tulpn | less

To check the process runnning on linux

ps -aux

JAVA PATH Setup in Linux

Edit vi /etc/profile

export ANT_HOME=/opt/sfw/apache-ant-1.7.0
export JAVA_HOME=/opt/sfw/jdk1.6.0_06
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$ANT_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH

Burn ISO image to DVD

cdrecord -v -sao dev=/dev/hda UDF_Volume.iso

Steps to install memcache


1)# which phpize

2)If the result is usr/bin/phpize then run the command

#export PATH=/opt/lampp/bin:$PATH.

3)Install memcached using

#apt-get install memcached.

4)Download memcache client using the command

#wget http://pecl.php.net/package/memcache/memcache-2.2.5.tar.gz

5)Extract the downloaded package using the command

#tar -xzf memcache-2.2.5.tar.tz

6)# cd memcache-2.2.5

7)# /opt/lampp/bin/phpize

8)# ./configure -enable-memcache -with-php-config=/opt/lampp/bin/php-config-5.1.6(your php version)

9)If u get “c compiler cannot create executable files” then u need to run

#apt-get install build-essential

10)If u get Zlib-dir not found then u need to execute

#./configure -enable-memcache –with zlib-dir=/opt/lampp –with-php-config=/opt/lampp/bin/php-config-5.1.6(your php version)

11)# make

12)# make install

13)open php.ini and search for extension and add

extension=” memcache.so”

and

when we execute make install it will give you the extensions folder path copy that and add it in php.in.

For example:

when we execute make install command the path displays like

“/opt/lampp/lib/php/extensions/no-debug-non-zts-20050922” and now we need to add the below statement to php.ini

“extension-dir=/opt/lampp/lib/php/extensions/no-debug-non-zts-20050922 to php.ini”

14)Restart your server

15)Open browser and give http://localhost/xampp/phpinfo

search for memcache in browser you will find it else again run the complete steps again.

Setting up public key authentication over SSH

applelinuxmisc

Every time I want to setup public key authentication over SSH, I have to look it up, and I've never found a simple guide, so here's mine.

Generate key on local machine

ssh-keygen -t rsa

It will ask you for a password but you can leave it blank.

Note you could also pick -t dsa if you prefer.

Ensure that the remote server has a .ssh directory

Make sure the server your connecting to has a .ssh directory in your home directory. If it doesn't exist you can run the ssh-keygen command above, and it will create one with the correct permissions.

Copy your local public key to the remote server

If your remote server doesn't have a file called ~/.ssh/authorized_keys2 then we can create it. If that file already exists, you need to append to it instead of overwriting it, which the command below would do:

scp ~/.ssh/id_rsa.pub remote.server.com:.ssh/authorized_keys2

Now ssh to the remote server

Now you can ssh to the remote server without entering your password.

Security

Now keep in mind that all someone needs to login to the remote server, is the file on your local machine ~/.ssh/id_rsa, so make sure it is secure.

Creating users in Win XP through command prompt

We all know how to create a new user account in Windows XP .

Just go to Start and click on Control panel. Now open the "user account tool".

Here you will be seeing an option Like "create an account".
Well enter any windows XP user and click on create account.
This is how you will be creating a new Windows XP user.

But there is a different procedure to create a new Windows Xp user using dos prompt.

To create a new account you have to type as follows :
net user USERNAME PASSWORD \ADD

To delete the account type as follows :
net user USERNAME \del

To get admin rights type as follows :
net localgroup administrators username \add

The complete command is
[username [password | *] [options]] [/DOMAIN]
username {password | *} /ADD [options] [/DOMAIN]
username [/DELETE] [/DOMAIN]

DB Dumps

MySql Dump

mysqldump --protocol tcp -P portnumber -h localhost -u root databasename > filename.sql

DB dump of all database

shell> mysqldump --all-databases > all_databases.sql

Postgresql dump

To get the database dump execute the below commands from outside the database

1. /usr/bin/pg_dump -U postgres -f - only for structure;
2. /usr/bin/pg_dump -U -d > - data + structure;

3.pg_dump dbname -U username -h hostname -p > filename.sql

4.pg_dumpall -U username -h hostname -p > filename.sql

Mysql Commands

To list the users,host in the mysql

select Host ,User ,Password from mysql.user;

To set mysql root password

mysqladmin -u root password newpassword ;


To delete the host from mysql

DELETE FROM mysql.user where host=hostname;


To drop the user

DROP USER 'desiyou'@'localhost';


To Start the multiple instance in Mysql


mysqld_multi --config-file=/etc/my2.cnf start 1
mysqld_multi --config-file=/etc/my2.cnf start 2


Mysql Case Sensitive

vim /etc/my.cnf

lower_case_table_names=1

To know the status of mysql :

SHOW STATUS;

To know the mysql process status :

SHOW FULL PROCESSLIST\G
show variables;