(以下內容均來自網絡學習)
root用戶執行
1、
使用yum -y install samba samba-client samba-common安裝Samba
rpm -qi samba可以查看samba版本信息
[root@MiWiFi-R1CM-srv samba]# rpm -qi samba
Name : samba
Epoch : 0
Version : 4.2.10
Release : 6.2.el7_2
Architecture: x86_64
Install Date: Tue 19 Jul 2016 03:26:55 AM CST
Group : System Environment/Daemons
Size : 1895784
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256, Fri 24 Jun 2016 04:12:11 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.2.10-6.2.el7_2.src.rpm
Build Date : Fri 24 Jun 2016 02:38:45 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
[root@MiWiFi-R1CM-srv samba]#
2、設置開機啟動:
Name : samba
Epoch : 0
Version : 4.2.10
Release : 6.2.el7_2
Architecture: x86_64
Install Date: Tue 19 Jul 2016 03:26:55 AM CST
Group : System Environment/Daemons
Size : 1895784
License : GPLv3+ and LGPLv3+
Signature : RSA/SHA256, Fri 24 Jun 2016 04:12:11 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : samba-4.2.10-6.2.el7_2.src.rpm
Build Date : Fri 24 Jun 2016 02:38:45 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.samba.org/
Summary : Server and Client software to interoperate with Windows machines
Description :
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
[root@MiWiFi-R1CM-srv samba]#
# systemctl enable smb.service
3、查看是否設置成功# systemctl status smb.service
4、啟動samba服務# systemctl start smb.service
5、再次查看啟動狀態
# systemctl status smb.service
[root@MiWiFi-R1CM-srv samba]# systemctl status smb.service● smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2016-07-19 03:32:36 CST; 12min ago
Main PID: 27455 (smbd)
Status: "smbd: ready to serve connections..."
CGroup: /system.slice/smb.service
├─27455 /usr/sbin/smbd
├─27460 /usr/sbin/smbd
└─27601 /usr/sbin/smbd
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: Starting Samba SMB Daemon...
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: smb.service: Supervising process 27455 which is not our child. We'll most likely not n... exits.
Jul 19 03:32:36 MiWiFi-R1CM-srv systemd[1]: Started Samba SMB Daemon.
Jul 19 03:32:36 MiWiFi-R1CM-srv smbd[27455]: [2016/07/19 03:32:36.184968, 0] ../lib/util/become_daemon.c:124(daemon_ready)
Jul 19 03:32:36 MiWiFi-R1CM-srv smbd[27455]: STATUS=daemon 'smbd' finished starting up and ready to serve connections
Hint: Some lines were ellipsized, use -l to show in full.
[root@MiWiFi-R1CM-srv samba]#
6、配置配置文件
進入目錄:
# cd /etc/samba
備份:# cp smb.conf smb.conf.backup
修改smb.conf文件,找到“[homes]”,修改以下設置:
[global]
log file = /var/log/samba/log.%m
load printers = yes
cups options = raw
server string = Samba Server Version %v
writeable = yes
force directory mode = 777
force create mode = 777
workgroup = MYGROUP
security = user
create mode = 777
passdb backend = tdbsam
max log size = 50
log file = /var/log/samba/log.%m
load printers = yes
cups options = raw
server string = Samba Server Version %v
writeable = yes
force directory mode = 777
force create mode = 777
workgroup = MYGROUP
security = user
create mode = 777
passdb backend = tdbsam
max log size = 50
新版的samba放在smb.conf最后是無效的
7、添加用戶
# smbpasswd -a username
如果出現 bash: smbpasswd: command not found,就是沒有安裝samba-client了
附: smbpasswd命令的常用方法
smbpasswd -a 增加用戶(要增加的用戶必須以是系統用戶)
smbpasswd -d 凍結用戶,就是這個用戶不能在登錄了
smbpasswd -e 恢復用戶,解凍用戶,讓凍結的用戶可以在使用
smbpasswd -n 把用戶的密碼設置成空.要在global中寫入 null passwords -true
smbpasswd -x 刪除用戶
8、selinux設置
# getsebool -a | grep samba
# setsebool -P samba_enable_home_dirs on
9、防火牆,使用新的防火牆firewall添加就可以,比iptables更方便
# firewall-cmd --list-services
# firewall-cmd --permanent --add-service=samba
# firewall-cmd --reload
# firewall-cmd --list-services
由於redhat7開始,iptables被firewalld代替了,所以使用firewalld的方法
關於firewalld的說明,可以看fedora官網介紹
10、重啟samba服務
# systemctl restart smb.service