linux7 共享盘创建,使用CentOS7建立samba文件共享服务器
1、安裝samba
檢查samba是否已經安裝
[root@bak1 ~]# rpm -qa | grep samba
沒有任何回顯則表示未安裝軟件包 samba
yum安裝samba
[root@bak1 ~]# yum -y install samba samba-client samba-common
再次檢查安裝結果
[root@bak1 var]# rpm -qa | grep samba
samba-common-libs-4.6.2-12.el7_4.x86_64
samba-common-tools-4.6.2-12.el7_4.x86_64
samba-4.6.2-12.el7_4.x86_64
samba-common-4.6.2-12.el7_4.noarch
samba-client-libs-4.6.2-12.el7_4.x86_64
samba-libs-4.6.2-12.el7_4.x86_64
samba-client-4.6.2-12.el7_4.x86_64
確認安裝路徑
[root@bak1 var]# whereis samba
samba: /usr/lib64/samba /etc/samba /usr/libexec/samba /usr/share/man/man7/samba.7.gz
2、配置samba
關閉SELINUX
[root@bak1 ~]# vi /etc/sysconfig/selinux
修改下邊紅字部分
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
關閉防火墻
[root@bak1 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
如果不關閉防火墻需要開UDP137、UDP138、TCP139、TCP445端口
firewall-cmd --add-port=137/udp --permanent
firewall-cmd --add-port=138/udp --permanent
firewall-cmd --add-port=139/tcp --permanent
firewall-cmd --add-port=445/tcp --permanent
firewall-cmd --reload
重啟計算機
[root@bak1 ~]# shutdown -r now
創建共享目錄
[root@bak1 home]# mkdir -p /home/share/software
創建共享用戶組
[root@bak1 home]# groupadd share
創建共享用戶
[root@bak1 home]# useradd -g share -s /sbin/nologin share
注:bak-lt賬戶專門用于備份Windows系統下的文件
設置共享目錄權限
[root@bak1 home]# chown -R share:share /home/share/software
修改共享用戶密碼
[root@bak1 share]# /bin/smbpasswd -a share
New SMB password:
Retype new SMB password:
Added user share.
修改samba配置文件
[root@bak1 share]# vi /etc/samba/smb.conf
配置文件說明如下:
[global] #全局變量
workgroup = WORKGROUP #工作組
security = user #登陸才可訪問共享
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[software] #顯示的共享目錄名
path = /home/share/software #共享目錄路徑
comment = Software Directories #共享目錄描述
writeable = Yes #共享目錄可寫入
write list = share #有寫入權限的用戶
valid users = share #共享目錄的用戶
browseable = Yes #是否可瀏覽文件
read only = No #是否只讀
inherit acls = No
啟動samba服務
systemctl start smb
設置samba服務開機自啟動
[root@bak1 share]# systemctl enable smb
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
標簽:samba,文件共享,share,bak1,CentOS7,home,root,el7
來源: https://blog.51cto.com/lzlutao/2367732
總結
以上是生活随笔為你收集整理的linux7 共享盘创建,使用CentOS7建立samba文件共享服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深圳豪宅税什么时候取消了?深圳豪宅线标准
- 下一篇: linux 计划任务 实例,计划任务 c