What I See

What I See

Zubair AHMED  //  Thinking Supersonic

Jan 25 / 4:08pm

Debian: Ubuntu 11.04 Setting Up JAVA - 'update-alternatives'

Posted by email 
I was working on setting JAVA environment for my Ubuntu 11.04 box

Searched a little and found nothing much on how to update default Open java path to sun java.

I downloaded sun package and unzipped in the /opt/java/ directory and set the JAVA_HOME and PATH variables in .bash_profile and .bash_rc.
But still I was not getting the sun java.

Then I check in ubuntu 11 we need to set the update-alternative as well. 

Here is how you do it.

Let say I have the java package in the below directory. 
/opt/java/jdk1.6/

Follow the below steps.
  • Register the java command - here 500 is the priority 
]$ sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.6/bin/java 500
  • Update and set new java path
]$ sudo update-alternatives --set java /opt/java/jdk1.6/bin/java
  • Finally Configure the default java command
]$ sudo update-alternatives --config java

Hope it helps someone.
Filed under  //  HOWTOs  
Dec 15 / 5:48pm

CentOS in Single user mode / root password reset [Default Installation]

Setting 'root' Password for Centos.

Today my friend was having an issue where he was not able to set 'root' password.
As the default installation had a default account without "sudo" privilege.

To set the "root" password for Cent OS  Follow below steps.

1. In the grub boot menu prompt - enter "e" (for edit) to edit boot parameters.
2. Select menu this will bring up 3 or more based on the installation type. root, kernel, initrd

 root (hd0,0)
 kernel /vmlinuz-2.6.8-1.523 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
 initrd /initrd-2.6.8-1.523.img
3. Select "kernel /vmlinuz-2.6.8-1.523 ro root=/dev/VolGroup00/LogVol00 rhgb quiet" and press "e" for edit
kernel /vmlinuz-2.6.8-1.523 ro root=/dev/VolGroup00/LogVol00 rhgb quiet single
4. Now add "single" at the end of the line (<space> single) as you see like the above line and press <enter>
5. Now at the boot menu enter "b" for boot
6. This will bring the system up in single user mode.
7. Enter "passwd root" >> Change your root password.

Enjoy!!

Filed under  //  HOWTOs  
Oct 15 / 4:39pm

Change Boot Configuration on Ubuntu 10.10

My daily work revolves around Windows, Putty.

My laptop which runs Ubuntu 10.10 and Windows 7 as dual boot.
I wanted to change the default boot conf to Windows 7 instead of Ubuntu (which I just use when I am messing around something ).

Anyways, I logged into Ubuntu 10.10 and went to my know place to change boot configuration /boot/grub/menu.lst
But to my surprise it is not there. Little looking around got me want I wanted.

Below is steps you need to follow to change your default boot configuration.

  1. Go to Terminal - Type “sudo vim /etc/default/grub” .
  2. Change “GRUB_DEFAULT=0″ to “GRUB_DEFAULT=4″ 
    • Remember sequence start from 0 , if your OS is on 5th on the list, in boot menu then you enter 4 in the "grub" file.
  3. Save the file.
  4. Type "sudo update-grub” in the terminal.
  5. Reboot and have fun with Windows 7 as the default OS to be booted.
Output for my system.
ahmed@ahmed-on-Edge:/etc/default$ sudo vim grub
[sudo] password for ahmed:
ahmed@ahmed-on-Edge:/etc/default$ update-grub
grub-mkconfig: You must run this as root
ahmed@ahmed-on-Edge:/etc/default$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.38-10-generic-pae
Found initrd image: /boot/initrd.img-2.6.38-10-generic-pae
Found linux image: /boot/vmlinuz-2.6.38-8-generic-pae
Found initrd image: /boot/initrd.img-2.6.38-8-generic-pae
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done
Filed under  //  HOWTOs  
Aug 23 / 4:51pm

Rooting Android Phone "Samsung Galaxy Ace"

I got my Android for a couple of months now and was stock for so long that I had to do something.
So first thing I planned to do was to root it .. :) 

Its very simple 
Attached are 2 files "root.zip" and "unroot.zip"

To root your phone
  1. Copy root.zip to your SD Card (/sdcard)
  2. Rename the file as update.zip
  3. So your file should be in /sdcard/update.zip (you can view this from any file manager you can install from the android market)
  4. restart phone and hold the HOME button you will enter into recovery mode. (as seen the image attached)
  5. select apply sdcard:update.zip
  6. This will root your phone you are all set for nice RnD.
To unroot your phone
  1. Follow the same procedure above, just replace unroot.zip to update.zip
Enjoy !

Click here to download:
unroot.zip (101 KB)

Click here to download:
root.zip (1.11 MB)

23082011019

Filed under  //  HOWTOs  
Aug 11 / 10:53am

Black and White life in Linux to color

Enter the below command to get the color on all the directories / executable files / other files (on Linux)

