码迷,mamicode.com
首页 > 其他好文 > 详细

samba

时间:2016-04-16 16:53:25      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

一、安装samba并配置

 

[root@localhost ~]# yum install -y samba samba-client

1. 共享一个目录,任何人都可以访问,即不用输入密码即可访问,要求只读
[root@localhost ~]# vim /etc/samba/smb.conf
...
...
workgroup = MYGROUP  #改为 WORKGROUP
...
...
security = user  #改为 share
...
#在文件最末尾加入
[share]
        comment = share all
        path = /tmp/samba
        browseable = yes
        public = yes
        writable = no
[root@localhost ~]# mkdir /tmp/samba
[root@localhost ~]# chmod 777 /tmp/samba
[root@localhost ~]# touch /tmp/samba/sharefiles
[root@localhost ~]# echo "111" > /tmp/samba/sharefiles
[root@localhost ~]# testparm     //测试你配置的smb.conf是否正确
//警告:WARNING: The security=share option is deprecated, 不过影响不大,无需管它。
[root@localhost ~]# /etc/init.d/smb start 

/*在Windows浏览器 或文件夹地址栏输入*/
file://IP/share

--> 看是否能访问到sharefiles



2. 共享一个目录,使用用户名和密码登录后才可以访问,要求可以读写
[root@localhost ~]# vim /etc/samba/smb.conf
//global 部分按照以下修改
[global]
        workgroup = WORKGROUP
        server string = Samba Server Version %v
        security = user
        passdb backend = tdbsam
        load printers = yes
        cups options = raw

//再在文件最尾部增加
[myshare]
        comment = share for users
        path = /samba
        browseable = yes
        writable =i yes
        public = no

[root@localhost ~]# mkdir /samba
[root@localhost ~]# chmod 777 /samba
//添加可访问samba共享文件夹的用户,用户必须在系统中存在
[root@localhost ~]# useradd user1 user2

//为用户添加samba账号
[root@localhost ~]# pdbedit -a user1
[root@localhost ~]# pdbedit -a user2
[root@localhost ~]# pdbedit -L      //列出samba所有账号
[root@localhost ~]# service samba restart

测试:
打开IE浏览器输入  or   文件地址栏
file://IP/myshare/


3. 使用linux访问samba服务器 {要安装samba-client}
//用法 :smbclient //IP/共享名  -U 用户名

[root@localhost]# smbclient //10.0.4.67/myshare/ -U user1
Password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-151.el6]
smb: \> ls

/*常用的有cd, ls, rm, pwd, tar, mkdir, chown, get, put等等,使用 help+ 命令可以打印该命令如何使用,其中get是下载,put是上传。也可使用挂载:

mount -t cifs //10.0.4.67/myshare /mnt -o username=user1,password=123456
格式就是这样,要指定 -tcifs//IP/共享名本地挂载点 -o后面跟username 和 password 挂载完后就可以像使用本地的目录一样使用共享的目录了,注意共享名后面不能有斜杠。*/

 

samba

标签:

原文地址:http://www.cnblogs.com/frankielf0921/p/5398329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!