Tuesday, July 29, 2008

Why Do You Use Linux?

My last post was submitted to here and received many comments. Because I didn't introduce myself clearly, some people misunderstand me. I think I am not a linux beginner and I have tried some distros such as Fedora, Debian, Gentoo for more than 3 years... I found that many people ignore an important question: why do you use it (linux)?

Don't say freedom and open source. I don't think source code is useful for normal users. Linux, of cource, is simply one kind of operation systems. I choose it only because it can work well. Why do people use computer? People need its help. Why the "Linux supporters" intend to explore Linux itself, not to how to use it to finish our work more effectively?

I've seen some people who have play with Linux for several years. But to my surprise, they don't know how to use Linux to finish their work. Linux is just an advanced toy. They often install some new distributions and compare them. They spend too much time on something unuseful, such as 3D-desktop, window animation... If you like Linux only because of these, Linux is just a toy for you.

Linux is just an OS, software. From a programmer's perspective, it's just a collection of programs, binary code ... It isn't special. But Linux has many distributions. Choosing one to start isn't an easy work. But the same thing: they are Linux! I think the most thing for a person who is working with Linux is to learn Linux/Unix commands. If he can use command line to solve most problems, many Linux distributions is "same" for him. But the goal is: finishing his work better.

If you are using Linux or plan to go to Linux world, think over this question: why do you use Linux?

Monday, July 28, 2008

Ubuntu Linux is Much Better than Windows

I have worked with Ubuntu Linux for about 2 months and find that Ubuntu is much better than Windows. My computer is Thinkpad T43 laptop. The reasons that Ubuntu is better are:

Wireless network supported. My laptop's wireless network card is Intel PRO/Wireless 2200BG. After booting from Ubuntu live CD, the wireless network is usable. Even you can install Ubuntu and surf the Internet at the same time. However, Windows XP doesn't support the wireless network adapter. So I have to download the driver from other computer and copy it to my laptop. Obviously, it is dirty work.

No need to look for software all over the world. Ubuntu, or any Debian-based Linux distribution, uses APT to manager the software packages. If you need to install some software, for example, apache2, you don't have to look for a download site but just execute "sudo apt-get install apache2". Ubuntu will download all necessary packages from its repositories. Installation and configuration are done by APT, the software package manager. If you don't know the package's name you want, you can use Synaptic Package Manager to find one. It is a GUI front-end of APT.

Perfect Chinese supported. Ubuntu 8.04 give me more beautiful Chinese fonts than 7.10. After installation, go to "System -> Administration -> Language Support" and check the Chinese option and the "Enable support to enter complex characters" option. Then you will get some Chinese fonts and input methods. It is extremely easy.

Anti-virus software is no need. When I used Windows, I have to install an anti-virus tool after installation. However, I think it isn't necessary for Linux. The viruses on Linux are much fewer than those on Windows. Since I don't install anti-virus software, my computer runs faster.

More useful softwares. After installation you can get many useful softwares. OpenOffice, GIMP, Pidgin... you can work immediately. However, on Windows, you have to install MS Office, GTalk or MSN Messenger... after Windows installation. Some people may not like so, they prefer to controlling their computer completely, so they don't like these softwares Ubuntu provides. No problem, just use "Applications -> Add/Remove..." to remove those you don't like.

Free and easy to use. Almost all the Linux distributions are free to use. Most softwares for Linux are also free. It makes people who are using Linux save lots of money. Besides, I think Ubuntu is easier to use than other Linux distributions, even Windows! No cost doesn't mean low-quality.

Sunday, July 27, 2008

Install Ubuntu 8.04 from Hard Disk

According to Ubuntu official website, installing Ubuntu 8.04 or upgrade to Ubuntu 8.04 from older version need CD. But in fact, burning a CD is not necessary. If you have installed a distribution of Linux but have no CD writer, you can also install Ubuntu 8.04 by the ISO file. I installed it from hard disk just now and now I am going to write something about how to do it.

First, make sure that you have more than one partitions (except swap partition). For example, I have two partitions /dev/sda1 (mounted as /) and /dev/sda5 (mounted as /home). Since I planned to install Ubuntu 8.04 on /dev/sda1. I downloaded the desktop iso file from here and save it in /home, the /dev/sda5 partition. So the full path of the ISO file is: /home/ubuntu-8.04.1-desktop-i386.iso.

Second, extract /casper/vmlinuz and /casper/initrd.gz from the ISO file. Since I had installed Ubuntu 7.10, I need to execute the following commands:
cd /home
sudo mount -o loop ubuntu-8.04.1-desktop-i386.iso /media/cdrom0
sudo cp /media/cdrom/casper/vmlinuz .
sudo cp /media/cdrom/casper/initrd.gz .

Now edit the grub configuration file /boot/grub/menu.lst. Add this item:
title Install Ubuntu
root (hd0,4)
kernel /vmlinuz boot=casper iso-scan/filename=/ubuntu-8.04.1-desktop-i386.iso
initrd /initrd.gz

