Saturday, September 30, 2006

Verify your download using md5sum

The situation: Often I found the md5sum term everytime I want to download softwares. At first I didn't even care what md5sum is. Ok, forget about it for a while...and talking of download, which there is one thing that annoys me regarding download and corrupted download file =.=

The Problem: How ? Eg I want to download ISO image for Knoppix Linux. After I download it, then (of course) without any question i will burn it. But it is only after burning and verifying the download, I realized it is a corrupted ISO file. There goes $1.00 of my CD-R.

The Solution: Up until now, I appreciate the md5sum, or MD5 checksum or MD hash . It is a command that can be used in terminal to verify download either it is the exact same copy (not corrupted) as in the mirror server... or it is already somehow corrupted during download process.

Open the terminal and navigate to the directory where the downloaded file is located. Type in the following command:

me@localhost:~#: md5um downloadedfile.tar.gz


...where downloadedfile.tar.gz is the file you've downloaded. Later the terminal will display the md5 hash number. verify whether it is the same as the one provided in download page. Good luck. =)

Friday, September 29, 2006

Display and force quit/terminate a program/services running on background
Where windows Alt + Ctrl + Del doesn't applied in Linux

The situation: While working on some application, you might stumble into a situation where you need to force terminate a running application or services. It is easy to do it in Windows, simply by pressing Alt + Ctrl + Del combination.

The Problem: How do I terminate a running program (including a background program and services) in Linux?

The Solution: The process is simple. Everything can be done in terminal. (Image example coming soon)

First, open the terminal, and to see currently running processes and application running, use the top command :

me@localhost:~#: top


You will be displayed the currently running processes in real-time. Just like Alt + Ctrl + Del combination in Windows.

Second, please take note of the processes you wish to terminate (or kill in Linux), and identify the process number (in the respective column), For example superkaramba application is running with process number 3349.

Press the "Q" button on your keyboard to quit top. Finally, type in the command #kill followed by the process number

me@localhost:~#: kill [process number]


For our example, it will be:

me@localhost:~#: kill 3349


NOTE: Sometime you just can't simply terminate a running application/processes. You can accomplish this by force kill. Here how you do it


me@localhost:~#: kill - 9 [process number]


Yeah, simple add -9 attributes (right after the kill command). In our example


me@localhost:~#: kill -9 3349

Thursday, September 28, 2006

How do I install and update softwares? - Using apt-get command in linux distributions based on debian

The situation: Ok, I was too excited browsing on the internet looking for free softwares to be installed in my linux box. Unlike in Windows, I stumbled up with so many methods of downloading and installing the software - I can see Gunzip (tar.gz), binary (.bin) JAR, .rpm, .deb..... you name it. And it really annoying because each softwares have their own dependencies. Not to mention about questions of which version suits my linux box.

The problem: Is there any way to quickly install software (just like in Windows) with having to worries about dependencies, extra libraries or whatsoever obstacles that may delay our time?

The Solutions: If you are using any debian based linux distribution (you may click here too) then life is much easier with apt-get command. But first let me explain how do you get to search the respective softwares.

First, you may go to debian package search page (http://packages.debian.org). Scroll down a a little until you reach about in the middle where you can see the searchbox, enter your search, and wait for the result. For example I was looking for installing gaim Instant Messenger, type in gaim and you can see few result. Your knowledge should be good enough to differentiate between each of the resulting package ( Use common sense, gaim is supposedly the package we are looking for, while gaim-extendedprefs and gaim-guinotifications are the add-ons). NOTE: People would recommend to use the stable, but as for me, I always preferred the latest one, regardless of their stability, so whatever you choose is up to you.

Click on the package, you may want to read the grimy details, or perhaps you just proceed with the apt-get. Get the keyword from the bolded title ( in this case it is gaim) Open the terminal, and type in the following command:

me@localhost:~# apt-get install gaim


or

me@localhost:~# apt-get update ; apt-get install gaim


Wait for the apt-get program to download informations from mirrors. Later as you may see, the terminal will displays all the dependencies needed (if any), how many packages to be downloaded etc - EVERYTHING IS BEING SETUP FOR YOU. All you have to do is to key in the answe , either (Y) es or (N)o. And leave the rest for the apt-get to install it.

And as you may guess, you might want to touch-up your gaim with following command (of course right after gaim completely installed. Note that you cannot run apt-get simultaneously)

apt-get update ; apt-get install gaim-guinotifications

I messed up with /etc/profile: How do I edit it?

The situation: I thought that running a daemon during startup is just as same as setting up the classpath for JDK. Well, I was wrong!!! I am so stupid tu add the mysqld (command to start mysql daemon) in a line of /etc/profile. The results? I can log in to my account (Worse, it is the root account), thus it stucks during loading and I cannot do anything. I need to get the /etc/profile edited.

The Problem: How do I edit /etc/profile, since I do not have the right permission to edit it under normal user account?

The Solution: I booted into Kanotix Live CD, and mount the linux partition containing "corrupted" /etc/profile. And it is editable from there. Thank you Kanotix Live CD, you save my day. =)

Set CLASSPATH for Java Development Kit (JDK) in Linux

