CentOS配置smaba與Windows共用檔案

來源:互聯網
上載者:User

標籤:style   class   code   http   tar   ext   

作業環境:CentOS 6.5 64bit

Linux與Linux間通過什麼共用檔案呢——NFS,Windows與Windows之間呢——共用檔案功能就OK了,那Windows與Linux之間呢?

這就是本段要講的東東——samba。

檢查是否安裝samba
# rmp -qa|grep samba

若安裝了,則會顯示如下,

samba4-libs-4.0.0-58.el6.rc4.x86_64samba-common-3.6.9-168.el6_5.x86_64samba-winbind-3.6.9-168.el6_5.x86_64samba-client-3.6.9-168.el6_5.x86_64samba-3.6.9-168.el6_5.x86_64samba-winbind-clients-3.6.9-168.el6_5.x86_64

否則,使用

# yum install smaba

安裝samba.

配置samba
  1. 設定開機啟動

    # chkconfig smb on# chkconfig nmb on

    也可以使用setup命令可通過介面配置開機啟動服務,

    # setup

  2. 建立smb使用者用於訪問Linux共用檔案

    # useradd smb       # 建立使用者# smbpasswd -a smb  # 修改密碼

    此時/home目錄會增加一個smb的使用者。該Linux使用者目錄將可直接共用到Windows下。若要共用其它檔案,按步驟3設定檔。如果不用了,刪除smb使用者也是可以的,

    # smbpasswd -x smb  # 刪除smb使用者
  3. samba設定檔。

    [tmp]comment = Tmp Directoriespath = /tmp                         # 共用的Linux目錄public = no                         # 目錄不公開writeable = yes                     # 可寫browseable = yes                    # 可讀valid users = smb                   # 訪問使用者,上面建立的,也可以使用原來已有的
讓smaba通過防火牆

使用samba需要穿過防火牆,因此根據不同情況,這裡提供3種方法:

  • 方法1

    # system-config-firewall

  • 方法2

    配置/etc/sysconfig/iptables檔案,添加

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT

    允許139 445 137 138幾個連接埠通過。配置完後重啟防火牆,

    # /etc/rc.d/init.d/iptables restart
  • 方法3

    索性,把防火牆關了,

    # service iptables stop    # 暫時關閉# chkconfig iptables off  # 永久關閉
關閉SELINUX
# vim /etc/selinux/configSELINUX=permissive

此時需要重啟下系統,

# reboot
啟動samba
# service samba start   # 啟動# service samba restart # 重啟

可以通過

# service samba status

查看samba啟動狀態。

Windows訪問

先查看Linux虛擬機器網路ip地址,

# ifconifgeth0      Link encap:Ethernet  HWaddr 00:0C:29:FD:DC:43            inet addr:192.168.56.58  Bcast:192.168.56.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:fefd:dc43/64 Scope:Link

在Windows下使用Win+R開啟運行視窗,輸入

\\192.168.56.58

即可訪問Linux共用的目錄。

此時使用

# smbstatus

查看串連狀態。

檔案存取權限:

若無法從Windows中往共用目錄中拷貝檔案,可能由於共用目錄對smb使用者的寫入權限不足,Linux中使用chmod 777 -R dir可改變dir目錄許可權。由於許可權原因,本文中使用/tmp目錄共用,因為/tmp目錄對所有使用者的許可權比較開放。

參考
  1. http://www.livingelsewhere.net/tag/unix-linux-samba-ftp-smb-cifs/
  2. http://www.tangrucheng.com/centos6-5-setup-configure-samba.html
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.