Thursday, January 24, 2013

fvwm and network-manager

if you want to run fvwm with network-manger,

you can install stalone tray to run network-manager on fvwm,

#sudo apt-get install stalonetray

then from fvwm terminal run 

#stalonetray --dockapp-mode simple &


and for network-manger run

#nm-applet &

you will get network manager

Sunday, November 25, 2012

Chainloading Grub2 from Grub

add following entry into grub,


title grub2_os
root (hd0,0)
kernel /boot/grub/core.img
boot

replace root partition number for grub2 os on second line ex. partiton no 1 then second line should be
 root (hd0,1).

partition number start with so , if df command display partition as sda6 then number should be 5.

Thursday, November 15, 2012

java monitoring memory usage on server

If you want to see how memory used by java process using command line tools.
You can use jmap command on server.

First you need to get the process id using ps or jps command.

Then use following command, to see memory consumption by java process.

on 32 bit OS you need to use,

jmap -J-d32 -heap <process_id>

on 64 bit os you need to use,

jmap -J-d64 -heap <process_id>

Securing EC2 instance with Dynamic Ip

In order to secure ubuntu ec2 instance all port should be closed except port on which you running web server(http port 80, https port 443) on security group applied to ubuntu instance.

but some time you need to login into instance in order to do some maintenance, you need to open port ssh server.

If you have static ip from your connection provider, it is easy, you just need to add rule to open ssh port for that specific ip from aws console.

You can do the same thing with dynamic ip but every time your internet connection public ip change, you need to again add rule from aws console,

