Monday, February 28, 2011

Problem with sound recording in Ubuntu 9.04

Configuration:
Ubuntu 9.04, HDA Intel (Alsa Mixer)

Problem:
I am using a headphone with mic. I have plugged in the mic, in the right socket. It seems that I have configured everything in Alsa Mixer right. But still sound recording does not work.

Solution:
Go to Volume Control -> HDA Intel (Alsa Mixer) -> Options -> Input Source (the first one). If it is 'Mic', change to 'Front Mic'. Try recording; it will fail. Now change it back to 'Mic'. Try recording again; it should work now.

[microphone, audio, voice]

Installing Logitech WebCam C210 on Ubuntu 9.04

The title is deceptive, implying one has to do something. Actually, it works right out of the box!

1. The Logitech Webcam C210 comes with a USB connector. Plug it in.
2. Install Cheese - sudo apt-get install cheese
3. Run cheese. You can now start recording video and taking pictures!

See https://help.ubuntu.com/community/Webcam.

Wednesday, February 23, 2011

Linux commands for gzip and bzip2


These examples are for compressing/decompressing, and preserving the original file.

Gzip-ing and gunzip-ing -
cat abc.txt | gzip > abc.gz
gzip -cd zbc.gz > abc.txt (-d decompress, -c send to console)

and similarly for bzip2 and bunzip2 -

cat abc.txt | bzip2 > abc.txt.bz2
gzip -cd abc.txt.bz2 > abc.txt

Some commands that operate directly on gzip-ped files -
zcat abc | less (abc can be a text file or a gzip-ped file)
zless def (the file need not have extension .gz)
zdiff abc.gz def
zgrep "pattern" abc.gz

and similarly for bzip2, we have bzcat, bzless, bzdiff and bzgrep.

Sunday, February 20, 2011

Opening/Creating .zip files in linux

Opening
To extract contents of abc.zip (keeping original zip file) --- unzip abc
To just list the contents --- unzip -l abc
To extract a specific file def.txt --- unzip -p abc def.txt > mydef.txt (where def.txt was listed in previous step)

Creating
To create abc.zip (keeping original files) --- zip abc def.txt xyz.txt ...
To zip a directory /path/to/dir1 --- cd /path/to; zip -r abc dir1
To add a file to existing zip file abc.zip --- zip /path/to/abc.zip lmn.txt (Do not give /path/to/lmn.txt)

Wednesday, February 9, 2011

Mounting drives using HAL in Ubuntu

Some drives in Ubuntu are mounted using HAL. To change the mount options for these drives, do the following -
  • Run gnome-mount -u -d /dev/sdb1.
  • Run gnome-mount -d /dev/sdb1 --display-settings to view current settings.
  • Run gnome-mount -d /dev/sdb1 --write-settings --mount-options umask=000,opt2,opt3=foo to set the mount options. 
  • If you want to keep the existing options and change/add only a few, then use gnome-mount -d /dev/sdb1 --write-settings --extra-mount-options opt4,opt5=foo.
  • Now mount the drive in the usual way (from Nautilus).
To see complete details about the drives mounted by HAL, run lshal.

(In the /dev/sdb2 example above, remember that umask=000 gives everyone all permissions; so it is the inverse of what you would give for chmod.)

Monday, February 7, 2011

Typing in Indic languages in Ubuntu using ITRANS

(For Ubuntu 10.04, see further below.)

Ubuntu 12.04

I found this tip that made things really easy. To summarize:
  • Install ibus-m17n.
  • Go to System Settings -> Language Support -> Keyboard input method system. Choose `ibus'. Close the dialog.
  • Click on Dash Home. Type ``ibus'' and click on the ``IBus'' icon that appears. A keyboard icon appears in the system tray (top right of screen).
  • Click on the keyboard icon -> Preferences -> Input Method -> Customize active input methods -> Select an input method -> (Now choose your language and input method). Click on Add. (Add as many as you want.) Close the Preferences dialog.
  • Open a new document in gedit. Click on the keyboard icon and select the input method (the default setting will be ``Input method Off'').
  • Start typing in your preferred language.

Ubuntu 10.04

To type in Indic languages in Ubuntu using ITRANS scheme, do the following
  • Go to synaptic; install
    • TrueType fonts for required language (search for language name, e.g. 'kannada')
    • SCIM
    • m17n
    • itrans
  • Run gedit
  • Right-click on editor. Select 'Input Methods' -> 'SCIM Input Method'. The SCIM icon (a keyboard) will appear in system tray (where date etc. are there).
  • Go to 'Kannada'-> 'kn-trans'. (Or to any other language)
  • Go back to editor and start typing in Indic using the ITRANS scheme (see below).

ITRANS Scheme (copied from here)

Vowels (dependent and independent):
-------
a     aa / A       i      ii / I       u     uu / U 
RRi / R^i    RRI / R^I    LLi / L^i    LLI / L^I
e     ai     o     au     aM    aH

Consonants:
----------- 
k     kh     g     gh     ~N
ch    Ch     j     jh     ~n
T     Th     D     Dh     N
t     th     d     dh     n
p     ph     b     bh     m
y     r      l     v / w
sh    Sh     s     h      L
x / kSh     GY / j~n / dny     shr
R (for marathi half-RA)
L / ld (marathi LLA)
Y (bengali)

Consonants with a nukta (dot) under them (mainly for Urdu devanagari):
-----------------------------------------
k  with a dot:      q
kh with a dot:      K
g  with a dot:      G
j  with a dot:      z / J
p  with a dot:      f
D  with a dot:      .D
Dh with a dot:      .Dh

Specials/Accents:
-----------------
Anusvara:       .n / M / .m  (dot on top of previous consonant/vowel)
Avagraha:       .a    (`S' like symbol basically to replace a after o)
Ardhachandra:   .c    (for vowel sound as in english words `cat' or `talk')
Chandra-Bindu:  .N    (chandra-bindu on top of previous letter)
Halant:  .h    (to get half-form of the consonant - no vowel - virama)
Visarga:        H     (visarga - looks like a colon character)
Om:  OM, AUM (Om symbol)


[As shown, many codes have multiple choices, example "RRi / R^i" implies you
 can use either "RRi" or "R^i"]

Friday, February 4, 2011

Setting classpath when compiling/running Java

Set the CLASSPATH environment variable to
- the directories having .class files
- the .jar files which contain relevant .class files

Then run javac and java; it will pick required the .class files from its location.

If you say
export CLASSPATH=dir1
and the .class file is dir1/dir11/abc.class, then you must say
java dir11.abc
to enable java to find abc.class.

Thursday, February 3, 2011

Verifying checksums in linux

Kinds of checksum algorithms - md5, sha1, sha224, sha256 etc.

Given a file abc and a checksum a1b23c using the md5 algorithm, run
md5sum abc | grep "a1b23c"
If the output is "a1b2c3      abc", the check succeeded.
If there is no output, the check failed.

md5sum calculates the checksum for the file abc using the algorithm md5 and prints to console. grep checks if that's the checksum you expected. If the check failed, grep will be silent.

Replace md5sum with sha1sum, sha224sum etc.

Each algorithm uses a certain number of bits for the calculation. The more bits the algorithm uses, the better.

md5 - 128 bits
sha1 - 160 bits
sha224 - 224 bits
sha256 - 256 bits
etc.