Tuesday, February 17, 2009

DNS lookup

To find an ip address for a domain, we need to do dns lookup. A few tools available for us to use in linux, but in this article I will give brief explanation about 3 most famous tools of dns lookup, which are host, nslookup and dig. Usually if the commands are used without the optional nameserver, then the nameserver entries in /etc/resolv.conf will be used


To find ip address of a domain using host (nameserver is optional):

$ host
example:
$ host www.google.com 208.67.222.222

To find the domain that belongs to an ip address using host (nameserver is optional):

$ host
example:
$ host 202.188.0.133 ns1.tm.net.my


To find ip address of a domain using nslookup (nameserver is optional):

$ nslookup
example:
$ nslookup www.google.com 208.67.222.222

To find the domain that belongs to an ip address using nslookup (nameserver is optional):

$ nslookup
example:
$ nslookup 202.188.0.133 208.67.222.222

nslookup also have interactive mode that you can access by simply typing
$ nslookup


To find ip address of a domain using dig (nameserver is optional):

$ dig @
example:
$ dig @ns1.tm.net.my www.google.com

Thursday, February 5, 2009

Unmounting busy device

You have an external drive attached to your linux machine. Then after finishing all your job, you try to unmount it, a message come out saying the device is busy.

# umount /media/disk
umount: /media/disk: device is busy
umount: /media/disk: device is busy

So what could possibly the cause?

1. You are inside the disk. Check your working directory using pwd

# pwd
/media/disk

2. Some files are accessing the disk. Check list of open files using lsof

# lsof | grep /media/disk

3. Some processes areaccessing the disk. Use fuser to check

# fuser -m /media/disk

What to do?

1. For case 1, just go to another directory

# cd
# umount /media/disk

2. For case 2, check the files that are accessing the disk and kill it

# lsof | grep "/media/disk"
vim 2693 pingu cwd DIR 8,4 4096 73729 /media/disk
# kill -9 2693
# umount /media/disk

3. For case 3, find the process that accessing the disk and kill it

# fuser -m /media/disk
/media/disk: 2693

# ps -e | grep 2693
2693 pts/0 00:00:00 vim
# kill -9 2693
# umount /media/disk

4. For case no 3 also, you can use fuser -k to kill the process that bugging the disk directly (Thanx to mr. linuxmalaysia for the comment)

# fuser -k /media/disk
#umount /media/disk


Hope this will be useful

Wednesday, January 14, 2009

GUI media converter

ffmpeg is a very powerful media converter but unfortunately it is text based. For people like me who use terminal as much as GUI, using ffmpeg in its original nature, which is text based is ok. You can refer to my post about converting flv to avi using ffmpeg. But for people who want to harness the power of ffmpeg yet not familiar of using terminal, mobile media cenverter from miksoft is a good option. This application is a GUI for mmpeg, so you can expect some of the goodness of ffmpeg if not all of them. You can download this application here, where it is available for windows and linux. For debian based linux user, the application is available in .deb form where you can install easily. For other linux user, a little bit of extra work has to be done to start using this application.

A few of mobile media converter features are drag n drop, using ffmpeg engine, it is free of charge, it has integrated youtube downloader and it is available for linux and windows. Supported formats are:
- Desktop Audio: mp3, wma, ogg, wav
- Mobile Audio: amr, awb
- Desktop Video: wmv, mpeg, wmv, avi, flv
- Mobile Video: 3gp, mp4

Installation instruction is available here under Help.

Below are screenshots of the application in ubuntu 8.10



and windows vista

Monday, January 5, 2009

Searching or finding files owned by user

A few days back, I have to find in my machine files that belong to a user or to a group. The general form are like below:

# find location -user username -group groupname

To find files in / directory owned by user foo:

# find / -user foo

To find files in / directory owned by user in group bar:

# find / -group bar

To find files in directory / owned by user foo and group bar:

# find / -user foo -group bar

You can also use uid or gid
To find files belong to uid 500:

# find / -uid 500

To find files that belong to gid 500

# find / -gid 500

Thursday, December 18, 2008

Knowing your hardware

In linux, there are a few ways that you can know you hardware details without opening the chassis of your machine. Below are a few ways that I know and hopefully can help linux users out there;

  1. Refer to the /proc directory. This directory contains a few files that can give you information about your hardware such as memory (meminfo), processor (cpuinfo), partitions (partition) and many more
  2. Use "lspci" command. This is a command to list all pci devices connected to your machine
  3. Use "lshw" command. This command will list out all hardware installed on your system. Available in ubuntu
  4. Use "kudzu -p" command. This is redhat/centos hardware probing and installing tool. Use "kudzu -p" to display all the hardware connected to the system
  5. Use "dmidecode" command. This is a tool for dumping bios information into human readable form
  6. Run "lsusb" to list out all usb devices. Thanks to KwangErn Liew for the suggestion in the comment.
If anyone have any tool that I didn't list out, please feel free to drop out a comment