天天看點

管理與維護samba伺服器,配置與管理samba伺服器

安裝Samba伺服器;

環境

CentOS 8 boot 64 位

window 10 64 位

samba軟體包

檢查是否安裝了samba軟體包

rpm -qa | grep samba

沒有安裝軟體包,則使用yum指令安裝

yum clean all

yum -y install samba

samba軟體包如下:

samba-4.11.2-13.el8.x86_64

samba-libs-4.11.2-13.el8.x86_64

samba-common-4.11.2-13.el8.noarch

samba-common-tools-4.11.2-13.el8.x86_64

samba-common-libs-4.11.2-13.el8.x86_64

samba-client-4.11.2-13.el8.x86_64

samba-client-libs-4.11.2-13.el8.x86_64

pcp-pmda-samba-5.0.2-5.el8.x86_64

samba服務

啟動samba服務

systemctl start smb.service

停止samba服務

systemctl stop smb.service

重新開機samba服務

systemctl restart smb.service

檢視samba服務狀态

systemctl status smb.service

開機自啟samba伺服器

systemctl list-unit-files | grep smb

配置Samba伺服器;

samba主配置檔案smb.conf

[myshare]

comment = share

path = /mnt/share

public = yes

Read only = yes

設定samba服務的日志和賬号。

日志

設定日志檔案儲存路徑

log file = /var/log/samba/log.%m

設定日志檔案最大容量,機關為KB

max log size = 50

賬号

samba賬号不能被直接建立,必須存在對應的同名系統賬戶。samba中添加賬号指令為smbpasswd

smbpasswd -a user(使用者名)

建立系統使用者

useradd user(使用者名)

修改系統使用者密碼

passwd user(使用者名)

将系統使用者建立為同名的samba賬号并設定密碼

smbpasswd -a user(使用者名)

關閉防火牆,将selinux設定成允許permissive。

使用firewalld打開關閉防火牆與端口

firewalld的基本使用

啟動: systemctl start firewalld

關閉: systemctl stop firewalld

檢視狀态: systemctl status firewalld

開機禁用: systemctl disable firewalld

開機啟用: systemctl enable firewalld`

systemctl是CentOS7的服務管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。

啟動一個服務:systemctl start firewalld.service

關閉一個服務:systemctl stop firewalld.service

重新開機一個服務:systemctl restart firewalld.service

顯示一個服務的狀态:systemctl status firewalld.service

在開機時啟用一個服務:systemctl enable firewalld.service

在開機時禁用一個服務:systemctl disable firewalld.service

檢視服務是否開機啟動:systemctl is-enabled firewalld.service

檢視已啟動的服務清單:systemctl list-unit-files|grep enabled

檢視啟動失敗的服務清單:systemctl --failed

配置firewalld-cmd

檢視版本: firewall-cmd --version

檢視幫助: firewall-cmd --help

顯示狀态: firewall-cmd --state

檢視所有打開的端口: firewall-cmd --zone=public --list-ports

更新防火牆規則: firewall-cmd --reload

檢視區域資訊: firewall-cmd --get-active-zones

檢視指定接口所屬區域: firewall-cmd --get-zone-of-interface=eth0

拒絕所有包:firewall-cmd --panic-on

取消拒絕狀态: firewall-cmd --panic-off

檢視是否拒絕: firewall-cmd --query-panic

開啟一個端口

添加

firewall-cmd --zone=public --add-port=80/tcp --permanent(--permanent永久生效,沒有此參數重新開機後失效)

重新載入

firewall-cmd --reload

檢視

firewall-cmd --zone= public --query-port=80/tcp

删除

firewall-cmd --zone= public --remove-port=80/tcp --permanent

将selinux設定成允許permissive

[[email protected] ~]# getenforce

Enforcing

[[email protected] ~]# setenforce 0

[[email protected] ~]# getenforce

Permissive

在window系統中測試samba伺服器

在資料總管位址欄中輸入`\192.168.0.1·(samba伺服器ip位址)