Archive for the ‘Linux’ Category

rpm vs dpkg, yum vs apt-get

Wednesday, September 3rd, 2008

If administrating different Linux distributions, sometimes it is quite confusing to remember package managers command.

This wiki page has listed up things nicely.

Very nice reference.

http://wiki.openvz.org/Package_managers

Installing Ubuntu Linux using PXE Boot (Network Booting)

Friday, February 15th, 2008

When you install Ubuntu Linux on multiple machines, it is good to use PXE Boot or similar network booting feature supported by the BIOS (Actually if the BIOS doesn’t support it, you can use GRUB, but you have to manually install GRUB on your disk first)

To summarize this process, here is the list of things you need to do.

  1. Set a server
    1. Install and configure DHCP Server
    2. Install and configure TFTP Server
    3. Prepare Ubuntu disk image
  2. Set clients (machines to install)
    1. Configure BIOS to enable network booting (or BOOTP)
    2. Put machines on same network with the server
    3. Boot and choose booting option to network booting

MECHANISM

How this work?

  1. The client broadcast the request to the ethernet, and the DHCP server will give an appropriate network information (IP address/Gateway/DNS) to the client.
  2. Now client is connected to the internet, it requests for the kernel to boot. The TFTP server will respond and send the kernel image.
  3. The client will launch the kernel image that it downloaded, and mount server’s disk image as a root file system. (You can do nfsroot, but usually it is merely a ramfs)
  4. The disk image has the installer program, so it will start the installer

It’s good that you don’t need to burn any installation CD. If you have a remote KVM-IP switch, then you can even install everything from remote site. 

DETAIL PROCEDURE

This article explains very well.
http://wiki.koeln.ccc.de/index.php/Ubuntu_PXE_Install

States that I drove through

Friday, January 18th, 2008

Total 22 States

NY, MA, NJ, PA, DE,

CT, VA, NC, SC, GA,

TN, AL, MS, AR, LA,

TX, NM, AZ, NV, CA,

MD, DC
I actually have been to AK, HI.

So I’ve been to 24 states so far.

Console Login with Upstart

Monday, November 5th, 2007

I found that recent Ubuntu releases use “upstart” instead of traditional “sysvinit”.
You can check it by

$ sudo dpkg -S /sbin/init

