Friday, September 9, 2011

Mounting remote file system using sshfs

sshfs is a tool which mounts remote file system on local machine. It internally uses SSH file transfer protocol. The current implementation of sshfs has dependcny on fuse.

following packages are required to be installed:
sshfs
fuse (fuse-utils on some Linux distros)

On my open suse, fuse package was pre-installed and I needed to install sshfs.

the fuse kernel module has to be loaded before using sshfs. Here is the command to do that
modprobe fuse

I did not require anything to do anything for this on my open suse box because the fuse module was already loaded. This can be easily checked whether a particular module is already loaded or not using lsmod command.

Command to mount remote file system:
sshfs remote-user@remote-server:/remote/directory local-mount-directory


Tuesday, July 19, 2011

/etc/alternatives/

Linux allows different implementation of a single command/utility co-exist. For example you can install both open JDK and sun JDK at a time on Linux and can also make one of them as default. The default selection is made using links in the file system. This works as:-

$which java
/usr/bin/java

$ls -l /usr/bin/java
/usr/bin/java -> /etc/alternatives/java

$ls -l /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-sun/bin/java

If we type command java on command prompt then /usr/bin/java is invoked. The /usr/java/bin points to /etc/alternatives/java and /etc/alternatives/java points to /usr/lib/jvm/jre-1.6.0-sun/bin/java. So the target of the command java becomes /usr/lib/jvm/jre-1.6.0-sun/bin/java


On Ubuntu, there is a graphical utility which lets you to change/configure the alternatives. But this is missing from the default install of openSUSE. But on the openSUSE this can be easily achieved by command line as -

update-alternatives --config java
 
This command will list all available options and will ask you to enter to select one of them.

Saturday, July 16, 2011

Mounting NTFS drive on openSUSE in read-write mode

Recently, I installed openSUSE 11.4 on my laptop. The laptop is dual boot with windows7. There was a minor issue. The NTFS drive was mounted read only by default. Editing /etc/fstab fixed the issue. Here was the original entry in the fstab:-

/dev/disk/by-id/ata-FUJITSU_MHV2080BH_PL_NW9ZT682CFW0-part2 /windows/D           ntfs-3g    users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0

I changed this to as below, to make it working
 
/dev/disk/by-id/ata-FUJITSU_MHV2080BH_PL_NW9ZT682CFW0-part2 /windows/D           ntfs-3g    defaults 0 0

Merging PDF files on Linux

There are many tools out there. gs is one of such command line tools to achieve this. Suppose there are two pdf files as file1.pdf and file2.pdf and we want to merge them into final.pdf, then the command will be -
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=final.pdf file1.pdf file2.pdf

More than two pdf can also be merged by providing their names in the command line argument.

Sunday, May 22, 2011

Connecting to internet on Linux with Airtel GPRS and Nokia mobile phone

The Nokia phone comes with a software called Nokia PC Suite which provides many utilities including Internet connection on PC via phone. Unfortunately this software is not available for Linux operating system. But, as usual, a little bit of hack can enable Internet connection on Linux using Nokia phone.
Here is what I have tried and it worked for me with Nokia N79 and Airtel (in India) as service provider.
- Install wvdial. It was installed by default on my box (open suse).
- edit /etc/wvdial.conf as
[Dialer Defaults]
Init1 = AT+CGDCONT=1,"IP","airtelgprs.com"
Modem Type = USB Modem
Phone = *99***1#
Password =" "
Username = " "
Modem = /dev/ttyACM1
Baud = 460800
auto DNS = 1
- Now from command prompt, run the command wvdial
- The wvdial will block the command prompt. If want to disconnect, then type Ctrl+C on the command prompt.


Misc:
- I faced an issue. It was not automatically obtaining the DNS address. So Manually edited the /etc/resolve.conf as
nameserver 8.8.8.8
nameserver 8.8.4.4
These two nameservers are public nameserver by google.

- The user name and password here is blank string. There is no user name and password for Airtel. This should be changed accordingly if there is different service provider.

- While connecting the phone to PC, select PC Suite when asked in the phone as "Select USB Mode"

- /dev/ttyACM1 can be different on different machines. run the command dmesg as root just after connecting the phone to PC (by USB) and look for a line similar to

cdc_acm 1-1:1.1: ttyACM1: USB ACM device

Change the device name in the /etc/wvdial.conf to what it appears here




Monday, March 28, 2011

Facebook canvas application and cookie issue with Internet Explorer

The Internet Explorer does not allow cross domain cookies for iframe. This causes the Facebook iframe application to not be able to write Facebook authentication cookie on the client side and it tries to authenticate each time you try to access any page of the Facebook app. This problem does not exist for Firefox.
This can be easily solved using P3P header. Here is how this can be done in PHP
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
use this code wherever you write some cookie. This is harmless for Firefox.

Zypper/Yast: Download all RPM packages first and then install

Yast is the package management tool in open SuSE and its back-end is zypper. One of frequent issue that I have faced with zypper is that it installs a RPM package as soon as it downloads. It does not download the dependent RPMs before installing a RPM package. Sometime this leads to broken installs if there is some network problem while downloading the dependent RPMs. The problem becomes even worse if there is some network problem while the system update is going on. Once I had a broken update for KDE and I was not able to log into the GUI.
The behavior of zypper can be changed by config file. But I do not understand why the Open SuSE comes with behavior by default. The other popular Linux destro Ubuntu does not have this problem.
Anyway, I here is the solution to the probelm:-
Search for the line
commit.downloadMode
in 
/etc/zypp/zypp.conf
By default this line is commented. Uncomment this line and change it to  
commit.downloadMode = DownloadInAdvance