Or you can use following command to add your public ip to your security group (You need to have ec2-api-tools setup before using following command https://help.ubuntu.com/community/EC2StartersGuide),

ec2-authorize <security_group_name> -p 22 -s `w3m -dump http://www.monip.org/ | awk -F': ' '/IP/ { print $2 }' | sed -n 1p`/32

and if you need to specify aws region then,

ec2-authorize <security_group_name> --region <region_name> -p 22 -s `w3m -dump http://www.monip.org/ | awk -F': ' '/IP/ { print $2 }' | sed -n 1p`/32


when you are debugging something, looking at dmesg command output, you seen some problem with os in log, but don't know when it is happen because format of time is not easily readable then,

gist python script posted by some one https://gist.github.com/542780 can help you format dmesg output
If you are using ec2-api-tools on ubuntu and getting following error

Client.InvalidSecurity: Request has expired

Most probably your machine date and time is outdated
You need to update it using following command

sudo ntpdate ntp.ubuntu.com


Monday, October 10, 2011

ssh tunneling to access remote mysql on ec2

to acess remote mysql on ec2 as local on port 3307 using ssh tunneling we can use following command(assuming port is close on remote machine),

ssh -i -L 3307:localhost:3306 username@server

This command can be used to acces any other kind of service by changing port number

login as another using sudo

use

sudo -u bash

to login into bash as another user

Sunday, July 3, 2011

Redirecting the request on openx login page

If you are not able to open openx login page due to redirecting request. Then that may be because cookie in your browser for that openx domain is creating some problem.

To solve this problem delete all cookie for that openx domain. Now Try to open login page, you should be able to open openx login page

Tuesday, May 24, 2011

How to copy multiple file from remote host using scp

To copy complete folder then -r swich can be used,

scp -r user@host:folder_path source_path_of_current_machine

To copy selected file from folder, then specify path1 and path2 of file separated by space

scp user@host:"path1 path2" source_path_of_current_machine

And if file is in the same folder then bash file expansion enclosed in double quote can be used,

scp user@host:"foder_path/{file1,file2}" source_path_of_current_machine




Thursday, May 19, 2011

How to run latest or multiple firefox release on linux

I want to run firefox 5 and firefox 6 on my ubuntu lucid while running firefox3.
Use follwing step,

  1. Download firefox 5 and firefox 6 build from mozzila site.
  2. then extract tar file and start the firefox using command 
  3. start firefox5 using,
    #ff5_dir/firefox -P "ff5" -no-remote
  4.  start firefox5 using,
    #ff6_dir/firefox -P "ff6" -no-remote
  5. firefox will prompt you to create new profile give name ff5 for firfox5 and ff6 for firfox 6, after creating profile uncheck option "Don't ask at starup",
  6. Now use the same step 2 command to start firfox 5 and firefox 6 or you can create shortcut with above step 2 command

 


Tuesday, May 17, 2011

How to delete firefox cookie from command line in ubuntu linux

just delete sqlite db file using following command
change home_dir and firefox_profile_name(some random   generated name) accordingly in command

rm home_dir/.mozilla/firefox/firefox_profile_name/cookies.sqlite

How to setup filezilla or Krusader for ec2 on ubuntu linux

add follwing entry int your ssh config file (ex. your_home_dir/.ssh/config)


Host server_address
 IdentityFile ssh_private_key_location
(change server_address and ssh_private_key_location accordingly)
you get ec2 ssh_private_key, when you create keypair in aws_console->keypairs section. They key you need to specify when you boot new instance.also change ssh private key security mode to 600.

Then add site into filezilla->site manager as shown in the above screenshot.

  1. host should be server address
  2. select servertype as sftp
  3. select username on linux instance accordingly
  4. then connect to ec2 instance


and for Krusader you need to specify same thing as shown in the above screenshot


How to use ec2 as proxy using SSH tunnel for geo related web testing on linux

create ssh tunnel using follwing command (change port number,key file address,username and ec2 instance ip address accordingly),
ssh -D 9999 -i key_file_location username@ec2_instance_address
then set SOCKS HOST proxy setting for the firefox (prefernce->network tab) or other browser as shown in the figure


















Close the ssh tunnel once you are done with testing.

how to enable mysql general logging using query without restarting server on ubuntu lucid 10.4.2

to see what's going on inside mysql without restarting server, logging can be enabled using following query

SET GLOBAL general_log_file = '/var/log/mysql/mysql.log';
SET GLOBAL general_log = 'ON'

and logging can be disabled using following query

SET GLOBAL general_log = 'OFF'

Tuesday, May 3, 2011

How to enable openx for geotargeting

install openx  after that download free geoip city database from maximind site and uncompress it.

#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#gunzip -d GeoLiteCity.dat.gz

enable geotargeting in configuration section of openx administration account

copy GeoLiteCity.data to <openx_home>/plugins/geoTargeting/oxMaxMindGeoIP/data
sudo chown www-data:www-data GeoLiteCity.dat
sudo chmod 777 GeoLiteCity.dat

change geoTargeting plugin setting, add "GeoLiteCity.dat" for city data file

in <openx_home>/plugins/etc/oxMaxMindGeoIP/oxMaxMindGeoIP.xml change line as shown below for GeoLiteCity.dat

            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/">oxMaxMindGeoIP.class.php</file>
            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/">oxMaxMindGeoIP.delivery.php</file>
            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/data/">GeoLiteCity.dat</file>

in <openx_home>/plugins/geoTargeting/oxMaxMindGeoIP/oxMaxMindGeoIP.delivery.php change following line
        //$geo = oxMaxMind_getGeo($ip, dirname(__FILE__) . '/data/FreeGeoIPCountry.dat');
        $geo = oxMaxMind_getGeo($ip, dirname(__FILE__) . '/data/GeoLiteCity.dat');

Friday, April 29, 2011

Backup ec2 mysql server on S3 using mysqldump and s3

Below is script to take backup of complete database on S3, also remove 10 day old backup file from S3

You need install s3cmd, and configure it before using this script, also need to create S3 bucket on aws
also change mysql username and password accordingly.



 #!/bin/bash
#below is path of variable to put dump of mysql
DATA=/data
#filename of today
file_name=db_`date +'%d-%m-%Y'`.sql.gz
#filename of today
file_name_10_day_old=db_`date --date='10 days ago' +'%d-%m-%Y'`.sql.gz
#take dump of mysql
mysqldump -u mysql_unsername -p mysql_password --all-databases | gzip > $DATA/$file_name
#push to s3
s3cmd put $DATA/$file_name s3://backup_bucket
#cleanup of file
rm $DATA/$file_name
s3cmd del s3://backup_bucket/$file_name_10_day_old