安装samba
sudo yum -y install samba
sudo yum -y install samba-common samba-client
安装后
[wuyujun@wuyujunlocalhost ~]$ service smb status //查看状态
smbd 已停
[wuyujun@wuyujunlocalhost ~]$ service smb start
[wuyujun@wuyujunlocalhost ~]$ //没有任何提示
[wuyujun@wuyujunlocalhost ~]$ service smb status //查看状态
smbd 已停
[wuyujun@wuyujunlocalhost ~]$ sudo ntsysv //尝试用ntsysv启动
ntsysv 1.3.49.5 - (C) 2000-2001 Red Hat, Inc.
┌────────────┤ 服务 ├────────────┐
│ │
│ 您想自动启动哪些服务? │
│ │
│ [*] rpcbind ↑ │
│ [*] rpcgssd ▒ │
│ [ ] rpcsvcgssd ▒ │
│ [*] rsyslog ▒ │
│ [ ] saslauthd ▒ │
│ [ ] smartd ▮ │
│ [*] smb ▒ │
│ [*] spice-vdagentd ↓ │
│ │
│ ┌──────┐ ┌──────┐ │
│ │ 确定 │ │ 取消 │ │
│ └──────┘ └──────┘ │
│ │
│ │
└────────────────────────────────┘
[wuyujun@wuyujunlocalhost ~]$ service smb status //查看状态
smbd 已停
[wuyujun@wuyujunlocalhost ~]$ sudo /etc/init.d/smb start
启动 SMB 服务: [确定]
[wuyujun@wuyujunlocalhost ~]$ service smb status
smbd (pid 4575) 正在运行...
/etc/init.d/smb start
service 一般都是调用 inin.d 下面的
配置samba服务器
[wuyujun@wuyujunlocalhost 桌面]$ sudo vim /etc/samba/smb.conf //配置samba服务器
[global] //设置samba服务整体环境
workgroup = MYGROUP //设置工作组名称
server string = Samba Server Version %v //服务器的字符串,服务器的描述
; netbios name = MYSERVER
; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
; hosts allow = 127. 192.168.12. 192.168.13. //设置哪个计算机或者那个网络能够访问
# --------------------------- Logging Options -----------------------------
#
# Log File let you specify where to put logs and how to split them up.
#
# Max Log Size let you specify the max size log files should reach
# logs split per machine
log file = /var/log/samba/log.%m //指定samba日志文件的地址
# max 50KB per log file, then rotate
max log size = 50 //指定samba日志的尺寸50k
##============================ Share Definitions ==============================
[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S
[printers]
comment = All Printers //允许共享所以打印机
path = /var/spool/samba //路径
browseable = no
guest ok = no
writable = no
printable = yes
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no
# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes
# A publicly accessible directory, but read only, except for people in
# the "staff" group
[public] //共享目录的名称
comment = Public Stuff //注释说明
path = /usr/local/wyj //共享目录的路径
public = yes //是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用)
writable = yes //是yes/否no不以只读方式共享当与read only发生冲突时,无视read only
browseable = yes //是yes/否no在浏览资源中显示共享目录,若为否则必须指定共享路径才能存取
guest ok = yes //是否允许来宾用户访问是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用)
; printable = no
; write list = +staff
290,2-8 底端
配置完之后注意要重启服务器
[wuyujun@wuyujunlocalhost local]$ sudo /etc/init.d/smb restart //重启服务器
关闭 SMB 服务: [确定]
启动 SMB 服务: [确定]
[wuyujun@wuyujunlocalhost wyj]$ sudo service iptables stop //关闭防火墙
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[wuyujun@wuyujunlocalhost wyj]$ ifconfig eth0 //查看linux ip地址 192.168.100.131
eth0 Link encap:Ethernet HWaddr 00:0C:29:DA:92:ED
inet addr:192.168.100.131 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feda:92ed/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:127968 errors:0 dropped:0 overruns:0 frame:0
TX packets:36237 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:171586389 (163.6 MiB) TX bytes:2244407 (2.1 MiB)
在windows中打开文件资源管理器输入\\192.168.100.131进行访问
在Linux的浏览器输入SMB://192.168.100.131进行访问
浏览器打开后在Linux的桌面上也会出现
注意的问题:
1,防火墙要关闭,#service iptables stop
2,每次配置完要重启samba服务器
3,selinux要设置成disabled,路径是/etc/sysconfig/selinux
4,需要用选项去掉开头的“#”或“;”
5,注意共享目录的权限设置
6,要设置成不需要用户名密码直接访问,需要修改配置文件,将安全设置成security = share。
使用smbpasswd添加共享用户的常用方法:
smbpasswd -a添加用户添加用户必须是系统用户)
的smbpasswd -d冻结用户(这个用户不能使用了)
的smbpasswd -e恢复用户(将冻结的用户解冻)
的smbpasswd -n将用户密码设置为空
smbpasswd -x删除用户
参考博客:HTTPS://www.cnblogs.com/hxgoto/p/7071175.html