Monday, November 30, 2009

Sharing files/folders to Windows clients from linux (Ubuntu)

Right click the folder that needs to be shared. Select the option 'Sharing Options'. The file manager window gets open.



Enable 'Share this folder'. On doing so, if the sharing service is not installed the following window will appear.



Press the button "Install service". It will install the SMB service.



After successful installation, it will ask to retsart your session.



Press the button "Restart session".

And now add a SMB user. To do so, open the terminal in Ubuntu and type the following command.

 sudo smbpasswd -a username

This will ask for the new SMB password for the username given. Provide the SMB password. After successful addition of SMB user, the shared folder can be accessed from the windows client using the username and password created.

End Of Line (EOL) in Linux and Windows

The end of a line of text is marked by the EOL character. The EOL character differs between Windows and Linux.

In Linux, the EOL character is line feed (LF) character '\n'. Whereas in Windows, the EOL character is carriage return (CR) character '\r' followed by the line feed (LF) character '\n'.

For example, create a text file containing the following in both Linux (LinuxSampleTxtDocument.txt) and Windows (WindowsSampleTxtDocument.txt).

 this is first line
 this is second line
 this is third line

And dump the contents of both the files.
sh-3.1$ hexdump -cb LinuxSampleTxtDocument.txt
0000000   t   h   i   s       i   s       f   i   r   s   t       l   i
0000000 164 150 151 163 040 151 163 040 146 151 162 163 164 040 154 151
0000010   n   e  \n   t   h   i   s       i   s       s   e   c   o   n
0000010 156 145 012 164 150 151 163 040 151 163 040 163 145 143 157 156
0000020   d       l   i   n   e  \n   t   h   i   s       i   s       t
0000020 144 040 154 151 156 145 012 164 150 151 163 040 151 163 040 164
0000030   h   i   r   d       l   i   n   e  \n
0000030 150 151 162 144 040 154 151 156 145 012
000003a

sh-3.1$ hexdump -cb WindowsSampleTxtDocument.txt
0000000   t   h   i   s       i   s       f   i   r   s   t       l   i
0000000 164 150 151 163 040 151 163 040 146 151 162 163 164 040 154 151
0000010   n   e      \r  \n   t   h   i   s       i   s       s   e   c
0000010 156 145 040 015 012 164 150 151 163 040 151 163 040 163 145 143
0000020   o   n   d       l   i   n   e  \r  \n   t   h   i   s       i
0000020 157 156 144 040 154 151 156 145 015 012 164 150 151 163 040 151
0000030   s       t   h   i   r   d       l   i   n   e
0000030 163 040 164 150 151 162 144 040 154 151 156 145
000003c

Sunday, November 29, 2009

Mounting external hard disk

Once my external hard disk is not properly removed after use from Windows OS. And when I tried to access the hard drive using Linux (Ubuntu) OS, I faced the problem of failure in mounting the drive. Following is the snapshot of the diagnostic I received on connecting the external hard disk to Linux (Ubuntu) OS.


To fix the problem I forced the mount of external hard disk manually. The manual mount of external hard disk is done using the following commands in terminal.

sudo mount -t ntfs-3g /dev/sdb1 /media/disk/ -o force

And unmounted the external hard disk using the following command:

sudo umount /media/disk/


The problem got fixed. On subsequent access I found that the external hard disk is mounted automatically by the Linux (Ubuntu) OS.