Ubuntu 16.04安裝配置Samba服務

1、使用apt-get安裝

sudo apt-get install samba

2、完成後查看samba版本,看是否真正安裝好了

~$ samba
[2017/05/25 07:14:53.739726,  0] ../lib/util/debug.c:947(reopen_logs_internal)
  Unable to open new log file '/var/log/samba/log.%m': Permission denied
[2017/05/25 07:14:53.739797,  0] ../source4/smbd/server.c:372(binary_smbd_main)
  samba version 4.3.11-Ubuntu started.
  Copyright Andrew Tridgell and the Samba Team 1992-2015

3、備份 smb.conf

@ubuntu:~$ sudo cp /etc/samba/smb.conf  /etc/samba/smb.conf.bak
[sudo] password for user: 
@ubuntu:~$ ls /etc/samba
gdbcommands  smb.conf  smb.conf.bak  tls

4、配置smb.conf

sudo gedit /etc/samba/smb.conf

在smb.conf最後加入以下配置並保存,然後退出

[work]
    comment = samba home directory 
    path = /home/user/
    public = yes
    browseable = yes
    public = yes
    read only = no
    valid users = user
    create mask = 0777
    directory mask = 0777 
    force user = nobody
    force group = nogroup
    available = yes

5、增加samba用戶, 一定要操作這一步,否則windows上訪問時輸入用戶名和密碼會不對,訪問不了。

@ubuntu:~$ sudo smbpasswd -a user
New SMB password:
Retype new SMB password:

6、重新啓動samba

sudo service smbd restart

7、查看你的IP地址 ,這個地址爲之前固定下來的IP地址

@ubuntu:~$ ifconfig
ens33     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  
          inet addr:192.168.174.136  Bcast:192.168.174.255  Mask:255.255.255.0
          inet6 addr: fe80::edaa:c21d:b322:a631/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15441 errors:2 dropped:0 overruns:0 frame:0
          TX packets:11070 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21853202 (21.8 MB)  TX bytes:633540 (633.5 KB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1899 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1899 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 

8、在windows上訪問剛配置好的samba
這裏寫圖片描述

9、用用戶名和密碼登錄成後如下所示
這裏寫圖片描述

10、現在可以正常讀寫了。 記得要將要共享的目錄權限改過來。

@ubuntu:~$ chmod 777 work

11、samba 可能會由於 不小心的一些操作或其他一些奇怪的事情造成訪問上的各種問題,可以網上查解決方案,通常會耗時很久還不一定能操作成功。 如果是裝的ubuntu系統並進 行了分區,建議重裝系統更快,自已的工作目錄及相關文件還在home中 。如果裝的虛擬機,建議用快照功能 ,每隔一段時間備份一個。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章