如何使Linux和windows和平共處,共同協作,用Samba,是一套免費開源軟體,他可以在Linux或者其他類Unix作業系統上,實現windows網域控制站、檔案伺服器、列印伺服器等功能。
Samba可以提供功能如下:
活動目錄服務Active Directory Service,ADS)
主網域控制站
共用目錄
共用印表機
安裝Samba並測試
安裝Samba,執行以下命令
650) this.width=650;" title="clip_image002" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image002" src="http://www.bkjia.com/uploads/allimg/131227/1P40644P-0.jpg" "683" height="32" />
650) this.width=650;" title="clip_image004" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image004" src="http://www.bkjia.com/uploads/allimg/131227/1P40AL3-1.jpg" "681" height="292" />
650) this.width=650;" title="clip_image006" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image006" src="http://www.bkjia.com/uploads/allimg/131227/1P40645A-2.jpg" "681" height="382" />
650) this.width=650;" title="clip_image008" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image008" src="http://www.bkjia.com/uploads/allimg/131227/1P4061X1-3.jpg" "680" height="387" />
執行sudo apt-get install smbclient
650) this.width=650;" title="clip_image010" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image010" src="http://www.bkjia.com/uploads/allimg/131227/1P40C151-4.jpg" "674" height="333" />
查看運行狀態
650) this.width=650;" title="clip_image012" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image012" src="http://www.bkjia.com/uploads/allimg/131227/1P4062M2-5.jpg" "680" height="97" />
啟動Samba伺服器只需執行如下命令:
#sudo /etc/init.d/samba start
650) this.width=650;" title="clip_image014" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image014" src="http://www.bkjia.com/uploads/allimg/131227/1P40C3U-6.jpg" "676" height="287" />
可以看到Samba服務會同時啟動兩個服務,其中smbd主要用來管理共用出來的目錄,nmbd主要用來解析NetBIOS名。在Windows系統中,主機可以被加入一個組中,這樣每個主機都必須有一個名字,這個名字是用於在網上被標誌的名,並非機器的主機名稱,將其稱為NetBIOS名。其中nmbd進程是隨著smbd進程啟動而啟動。
重新啟動Samba伺服器:
#/etc/init.d/samba restart
驗證安裝,開啟windows 運行\\UbuntuIP\
650) this.width=650;" title="clip_image016" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image016" src="http://www.bkjia.com/uploads/allimg/131227/1P40AN9-7.jpg" "679" height="344" />
配置Samba服務
Samba伺服器主要設定檔為/etc/samba/smb.conf,並且可以將NetBIOS名與主機的對應關係寫在/etc/samba/lmhosts檔案中。
1) 在Windows系統中不用輸入密碼訪問Linux共用目錄
在Linux共用一個目錄,將建立好的目錄的設定資訊寫入/etc/smb.conf檔案即可。如:若共用/home/share目錄,要在Windows系統中訪問這個共用的目錄,假設Windows主機的IP為192.168.0.11,Linux主機的IP為192.168.10,進行如下操作:
650) this.width=650;" title="clip_image018" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image018" src="http://www.bkjia.com/uploads/allimg/131227/1P4064208-8.jpg" "680" height="187" />
#mkdir /home/share#vi smb.conf
將檔案中的內容做如下相應修改:
security=user 改為security=share
在檔案結尾添加如下行:
[share]
comment=this is Linux share directory
path=/home/share
public=yes
writable=yes
650) this.width=650;" title="clip_image020" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image020" src="http://www.bkjia.com/uploads/allimg/131227/1P40B107-9.jpg" "662" height="374" />
2) 儲存退出,啟動Samba服務:
3) #/etc/init.d/samba start
設定完成!
驗證:
650) this.width=650;" title="clip_image022" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image022" src="http://www.bkjia.com/uploads/allimg/131227/1P40B936-10.jpg" "652" height="331" />
650) this.width=650;" title="clip_image024" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image024" src="http://www.bkjia.com/uploads/allimg/131227/1P4064000-11.jpg" "660" height="335" />
預設沒有寫入許可權,修改
650) this.width=650;" title="clip_image026" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image026" src="http://www.bkjia.com/uploads/allimg/131227/1P40B135-12.jpg" "667" height="153" />
650) this.width=650;" title="clip_image028" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="clip_image028" src="http://www.bkjia.com/uploads/allimg/131227/1P4061J6-13.jpg" "655" height="333" />
3.安裝中文支援能夠顯示中文)
sudo apt-get install language-support-zh
===============================================================
我研發的IT整合課程
試聽 http://www.91xueit.com 試聽下載
650) this.width=650;" title="titel263" border="0" alt="titel263" src="http://www.bkjia.com/uploads/allimg/131227/1P40642I-14.jpg" "650" height="201" />
650) this.width=650;" title="12353" border="0" alt="12353" src="http://www.bkjia.com/uploads/allimg/131227/1P40Aa4-15.jpg" "650" height="300" />
650) this.width=650;" title="system63" border="0" alt="system63" src="http://www.bkjia.com/uploads/allimg/131227/1P40CJ7-16.jpg" "650" height="359" />
650) this.width=650;" title="system373" border="0" alt="system373" src="http://www.bkjia.com/uploads/allimg/131227/1P4061G6-17.jpg" "650" height="561" />