[zahmed@build ~]$ ls
3.0.0_cores  code_review  rnd  snmp  test_binary
[zahmed@build ~]$ alias l.='ls -d .* --color=tty'
[zahmed@build ~]$ alias ll='ls -l --color=tty'
[zahmed@build ~]$ alias ls='ls --color=tty'
[zahmed@build ~]$ ls
3.0.0_cores  code_review  rnd  snmp  test_binary
Filed under  //  HOWTOs  
Jul 25 / 5:08pm

Running Crontab

My Previous post talks about sending automated emails using mutt.

How do we automate this process say every hour
Then we setup crontab to get this up and running.

Below are few of the options which crontab gives.

crontab -e    Edit your crontab file, or create one if it doesn’t already exist.
crontab -l    Display your crontab file.
crontab -r    Remove your crontab file.
crontab -v    Display the last time you edited your crontab file.

Steps
  1. Enter:  $ crontab -e
  2. If you have not configured EDITOR it will ask for it set which ever you are comfortable with.
  3. Enter your time to execute command information, below is how you give it.

----------------------------------------------
# Every Minute
# m h  dom mon dow   command <Enter you command Here> 
  * *   *   *   *    /home/ahmed/executeMyMuttScript.sh

----------------------------------------------
# Every Hour at zero minute
# m h    dom mon dow   command <Enter you command Here> 
  0 0-23  *   *   *    /home/ahmed/executeMyMuttScript.sh

----------------------------------------------
# Every Hour at 30th minute (1:30, 2:30, 3:30 ...)
# m  h  dom mon dow   command <Enter you command Here> 
  30 *  *   *   *     /home/ahmed/executeMyMuttScript.sh

----------------------------------------------

m h dom mon dow Command
*     *   *  *   *  command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)
Filed under  //  HOWTOs  
Jul 21 / 6:09pm

Configure "mutt" to send mail over SMTP using Google Apps

Click here to download:
dot.muttrc (1 KB)

My Colleague was working on having auto scripts to send mail through "mutt" with backup attachment.
But he was not able get it up, so though of looking into this.

Wondering what "mutt" is go here then :)

Here is what I did to get it working.

  1. If you need to configure anything for mutt first look for .muttrc in your home directory ~/.muttrc
  2. If its not there you can create one.
  3. I have attached my .muttrc file you can use to configure your mutt. (change the email and password)
  4. Just download the dot.muttrc and save it as .muttrc in your home directory (/home/ahmed).
  5. Also create directory in the  path below
  • mkdir -p ~/.mutt/cache/headers
  • mkdir -p ~/.mutt/cache/bodies
  • mkdir -p ~/.mutt/certificates
Before you can start using the script to send your mails -
you need to send the first mail from the "mutt client" so that it takes the certificate from the server.

use
$ mutt

This will bring up the mutt interface - send your test mail from here.
Once that is done. You are all set to use the script.

To test - run the below command in your command prompt.
$ mutt --help
$ mutt -s "Hello Test from the shell Script :)" zubair.ahmed@emailid.com < /dev/null -a <attach a File here>


NOTE for .muttrc
# Non Google App users can just enter the username without the domain name like below.
#set smtp_url = "smtp://zubair.ahmed@smtp.gmail.com:587/"
# To use google apps make sure your email account is transitioned - check with our Google Email Administrator
set smtp_url = "smtp://zubair.ahmed@domainName.com@smtp.gmail.com:587/"
set smtp_pass = "yourDomainPassword"

Filed under  //  HOWTOs  
Jul 11 / 12:51pm

cut/copy/delete/paste lines in vim

Posted by email 

If you ever need to cut/copy/delete/paste lines without knowing the actual number of lines, here is what you should do.

  1. go to the beginning of the section that you want to yank.
  2. Enter Visual mode - (enter 'v' in normal mode (without single quote [']) )
  3. Type 'mz' marking area as 'z'(without single quote ['])
  4. Go to the end of the section you want to yank.
  5. Type: y'z (<y-yank>, <single quote-go to mark>, z) To yank from the mark to the current location.
  6. You can paste those lines wherever you want with p

Similarly, d'z will cut/delete the lines from the current location to the mark.

Filed under  //  HOWTOs  
Jun 21 / 4:01pm

Fixing “Couldn’t Install On USB Storage Or SD Card” - Android 2.2

This usually occurs when you are updating some application or game.

After googling around a bit I found that problem is caused by a temporary file called smdl2tmp1.asec
Mount SD card to you computer and Got to File .android_secure directory  and remove file smdl2tmp1.asec

Enjoy.
Filed under  //  HOWTOs  
Jun 17 / 12:08pm

Vaio Repair Manual

Click here to download:
VAIO Manual.7z (19.3 MB)

Found great source with service manuals for Sony Vaio VGN series laptops and notebooks.

Hope this helps someone.
Filed under  //  HOWTOs