Linux Fundae

This blog contains some important fundae for linux users, which may look very trivial, but are very useful.

vncserver on display/desktop 0

Edit /etc/X11/xorg.conf (for Xorg server) or /etc/X11/XF86Config for the old XFree server.

1) Search for Section "Screen"
  • Add the following three lines in this section
  • Option "SecurityTypes" "VncAuth"
    Option "UserPasswdVerifier" "VncAuth"
    Option "PasswordFile" "/home/yourusername/.vnc/passwd"
  • Change yourusername to your user name
2) Search for Section "Module"
  • Add following line to this section
  • Load "vnc"
3) Goto your home directory (cd /home/yourusername)
  • run vncpasswd command (vncpasswd)
4) Restart X (press ctrl-alt-backspace)

vi replace by newline

:s/:/: \\^M/

You get the ^M by depressing and holding the ctrl-V and then the 'm'

Fix Backspace In VIM

The function of the backspace key is to delete the character just before the cursor position. If it is not working properly put the following line in ~/.vimrc

set backspace=2

Konsole Title

To change the konsole title to current working directory ($PWD), put the following line in .bashrc

PS1=$PS1"\[\e]30;\w\a\]"

tar: append files to an archive

To demonstrate using `--append' to add a file to an archive, create a file called `rock' in the `practice' directory. Make sure you are in the `practice' directory. Then, run the following tar command to add `rock' to `collection.tar':

$ tar --append --file=collection.tar rock 

If you now use the --list (-t) operation, you will see that `rock' has been added to the archive:

$ tar --list --file=collection.tar
-rw-rw-rw- me user 28 1996-10-18 16:31 jazz
-rw-rw-rw- me user 21 1996-09-23 16:44 blues
-rw-rw-rw- me user 20 1996-09-23 16:44 folk
-rw-rw-rw- me user 20 1996-09-23 16:44 rock

FAM (File Alteration Monitor)

The File Alteration Monitor (FAM) monitors changes to files and directories in the filesystem and notifies interested applications of these changes. Your application can use FAM to get an up-to-date view of the filesystem rather than having to poll the filesystem. This chapter describes the required libraries and provides a basic list of steps for using FAM.
Reference: sgi techpub library

gam_server , gadmin

gam_server or gadmin is file and directory change monitoring daemon. Programmer may need to monitor the file system, without this, he may need to poll every file/directory. It provides API for this puspose. It is a subset of FAM, which is another monitoring system.

Installing Java Plugin on Mozilla/Firefox for Linux

To install the Java plugin, download the JRE for Linux from http://java.sun.com/j2se/1.4.2/download.html.

That page also has installation instructions.

After you have installed Java, then you must install the plugin by creating a symbolic link from the java plugin library to the mozilla plugins directory:

  cd where-ever-you-installed-mozilla
cd plugins

# If your system has GCC 3.2 (RedHat 8 or 9) do:
ln -s path-to-java/plugin/i386/ns610-gcc32/libjavaplugin_oji.so .

# Otherwise:
ln -s path-to-java/plugin/i386/ns610/libjavaplugin_oji.so .

Recover lost root password

  • Try to boot linux in single user mode
    • For LiLo type "linux 1" or "linux single" at your LilLo boot prompt. If it asks for root password then this step will not work try next step.
    • For GRUB, at the boot screen press e, this will allow you to edit boot line. Append "single" to the boot line. Press enter then press b to boot with this modified boot line.
    • If you do not get the command prompt, follow the next step, otherwise you have the root file system mounted read only to you, you need to change this to rw. You can do this with mount -o remount,rw
    • Now you can change the root password by passwd command, or edit the /etc/shadow file, and remove encrypted password (by removing everything between first : and second : in the entry for root)
  • If the first method does not work. Do the following
    • For LiLo type "linux init=/bin/bash" at LiLo boot prompt
    • For GRUB press e. Append "init=/bin/bash" to the boot line. Press enter and then press b.
    • Now you have the root file system mounted read only to you, you need to change this to rw. You can do this with mount -o remount,rw
    • Now you can change the root password by passwd command, or edit the /etc/shadow file, and remove encrypted password (by removing everything between first : and second : in the entry for root)

Linux Keywords

ASCII - American Standard Code for Information Interchange
cupsd - common unix printing system daemon
FAM - File Alteration Monitor
Gamin - File and Directory Monitoring Daemon
GNU - GNU's Not Unix
GRUB - Grand Unified Boot loader
LiLo - Linux Loader
MBR - Master Boot Record
USB - Universal Serial Bus

SCP and SSH without password

To ssh from machine source to destination without system asking you for password follow these instuctions. On source run the command
ssh-keygen -t rsa

You will be asked "Enter passphrase (empty for no passphrase):" . Press Enter.
This command will generate a private key in $HOME/.ssh/id_rsa and a public key in $HOME/.ssh/id_rsa.pub

Transfer the file id_rsa.pub to destination machine (you can use scp/ftp)
At destination append the id_rsa.pub to $HOME/.ssh/authorized_keys using
cat id_rsa.pub >> $HOME/.ssh/authorized_keys
Next time when you ssh from source to destination, you will not be asked for any passwords.

Saving Password in Pine

Create a file ".pine.passwd" in your home directory. You can use the following command for this
touch ~/.pine.passwd
Start pine. Enter login and password. Now, It will ask you "Preserve password on DISK for next login?".
Press y
From next time onwards when you start pine, it will not ask for login and password

Exporting Sound in Linux

Run the following command at the local machine
artsd -n -u -p 5001
This will start arts server. Now on remote machine run
export ARTS_SERVER=ip-of-local-machine:5001
now you can start xmms, mplayer on the remote machine and listen the audio at the local machine.