2010년 9월 21일 화요일

Find out which version of ubuntu is running

cat /etc/issue

or

lsb_release -a

Find out which version of ubuntu is running

cat /etc/issue

or

lsb_release -a

2010년 9월 18일 토요일

Choosing a default jdk when there are more than 2 jdks installed. (jdk5, jdk6)

If there are more than 2 jdks installed, you need to switch to specific jdk according to the situation.
This can be achieved easily with the following commands (update-java-alternatives)

1. Check the current configuration and possibilities.
# sudo update-java-alternatives -l
2. Set the specific jdk as default.
# sudo update-java-alternatives -s XXXX
3. To check the configuration,
# java -version
or
#javac -version

Source: https://help.ubuntu.com/community/Java

Installing sun-java6-jdk on ubuntu

Canonical decided to go with openjdk instead of the proprietary sun-java6.
But lots of people still demands sun-java6.
Actually the solution is in the release note of Ubuntu 10.04 (Lucid Lynx).
(Refer to the source link below)

# sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
# sudo apt-get update
# sudo apt-get install sun-java6-jdk

Source: https://wiki.ubuntu.com/LucidLynx/ReleaseNotes#Sun%20Java%20moved%20to%20the%20Partner%20repository

2010년 9월 17일 금요일

Find and replace a string

find /home/bruno/old-friends -type f -exec sed -i 's/ugly/beautiful/g' {} \;

1. Find a string (only in alphabets)

# grep -rw "search string" ./

2. Find a string

# grep -i -l "search string" * -r 2> /dev/null

2>/dev/null : direct error outputs to /dev/null

3. Find a string(all languages can be used for search string)

# find . -exec grep -l "search string" {} \; 2>/dev/null

4. Find a string(case insensitive)

# find . -exec grep -i -l "search string" {} \; 2>/dev/null

-i: case insensitive

5. Find and replace a string

# find . -exec perl -pi -e 's/search string/replace string/g' {} \; 2>/dev/null

# find . -type f -exec sed -i 's/ugly/beautiful/g' {} \;

6. Find a file

# find / -name filename -type f

7. Find a file(case insensitive)

# find / -iname filename -type f

8. Find a directory

# find / -name filename -type d

9. Find a directory(case insensitive)

# find / -iname directoryname -type d

10. Find all files that matches to the filename

find . | xargs grep 'filename'

Source:
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html
http://apms.tistory.com/tag/replace

Installing sun-java5-jdk on ubuntu

* The recent master branch releases of Android Open Source Project, you need to install java6. Google finally switched to jdk 6 from old jdk 5.

In order to build Android(open source) on Ubutu, you need to install sun-java5-jdk.
However, sun-java5-jdk is not available on the repositories of latest Ubuntu versions (9.10 or aboves) any longer.

Here is the way to install sun-java5-jdk on the latest versions of Ubuntu.

1- Open /etc/apt/sources.list with a text editor like gedit:

sudo gedit /etc/apt/sources.list

2- Add the following lines to the end of the file then save it and close:

## For sun-java5-jdk
deb http://ir.archive.ubuntu.com/ubuntu jaunty-updates main multiverse

3- Update the packages lists and install sun-java5-jdk:

sudo aptitude update
sudo aptitude install sun-java5-jdk

4- (Optional) Remove the lines added at the step 2 from the sources.list.

4-1. open an editor to modify sources.list
sudo gedit /etc/apt/sources.list
4-2. remove or comment out(like the below) the added lines
## For sun-java5-jdk
#deb http://ir.archive.ubuntu.com/ubuntu jaunty-updates main multiverse
4-3. Update the package lists
sudo aptitude update

Source: http://zebardast.ir/en/installing-sun-jdk-5-on-ubuntu-9-10-and-10-04/