The situation: Installing JDK in linux is not as easy as in Windows. After installing the downloaded binary (.BIN) JDK installer, I was thinking of this - if it is even in Windows XP that I have to configure the classpath manually (which is tad easy)...the how am I gonna do it in linux? So that I can use the terminal to type in java command (javac, jar etc) to perform operations on java virtual machine.

The Problem: How do I setup the CLASSPATH for JDK in Linux, so that I can use it on terminal every time I boot my Linux?

The Solution: In order to accomplish this, simple edit the file /etc/profile, and add the following to any of empty lines in the file:

PATH="$PATH:/opt/jdk1.5.0_07/bin:."
export PATH

...where the /opt/jdk1.5.0_07/bin is substituted with the actual directory of where the JDK is installed in your box. Save the file, and restart your machine.

Dual boot Linux/Windows using NTLDR with linux on the other hard disk drive

The situation: I want to take safety precautions by avoiding the possibilities of messing up with my Windows Partition (and yet still wants to play around with any linux box) by installing the linux on a new empty hard disk drive. As easy as it sound... but I want to use NTLDR bootloader Windows (the classy black and white MS-DOS style) instead of colorful GRUB loader (or maybe you just want to use NTLDR boot loader and still refused to use LILO bootloader).

The Problem: How do I do it, since the Windows on the primary hard disk drive, and the Linux is on the 2nd disk?

The Solution: During installation of the new linux, we must install LILO/Grub on the first partition, not on the MBR. Next, simply boot into your linux box and launch the terminal. On debian based box (knoppix, kanotix, ubuntu etc) maybe you want to view the list of hard disk drives attached to the computer, use this command:

root@localhost:~# fdisk -l


And the terminal will list down every single hard disk drives available. (Note: you must be in root permission in order to do this) Determine the hard disk for linux and respective partition. As for my case it is /dev/hdb1.

In the terminal, type in the following command:

dd if=/dev/hdb1 of=bootsector.lnx size=512 count=1

(Note: If above command doesn't work, you might want to omit the size=512 in the command)
Where:
/dev/hdb1 is my linux partition.

This will create a file bootsector.lnx in the current present working directory (type #pwd in the terminal to determine the current directory). Now, we need to transfer the file into a diskette or FAT32 partition, since we are going to transfer this bootsector.lnx file to the Windows Partition (usually formatted with NTFS filesystem).

Next, login into your Windows XP. Open c:\boot.ini files. Or you may choose the long way - On the My Computer icon, choose properties (Or Control Panel > System). On the Advanced tab, click settings button under "Startup and Recovery". Next, click on the Edit button.

Edit the boot.ini file by adding this lines on the very bottom of the page.

c:\bootsect.lnx="Boot to my linux box"


...and as you may guess., copy the generated bootsector.lnx to the root of c (c:\).

Reboot your computer. Supposedly you will have the NTLDR bootloader showing options to boot to your linux box apart from Windows XP.

Resizing linux root partition - Norton Ghost or Acronis Disk Director?

The situation: Today I want to increase the size of the main partition, or root partition ( or precisely the "/" partition, not the "/home" partition). And I tried to use norton ghost (since I am very familiar working on this software under Microsoft Windows). The original size is 7.8GB, and I wish to resize the to 30GB (by resizing current NTFS partition)

So I ghost the original partition (the 7.8GB partition) into a .GHO image and place it on a fat32 partition. And then I resize the 7.8GB partition to 30GB, and then I ghost back the image to the brand old new 30GB partition.

The Problem: No problems with "Ghosting", my kanotix box boot and loads perfectly into the KDE desktop....except for my box still recognize the brand new partition is 7.8GB in capacity - although the /proc/partitions is showing the current volume size...but the box just fails to detect the new configuration. eg On the properties menu, it shows Free disk space : 1.2 GB out of 7.8GB is used (85% used).

The Solution: Forget about the Norton Ghost, simply resize using Acronis Partition Expert (no need to install, just run it on live cd) or Acronis Disk Director (works in my Windows XP). My boyish knowledge of playing around with "GUI based boxes of partition" allows me to simply resize the partition. And my kanotix box detects the changes without any problem.

apt-get error fixed

The situation: I was searching for a new lite version of java IDE to works with my kanotix box on the internet when suddenly i stumbled up with jEdit. So i decided to try the software . After browsing the packages.debian.org, i perform the apt-get operation to download and install jEdit. Unfortunately it is somehow corrupted, and it affect my apt-get command too!

The Problem: Everytime I tried to perform upgrade/installation/whatsover using apt-get, it really pissed me off with this message:

Reading package lists... Done
Building dependency tree... Done
E: The package jedit needs to be reinstalled, but I can't find an archive for it


The Solution: Force uninstall it using this command in terminal:

root@localhost:~# dpkg --force-all -r jedit


And here's the output:
root@localhost:~# dpkg --force-all -r jedit
dpkg - warning, overriding problem because --force enabled:
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
(Reading database ...
dpkg: serious warning: files list file for package `jedit' missing, assuming package has no files currently installed.
160172 files and directories currently installed.)
Removing jedit ...


Viola! My apt-get works!!
Supposedly this will work on any other packages too =)