Categories
Tech Encounters

Linux and Open Source Applications Support Vendors in Singapore

Many companies try very hard to avoid using open source solutions in Singapore because the general impression is that support is poor.

A quick googling suggests that these vendors do provide professional support in Singapore:

Do you know of other vendors in this business? Let me know so that I can grow this list. When it’s substantial, maybe more Singapore companies will be willing to try open source solutions. 🙂

Categories
Tech Tips

crontab -e not saving changes

‘crontab -e’ kept telling me ‘crontab: no changes made to crontab’ even though I’ve made changes. When I run ‘crontab -l’ to check, my changes were not saved.

Turned out it’s due to my environment variable:

export EDITOR=/usr/bin/gvim

Changing it to vim solves the problem:

export EDITOR=/usr/bin/vim

Categories
Tech Tips

How to create MBR for booting into Windows

I had a dual-booting laptop with Linux Mint and Windows XP on it. After deleting the Linux Mint partitions, it failed to boot into XP because grub can no longer find the MBR. This was the error message:

error: no such partition
grub rescue>

Solution:

Boot into SystemRescueCD and run this command to create a new MBR:

lilo -M /dev/sda mbr

Note: My XP resides in /dev/sda.

Categories
Tech Tips

How to determine which repo a RHEL/CentOS package belongs to

I thought this command should show me which repo the package ‘htop’ belongs to, but I was wrong:

[root@server ~]# yum info htop
Loaded plugins: rhnplugin, security
Installed Packages
Name : htop
Arch : x86_64
Version : 0.8.3
Release : 1.el5
Size : 136 k
Repo : installed 
Summary : Interactive process viewer
URL : http://htop.sourceforge.net/
License : GPL+
Description: htop is an interactive text-mode process viewer for...

Notice that it merely indicates ‘installed’ for the ‘Repo’ field? Not very helpful here. I wonder why yum works this way.

To find out which repo ‘htop’ comes from, use this command instead:

[root@server ~]# yum provides `which htop`
Loaded plugins: rhnplugin, security
htop-0.8.3-1.el5.x86_64 : Interactive process viewer
Repo : epel
Matched from:
Filename : /usr/bin/htop

htop-0.8.3-1.el5.x86_64 : Interactive process viewer
Repo : installed
Matched from:
Other : Provides-match: /usr/bin/htop

See ‘epel’ there? Bingo!

Categories
Tech Tips

How to make bash step through matches from possible TAB completions

By default, TAB runs the ‘complete’ function whereas ‘\C-n’ runs ‘menu-complete’ and ‘\C-p’ runs ‘menu-complete-backward’.

So, let’s say you have .bash_history, .bash_logout and .bashrc in your current directory. When you type “ls .bash<TAB>“, this will be shown:

$ ls .bash<TAB>
.bash_history .bash_logout .bashrc

When you hit CTRL+N (next) now, the auto completion will replace ‘.bash’ with the first match from the list of possible completions, i.e. ‘.bash_history’. Repeated CTRL+N steps through the list of possible completions, inserting each match in turn.

CTRL+P (previous) moves backward through the list and matches in reverse sequence.

Categories
Tech Tips

How to move VirtualBox VM from 1 machine to another

Environment: VirtualBox v4.1.8

  1. Backup everything that you’ll be touching in case anything goes wrong and you need to revert back.
  2. Move the <vm>.vdi hard disk file from the old machine’s "$HOME/.VirtualBox/VDI" to the new machine.
  3. Move the <vm> directory from the old machine’s "$HOME/VirtualBox VMs" to the new machine.
  4. Edit the "$HOME/VirtualBox VMs/<vm>/<vm>.vbox" file to change the old <HardDisk> location to that of the new machine.
  5. Double-click on this vbox file to load it into VirtualBox.
  6. Start the VM. It should load without any error.
Categories
Tech Tips

How to combine 2 single-page PDFs into 1 page

(1) Join the 2 separate PDFs into 1 file (e.g. joined.pdf) using tools such as pdfunite, pdfsam or pdfshuffler.

(2) Install pdfjam.
(Note: If you’re using Arch Linux, pdfjam is included in the texlive-bin package)

(3) Use the pdfnup tool from the pdfjam package to merge page 1 and page 2 of joined.pdf into a new pdf file consisting of only a single page, with page 1 stacked on top of page 2:

$ pdfnup joined.pdf --nup 1x2

Categories
Tech Tips

How to check if promiscuous mode is enabled on network interface in Linux

$ netstat -i

Look under the last column “Flg” for value “P”. If it’s there, it means promiscuous mode is enabled for that network interface. Is the flag really P and not M? Here’s a quick test. Check existing active flags:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1366      0      0      0 BMRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

Turn multicast off on eth0:

[root@localhost ~]# ip link set eth0 multicast off

Notice that the ‘M’ flag is gone? So, M is for multicast:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1369      0      0      0 BRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

Turn promiscuous mode on:

[root@localhost ~]# ip link set eth0 promisc on

Notice that the ‘P’ flag is now shown:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1370      0      0      0 BPRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

UPDATE 20130531: This post wrongly indicated that the “M” flag indicates promiscuous mode. Sorry for the confusion. I got that from other incorrect sources as well. It seems quite many online sources got that wrong. Thanks to the helpful commenters for correcting this mistake.

Categories
Tech Tips

GVim problems after upgrading to Ubuntu 11.10 Oneiric Ocelot

After upgrading Ubuntu 11.04 (Natty Narwhal) to 11.10 (Oneiric Ocelot), GVim starts to behave weirdly.

6 May 2012 UPDATE: Issue persists even after upgrading to 12.04 (Precise Pangolin)! 🙁

Symptoms:

  1. It sometimes freezes during startup, rendering the window greyish. If you wait, it may or may not regain control.
  2. When it doesn’t freeze during startup, typing response becomes very slow. For example, when you hit ‘j’ to move the cursor down 1 line, it takes ~7s before the action takes place. Key response then returns to normal if GVim is editing an empty file.
  3. When GVim loads a large file, typing response becomes very slow all the time.
  4. Sometimes you may see this error in the Terminal window you used to run gvim:
    ** (gvim:5933): IBUS-WARNING **: Create input context failed: Timeout was reached.
  5. Other times you may see this instead:
    ** (gvim:5760): WARNING **: Unable to register window with path '/com/canonical/menu/5C00024': Timeout was reached

Workaround:

Run gvim -f instead of just gvim.

Put this in your .bashrc if you don’t want to add -f all the time, or if you already have other aliases using gvim and you don’t want to change all of them:

gvim(){ setsid /usr/bin/gvim -f "$@"; }

Categories
Tech Tips

How to identify package of particular file and verify its integrity

Let’s say we need to:

  1. Find out which package contains the file /bin/su in Linux
  2. Verify if the file is untainted (from package) or changed in some manner

For RPM (Fedora, Red Hat, CentOS):

$ rpm -q -f /bin/su
coreutils-5.97-34.el5
$ rpm -V coreutils-5.97-34.el5

For DEB (Debian, Ubuntu):

$ dpkg -S /bin/su
login: /bin/su
$ debsums -s -a login