Note: the red text (hd0,4) means the fifth partition on the first hard disk. i.e. it means /dev/sda5. The partition number of grub is from zero, not one.

Save menu.lst and reboot your computer. You can start Ubuntu 8.04 live CD from grub and install it to your hard disk as using CD. The only thing you must care about is that you mustn't format the partition which contains the ISO file. In my installation, the ISO file is at /sda5 so I can't format it. In addition, I mounted /home onto /dev/sda5.

Sunday, July 20, 2008

Enable and Disable "root" on Ubuntu Linux

On Ubuntu Linux, the "root" account is disabled by default. Normal users can use "sudo " to when he has to run a programe as root. This provides a bit more safety but sometimes typing "sudo" is dirty work. On other Linux distributions, you can use "su" to switch into root account. You can enable the function on Ubuntu.

Set the root's password:
sudo passwd root

Enter the password twice. Now you can use "su" to enter root account.

But how to disable root's account? The answer is "passwd". In your normal account, type "sudo passwd -l root". Here, the argument "-l" means "lock". It locks the root account. However, you can unlock the root account by typing "sudo passwd -u root" if you have set the root's password. Here, the "-u" means "unlock".

Friday, July 18, 2008

Windows on Linux

I have used Ubuntu Linux for about one month and I feel I like Linux better than Windows. But sometimes I need to work on Windows, for example, some online banks only support IE. So I have to use Windows. I think it is good to install Windows with virtual machine. At last I chose VirtualBox, a virtual machine software with a user friendly GUI. On Ubuntu Linux, just use "sudo apt-get install virtualbox" to install it. Next, add my user account to group "vboxusers". My computer's memory is 512MB, not too much, but Windows runs well in VirtualBox.
Screenshot-Windows XP [Running] - VirtualBox OSE-1

Creating a new virtual machine with VirtualBox wizard is very easy. VirtualBox can use the real CD drive directly, but to make installation faster, I make an ISO image file from my Windows CD. Making ISO image file is very easy with Linux. On my laptop the CDROM is /dev/scd0. What I need to go is inserting the Windows CD into the CD drive and executing "cat /dev/scd0 > windows.iso". After a while I got the ISO file -- windows.iso. Then modify the virtual machine's properties to make it use the ISO image instead of the real CD drive. Click the "Settings" button and configure "CD/DVD ROM" as below:
Screenshot-Windows XP - Settings

When the virtual Windows is running, right Ctrl+F turns on/off the full-screen mode. When working in full-screen, it is almost the same with the real Windows.

Saturday, July 12, 2008

Installing Tomcat on Ubuntu Linux

I installed Tomcat on my laptop which runs Ubuntu Linux. APT package manager makes it very easy to install many software packages.

Firstly, make sure that you have configured software sources correctly. Go to "System"--"Administration"--"Software Sources" and do it as below:
Screenshot-Software Sources
If you skip this step, apt-get may not find tomcat package.

Before installing tomcat, I have to install Java programming environment. Just use "sudo apt-get install sun-java6-jdk sun-java6-jre" to install JDK and JRE. I suggest choosing Sun JDK or JRE. If you have more than one, you'd better use "sudo update-alternatives --config java" and "sudo update-alternatives --config javac" to choose Sun Java interpretor and compiler as default.

Then you can install tomcat-5.5 with "sudo apt-get install tomcat5.5". After that, Tomcat will start. The default port is 8180. i.e. you can visit http://localhost:8180 to test your tomcat. If you see a blank page, it means tomcat works.

One of configure files is /etc/tomcat5.5/server.xml. I want to make tomcat use port 8080. Open it and find:
<Connector port="8180" maxHttpHeaderSize="8192" .... />
Change ""8180" to "8080", save it and use "sudo /etc/init.d/tomcat5.5 restart" to restart tomcat.

The last step you should specify a directory as web root directory. Go to /etc/tomcat5.5/Catalina/localhost directory, add an XML file (for example: ROOT.xml) which contains:
<Context path="/" docBase="/home/albert/Programs/JavaEE" reloadable="true" />
Put a JSP file (test.jsp) in /home/albert/Programs/JavaEE/, which contains:
<% out.println("It works"); %>
Restart tomcat and visit http://localhost:8080/test.jsp to test it.

Wednesday, July 9, 2008

A Problem of Gvim on Ubuntu Linux

My ubuntu linux is version 7.10. I installed Gvim (Vim for X Window) yesterday, but it has a serious problem: I cannot enter correct character with keyboard. For instance, I press 'g', but it shows 'h'. I've searched this problem on Google and found a very simple solution.

Just use your favourite text editor to open /etc/vim/gvimrc and find the lines:
if has('gui_gtk2')
set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1

The five lines should be commented with quotes. Just remove it. Now save it and restart Gvim. If everything is OK, it should work.