sakana

very short memo

mount windows file system remotely

Sometime you would like to mount Windows File System from ubuntu so that you are able to Windows files by making use of command line tools of linux.

You can access via CIFS and here is a quick procedure to do so.

Create share

Create File Share on on Windows side, which is the target of reference. You can check share properties by.

$ net share <shareName>

CIFS utility

Then install tools necessary for mounting with CIFS on ubuntu side.

$ sudo apt-get install cifs-utils

mount

Create mount point.

$ sudo mkdir -p /windows/server1

Prepare password file for authentication, say, named “passwd” under ~/cifs directory with content as follows:

username=<MS_UID>
password=<MS_PASSWD>

Add following line in /etc/fstab so that one can mount shared folder from ubuntu

//<MS_HOST>/<ShareName>  /windows/server1  cifs credentials=<HOME>/cifs/passwd,iocharset=utf8,sec=ntlm  0  0

Now it’s ready for mounting.

$ sudo mount -v -a

view next line of matched word

You sometimes would like to show the very next line(s), which contain specific word(s).

I have to confess that I did not know there is a useful option in grep to achieve this sake... I have been using, say, some script to extract lines, which I would like to check.

You can achieve this with -A option. For example, if you would like to show the next line, which contains specific word, then following command give you the answer:

$ grep <WORD> -A 1 <FILE>

If you would like to see more line(s), increase argument after -A option.

So easy...

a X window trouble

When I connected from localhost to an instance of ubuntu in lxc, I encountered following message upon login via ssh.

X11 forwarding request failed on channel 0

That is, I connected to this host with -X option for the purpose of X forwarding. (so as to use gvim)

$ ssh -X -l ubuntu <lxc_instance_IP>

Let us dig into further by adding verbose option, -v as argument of ssh.

$ ssh -X -v -l ubuntu <lxc_instance_IP>

Then I found following debug message, which states that relevant xauth application does not exist.

debug1: Remote: No xauth program; cannot forward with spoofing.

Ok, let us install xauth on target host side.

$ sudo apt-get install xauth

After installation of xauth, this message never comes up. And I am able to forward X sessions to host without any problem.