环境是centos5.6 windows server 2008
实现linux与windows的文件共享
1.安装samba
yum install -y samba samba-client
2.更改配置文件
vi /etc/samba/smb.conf [share] #共享名 comment = Public Stuff #通用名 path = /var/share #共享目录路径 public = no #允许用户不用账号和密码访问 writable = yes #写权限 printable = no #打印服务 write list = @administrator @test #可以写的用户 vaild users = @administrator @test #有效的用户 guest ok = yes #windows与linux共享 browseable = yes #可浏览
3.创建共享目录,并更改权限
mkdir /var/share chmod 777 /var/share chown administrator.root /var/share
4.创建smb用户,首先要创建系统用户
useradd administrator echo "admin" |passwd --stdin administrator smbpasswd -a administrator
5.重启samba服务
[root@md-im1 ~]# testparm #测试配置文件 Load smb config files from /etc/samba/smb.conf Processing section "[homes]" Processing section "[printers]" Processing section "[share]" Unknown parameter encountered: "vaild users" Ignoring unknown parameter "vaild users" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions /etc/init.d/smb start chkconfig smb on
6.测试连接
[root@md-im1 ~]# smbclient //localhost/share -U administrator Password: Domain=[MD-IM1] OS=[Unix] Server=[Samba 3.0.33-3.39.el5_8] smb: \> ls . D 0 Tue Sep 17 13:17:20 2013 .. D 0 Tue Sep 17 13:17:20 2013 smb: \> put nginx-1.2.0.zip putting file nginx-1.2.0.zip as \nginx-1.2.0.zip (38396.2 kb/s) (average 38396.3 kb/s) smb: \> ls . D 0 Tue Sep 17 13:35:02 2013 .. D 0 Tue Sep 17 13:17:20 2013 nginx-1.2.0.zip A 1140217 Tue Sep 17 13:35:02 2013
windows使用UNC路径连接linux的IP地址,,输入用户名跟密码进入,使用网络映射驱动器
进入后看到
可以在windows里创建文件,并写入
linux里可以看到该文件
转载于:https://blog.51cto.com/charlie928/1298181