Linux和Win7之間的檔案分享權限設定

來源:互聯網
上載者:User

參考連結:http://www.linuxidc.com/Linux/2011-09/43848.htm 

http://apps.hi.baidu.com/share/detail/24793837

samba 是ubuntu和windows之間實現網際網路共用的工具。

1. 安裝samba 

sudo apt-get install samba

查看安裝是否成功:

sudo dpkg -l samba*

輸入上面命令會看到如下輸出:

Desired=Unknown/Install/Remove/Purge/Hold| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)||/ Name           Version        Description+++-==============-==============-============================================ii  samba          2:3.5.11~dfsg- SMB/CIFS file, print, and login server for Uun  samba-client   <none>         (no description available)ii  samba-common   2:3.5.11~dfsg- common files used by both the Samba server aii  samba-common-b 2:3.5.11~dfsg- common files used by both the Samba server aun  samba-tools    <none>         (no description available)un  samba4         <none>         (no description available)un  samba4-clients <none>         (no description available)un  samba4-common  <none>         (no description available)

前面顯示ii表示安裝成功了。

2.建立共用目錄

假設使用者名稱為user_z


mkdir /home/user_z/share (建立share檔案夾用來共用)chmod 777 /home/user_z/share (更改chare的檔案許可權為所有使用者可讀可寫可運行)

3. 備份並編輯smb.conf


sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backupsudo gedit /etc/samba/smb.conf

找到 Authentication參數, 設定 security。

security 的設定可以是為 share, 也可以為 user。設定為 share時,訪問不需要使用者名稱和密碼,也不需要映射使用者和添加使用者密碼。但是為了安全考慮,此處我們設定為 user, 並設定訪問密碼

security = user(這裡也可以設定為share,這時訪問就不需要使用者名稱和密碼了。那麼就不需要映射使用者和添加使用者與密碼)username map = /etc/samba/smbusers

設定[share]參數,假設允許訪問share檔案夾的網路使用者名是guest_z(後面要相應地添加該使用者)

[Share]comment = Shared Folder with username and passwordpath = /home/user_z/sharepublic = yeswritable = yesvalid users = guest_zcreate mask = 0700directory mask = 0700force user = nobodyforce group = nogroupavailable = yesbrowseable = yes

找到Global Settings,設定:

workgroup = WORKGROUP #注意,這裡的WORKGROUP是共用中的工作群組名稱#下面的三行是為了防止出現中文目錄亂碼的情況display charset = UTF-8unix charset = UTF-8dos charset = cp936

4.添加網路賬戶guest_z

sudo useradd guest_z

要注意,上面只是增加了new這個使用者,卻沒有給使用者賦予本機登入密碼。所以這個使用者將只能從遠端存取,不能從本機登入。而且samba的登入密碼可以和本機登入密碼不一樣。現在要新增網路使用者的帳號:

sudo smbpasswd -a guest_z(設定你的new密碼,這個密碼不是開機登入時候用的,是你要訪問WIN共用檔案或者WIN共用檔案訪問你的時候要填的密碼)

5. 編輯smbusers檔案,(若第一次添加使用者,此檔案可能不存在,輸入下面命令,系統會為我們建立一個smbusers檔案)

sudo gedit /etc/samba/smbusers

在smbusers檔案中加上

new = “network username”

儲存,退出。

刪除網路使用者的帳號的命令把上面的 -a 改成 -x;如 sudo smbpasswd -x guest_z

6. 測試並重啟samba,Samba服務會同時啟動兩個服務,其中smbd主要用來管理共用出來的目錄,nmbd主要用來解析NetBIOS名。在Windows系統中, 主機可以被加入一個組中,這樣每個主機都必須有一個名字,這個名字是用於在網上被標誌的名,並非機器的主機名稱,將其稱為NetBIOS名。其中nmbd進 程是隨著smbd進程啟動而啟動。

sudo testparm #測試sudo smbd restartsudo nmbd restart

這樣,在win7命令列中輸入\\linux ip,就可以訪問你linux下的檔案了。

7.遇到的訪問錯誤:

“multiple connections to a server or shared resource”, 一種可能性如下:

(連結:http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/aeeb452d-0254-4bc2-a598-20f1f57ee8e0/)

The network folder specified is currently mapped using a different 
user name and password. To connect using a different user name and 
password, first disconnect any existing mappings to this network 
share. 

To do this

net use * /delete

Press 'Y' on keyboard


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.