Wednesday, September 26, 2012

How to access Windows Share from Linux and Vice versa


There are two ways. Use command line tool called smbclient or you can mount windows shares the mount command. Another option is use GUI tools. 

Mount Windows share using mount command

This is simple way to share data between windows and linux system. You would like to access MS-Windows share called //windowsserver/sharename by mounting to /mnt/pankaj directory under Linux system. Type the following command (replace username, windows server name, share name and password with actual values):

# mkdir -p /mnt/pankaj
[root@stn01 mnt]# mount -t smbfs -o username=pankaj.pal,password= mypassword //10.10.8.192/Firdous /mnt/pankaj
mount: unknown filesystem type 'smbfs'
                                                                              OR
[root@stn01 mnt]# mount -t cifs -o username=pankaj.pal,password= mypassword //10.10.8.192/Firdous /mnt/pankaj

[root@stn01 mnt]# cd /mnt/pankaj
[root@stn01 pankaj]# ls -l
total 24325653
-rwxr-xr-x. 0 root root  2147483648 May  1 04:15 564dee48-da1d-79a3-59e8-1a7131e65e9e.vmem
-rwxr-xr-x. 0 root root  4185118720 Jun 25 18:39 CentOS-5.5-i386-bin-DVD.iso
-rwxr-xr-x. 0 root root   652234752 May  3 04:02 en_win_srv_2003_r2_standard_x64_with_sp2_vl_cd1_x13-47808.iso
For the share //windowsserver/sharename to be automatically mounted at every system start (after reboot), insert an option in the file /etc/fstab:

# vi /etc/fstab

Append following line (written in a single line)
//10.10.8.192/share /mnt/win cifs
auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0


Next create the password file /etc/sambapasswords:
# vi /etc/sambapasswords

Now add following content:
username=pankaj
password=mypassword


Save and close the file. Make sure only root can access your file:
# chown 0.0 /etc/sambapasswords
# chmod 600 /etc/sambapassw


Just to let you know – if you put a space with the equals sign in your credentials file, like this:

username = pankaj
 password = mypassword

it will error out ‘permission denied’
You HAVE to have no spaces on each line like this:

username=pankaj
 password= mypassword

Mount Linux share on Windows


Create User on Linux Server


[root@stn01 abc]# useradd firdous
[root@stn01 abc]# passwd firdous
Changing password for user firdous.
New password:
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.


Create Samba password for the user

[root@stn01 abc]# smbpasswd -a firdous
New SMB password:
Retype new SMB password:
Added user firdous.


[root@stn01 abc]# cd /home/firdous/

[root@stn01 firdous]# ls -l
total 0


[root@stn01 firdous]# touch abc

[root@stn01 firdous]# ls -l
total 0
-rw-r--r--. 1 root root 0 Sep 26 08:54 abc


Now Login to your Windows Server


Start ---> Run -- open : Linux Server Ip


It will ask for the credentials of the Linux server


username : firdous

Password : mypassword (Samba Password which you created above)

that's all you will get the access of /home/firdous folder of linux. 










1 comment:


  1. Khó khăn lắm né qua một đạo chùm tia sáng Tiêu Viêm, trông thấy lại là tam thúc quang mang hướng hắn phóng tới. Hơn nữa đánh úp lại trên đường, hoàn toàn phong tỏa Tiêu Viêm sở hữu tất cả đường lui.

    "Móa nó, liều dongtam
    game mu
    http://nhatroso.net/
    http://nhatroso.com/
    nhac san cuc manh
    tư vấn luật qua điện thoại
    dịch vụ thành lập công ty trọn gói
    văn phòng luật
    tổng đài tư vấn pháp luật
    thành lập công ty
    http://we-cooking.com/
    chém gió
    trung tâm ngoại ngữmạng!"

    "Kim Cương Lưu Ly Thân", "Viêm Đế Thân", "Tịch Diệt Hỏa Thể" khởi!"

    "Viêm Hoàng Lục Giác Không Linh Thuẫn! Hợp! Ngự!"

    Đối mặt đánh úp lại ba đạo chùm tia sáng, Tiêu Viêm một cổ món óc đem tự mình biết phòng ngự đấu kỹ toàn bộ thi triển ra."Rầm rầm rầm phanh! . . ." Liên tục ba đạo chùm tia sáng công kích đều tận đã rơi vào Tiêu Viêm trên thân thể. Một búng máu mũi tên nhịn không được xì ra.

    Thân thể Tiêu Viêm thì là bị đánh bay hơn trăm dặm.

    ReplyDelete