One bummer on upstart is that it doesn’t allow console login.
I first thought it was a security reason, but I doubt it is more a bug.
(Because there was a wrong entry in the configuration)
Instead of using /etc/inittab, upstart uses /etc/event.d/* files.
For example, /etc/event.d/tty1 is where you can launch console login prompt.
For me this file was missing, so I created /etc/event.d/tty1 as follows.

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

stop on shutdown

respawn
exec /sbin/getty 38400 tty1

After you reboot, you’ll be able to have a console login prompt.
If you want more (tty2 ~ tty6), just copy and paste above and change tty1 accordingly.

How to keep SSH connection alive

Friday, April 13th, 2007

When you work remotely using ssh, you may have experienced that ssh connection is closed while you are out for a coffee or checking email. This is annoying if you were in the middle of editing a file and didn’t save the data, or you were running an application and can’t see the result. SSH has an internal “ping” to keep the connection alive. However, it is turned off by default in most cases. Here is several ways you can turn it on.

  • Using command line option: add -o ServerAliveInterval=X
    $ ssh -o ServerAliveInterval=30 userid@server
    This will let ssh to ping every 30seconds
  • Add it to the configuration: Add a line at ~/.ssh/config as the following

    Host *
    ServerAliveInterval 30

People often confuses ServerAliveInterval option with TCPKeepAlive. TCPKeepAlive is an TCP layer option to check whether the remote server is alive or dead. This will keep your connection alive if the both the client and server has this option turned on. Setting ServerAliveInterval is a better way since you don’t need to check the server side options. For more information try man ssh_config.

Use RDTSC instruction to measure time on x86 architecture

Sunday, September 24th, 2006

In x86 architecture, RDTSC instruction reads current time stamp counter from the hardware. This is a better cost measurement for a program than using GNU time. It’s overhead is low and accuracy is high. You can simply add the following function to get the current counter.

typedef unsigned long long cycles_t;
inline cycles_t currentcycles() {
    cycles_t result;
    __asm__ __volatile__ ("rdtsc" : "=A" (result));
    return result;
}

Autoreconf: One line patch to support multiple include for aclocal

Thursday, August 31st, 2006

A perl script autoreconf is part of GNU autoconf package, which automates the tedious job calling autoconf, autoheader, aclocal, automake, libtoolize, and autopoint appropriately. However, if you have multiple directories for aclocal macros, current 2.6 version of autoreconf doesn’t have a way to do that. This may cause a problem when you build a big software like X where autoreconf is called from a build script, and you have multiple directories to include. However, since it is a mere perl script, the hack is simple. Add one line as below.

	$autoheader .= join (' --prepend-include=', '', @prepend_include);
+	$aclocal   .= ' '.$ENV{'ACLOCAL_FLAGS'};

	# --install and --symlink;
	if ($install)

Now autoreconf will attach flags to aclocal calling it. Hence, you can set ACLOCAL_FLAGS globally which will affect any aclocal call from autoreconf. For example, if you put

export ACLOCAL_FLAGS=”-I /lusr/share/aclocal -I /usr/share/aclocal”

on your ~/.bashrc, autoreconf will use above flags to call aclocal.

You can also modify aclocal since it is also a perl script. It is your choice.

Cheap trick to block nasty ads with /etc/hosts

Thursday, August 24th, 2006

This is not a perfect way, and limited to per site base, but you can block websites with almost no additional cost. And this trick applies to both Windows and Linux. For background understanding, before domain name is resolved from DNS server, Linux first check /etc/hosts. If it found a match it doesn’t query to DNS server for name resolution. Hence, if you set the ad-site’s ip address as your local address (127.0.0.1), your web-browser would try to connect to your local machine, which will fail to load ads. Here is an example.

# block nasty ads
127.0.0.1 ad.doubleclick.net
127.0.0.1 adplus.yonhapnews.co.kr
127.0.0.1 ad.ubnm.co.kr
127.0.0.1 ad.hani.co.kr

You can add those lines to the /etc/hosts (Windows: c:/windows/system32/drivers/etc/hosts).

My sources.list

Wednesday, August 23rd, 2006

If you use Ubuntu, default sources.list has only official repositories. There are some reliable third party repositories with useful packages. (But use it with your own risk. Don’t complain to me.)
There is a nice Sources.list Generator where I got below one. I like the kubuntu.org packages which has more recent version of KDE than the official ones. w32codecs, and acroread are also useful packages.
Here goes my /etc/apt/sources.list.

deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse

deb http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu dapper-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted universe multiverse

#deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse

# Seveas’ packages (packages, GPG key: 1135D466)
deb http://mirror2.ubuntulinux.nl dapper-seveas all

# Seveas’ packages (sources, GPG key: 1135D466)
deb-src http://mirror2.ubuntulinux.nl dapper-seveas all

# kubuntu.org packages for the latest KDE version (packages, GPG key: DD4D5088)
deb http://kubuntu.org/packages/kde-latest dapper main

# kubuntu.org packages for the latest KDE version (sources, GPG key: DD4D5088)
deb-src http://kubuntu.org/packages/kde-latest dapper main

# kubuntu.org packages for the latest amaroK version (packages, GPG key: DD4D5088)
deb http://kubuntu.org/packages/amarok-latest dapper main

# kubuntu.org packages for the latest amaroK version (sources, GPG key: DD4D5088)
deb-src http://kubuntu.org/packages/amarok-latest dapper main

# Bleeding edge wine packages (packages)
deb http://wine.budgetdedicated.com/apt dapper main

# Bleeding edge wine packages (sources)
deb-src http://wine.budgetdedicated.com/apt dapper main

SCIM – Korean Input Method on Ubuntu Linux (리눅스 한글 입력기 설정)

Tuesday, August 22nd, 2006

I switched to SCIM from NABI recently, because SCIM is easier to use in both KDE and GNOME. SCIM still has many crashing bugs, but it has improved recently and codes are maintained actively. I think nobody maintains NABI anymore. Below worked on Dapper-drake, but I guess it will also work for Breezy-badger.

Packages to Install

$ sudo apt-get install uim scim-gtk2-immodule scim-uim scim-hangul scim-tables-ko scim-qtimm skim im-switch

Configuration

If you installed ‘im-switch’ package above, it enables X to read ~/.xinput.d/default when launching X. This is to customize X input per user account, and make it consistent with Fedora or Redhat based Linux. Create ~/.xinput.d/default as following:

export XMODIFIERS=”@im=SCIM”
export GTK_IM_MODULE=”xim”
export XIM_PROGRAM=”scim -d”
export QT_IM_MODULE=”scim”

KDE user, create ~/.kde/Autostart/scim as:

#!/bin/sh
scim -d

and then set executable permission

$ chmod a+x ~/.kde/Autostart/scim

GNOME Users, Add below to ~/.gnome2/session-manual

[Default]
num_clients=1
0,RestartStyleHint=3
0,Priority=50
0,RestartCommand=scim -d
0,Program=scim

Now restart X and you will see SCIM on taskbar if everything went on. Right click on the icon and choose SCIM setup. On menu “IMEngine > Global Setup”, select appropriate Korean keyboard you use. I use 2bul, and I guess others don’t behave correctly.

If you have any question or suggestion, please leave a comment.