您的位置:首页 > 其它

Ubuntu 16.04安装配置Samba服务

2017-05-25 22:58 866 查看
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中 。如果装的虚拟机,建议用快照功能 ,每隔一段时间备份一个。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: