samba 伺服器的主要程式
smbd:提供對伺服器中檔案、列印資源的共享通路
nmbd:提供基于 netbios 主機名稱的解析
samba 的配置目錄及檔案
/etc/samba/
/etc/samba/smb.conf
配置檔案檢查工具:testparm
smb.conf 檔案的配置内容
[global]:全局設定
[homes]:使用者目錄共享設定
[printers]:列印機共享設定
[myshare]:自定義名稱的共享目錄設定
輔助配置内容
注釋行:以 # 号開頭的行
配置樣例行:以 ; 号開頭的行
結合 grep 指令可以提取有效配置行
grep -v "^#" smb.conf | grep -v "^;" | grep -v ^$
常見全局配置項的含義
workgroup:所在工作組名稱
server string:伺服器描述資訊
security:安全級别,可用值如下
user、server、domain
log file:日志檔案位置,“%m”
變量表示客戶機位址
passwd backend:設定共享賬戶檔案的類型
常見共享目錄配置項的含義
comment:對共享目錄的注釋、說明資訊
path:共享目錄在伺服器中對應的實際路徑
browseable:該共享目錄在“網路上的芳鄰”中是否可見
guest ok:是否允許所有人通路,等效于“public”
writable:是否可寫,與 readonly
的作用相反
通路共享檔案夾
smbclient 指令,檢視及登入使用共享
smbclient -l 192.168.1.20
smbclient -u sunboy //192.168.4.11/tools
[rootelocalhost sharel# s#clinent -l 192.168.1.20
bash: smbclinent:
[root@localhost sni3ciient -l 192.168.1.20
enter satoa\root's password:
sharenanw
print$
public
peixun
yanta
ipc$
reconnecting with
wo rkg roup
type
disk
ipc
comment
printer drivers
publ ic
yan fa
ipc service (sarba 4.18.16)
for workgroup listing.
mas te r
(root@locathost d " title="[root@localhost share]# systextl stop firewatld
(root@locathost d " style="visibility: visible; width: 576px; height: 414px;">
使用 mount 挂載共享檔案夾
mount -0 username—hunter 1/192.168.4.11/t001s
imedia/smbdir/
password:
mount i tail -1
samba
1/192.168.4.11/tools on imedia/smbdir type c
(rw, relatime, vers=l.
,unix,posixpa
60,acümeo=1) " title="mkdir imedia/smbdir
60,acümeo=1) " style="visibility: visible; width: 654px; height: 247px;">
1.首先挂載CD光牒 切換到/yum.repos.d/目錄 删除所有檔案 修改檔案 然後安裝samba伺服器
mount: /dev/srß
[ root@localhost
t root@tocalhost
mount /dev/cdrom/ /mnt/
cd 'etc/ yum. repos . d/
yum. repos.dl#
- 1 root root 54 9k 14 09:49 zz.repo
-rw-r--r-
[root@localhost yum. repos. rm -rf
[root@localhost yum. repos. vim zz. repo
troot@localhost yum. repos.dl# vim zz. repo
[root@localhost yum. repos.dl# yum install sarnba•
fastes tmirror, langpacks
loading mirror speeds from cached hostfile
-4.10.16-5.e17.x86 64
samba-
client-libs-4.1e.16-5.e17.x86_64
samba -
commn-toois-4. 1b.16-5. el 7 . x86 _64
samba-common-4_16 16-5 e17_noarch
-y " title="[ root@localhost
-y " style="visibility: visible; width: 643px; height: 327px;">
-file:///mnt " title="[root@localhost yum. repos.dl# vim zz. repo
-file:///mnt " style="visibility: visible; width: 494px; height: 150px;">
2.切換到samba目錄,将配置檔案備份
root@localhost saüal# is
unhosts snb. conf snb. conf. example
[root@localhost sambal* cp slit). conf smb.conf.bak " title="( root@locathost yum. repos .dl# cd / etc/sa±a
[root@localhost sambal* cp slit). conf smb.conf.bak " style="visibility: visible; width: 595px; height: 86px;">
3.修改samba伺服器配置檔案
進去後到最後添加以下
/ldo/
uauıujc:)
[zzl " title="/4do/—q'ld
[zzl " style="visibility: visible; width: 384px; height: 169px;">
最上面在中間插入任何使用者可以通路的指令
[global]
scrarity
pretinq
= samba
user
ls'.i
tdhsam
cups
— cups
load p: —
cups options — " title="# you modi
cups options — " style="visibility: visible; width: 328px; height: 279px;">
4.啟動smb服務 過濾一下這個服務
虛拟機的虛拟網卡設定為vmnet1
與主機能夠通信
囤 usb 控 制
咼 打 印 機
0 顯 示 器
自 定 又 (vmnet1)
存 在
自 動 椧 兩
有 在
目 動 檢 兩
o 所 鼈 式 陽 ) : 自 連 理 網 掐
0 複 制 物 理 網 絡 連 接 忒 态 舊
o nat 模 式 ( n ) : 用 于 # 主 榌 的 伊 地 址
c) 僅 主 機 模 式 ( 田 : 與 主 枳 共 享 的 專 用 網 絡
0 寶 又 ( u ) : 特 定 膚 拟 網 絡
vmnet1 ( 僅 主 祖 模 式 )
c)laneer(l):
lan 區 的 “
高 (v) “ " title="網 絡 适 配 器
高 (v) “ " style="visibility: visible; width: 654px; height: 250px;">
複 複 複
字 字 字
、 / ^ 0 0 乙 0 乙 0 乙
1 回 回 回
1 節 節 節
0 ' 00 00 00
00 0 0 0
嘔 的 的 的
節 》
據 牖 牖 " title="還 在 自 自 自
據 牖 牖 " style="visibility: visible; width: 579px; height: 223px;">
5.在本地運作輸入虛拟機的ip位址 測試共享檔案夾
主 頁 # 臯 看
巪 制 徑
移 動 到 短 制 0
稭 麩 匣 方 忒
忄 到 》 網 絡 > 19206 & l20
qqpcmgr
0 onedrive
愆 此 電 蕕
彐 d 對 象
0 新 建 頂 0 .
0 松 訪 問 ,
牖 除 重 叾 " title="到 到 一 「 1g2 、 168 . l20
牖 除 重 叾 " style="visibility: visible; width: 654px; height: 340px;">
6.給/opt/這個目錄一個讀取執行寫入的權限,在本機上可以上傳檔案
i root@localhost opt] #
777 /opt/
1664
1309
649
314
630
1331
8515
616
5071
log
23
13
31
2020
centos. base. re
centos- cr. repo
cen tos- debugin
centos- fasttra
centos- media. r
centos. sources
centos- vault. r
centos- xe6 64-
xr-x
root
i nobody
nobody
10:56 lamp-7.3. txt
201 e rh " title="[ root@localhost opt] # chmod
201 e rh " style="visibility: visible; width: 539px; height: 235px;">
= this is my share
= /opt/share #
path
= yes #
= usi
write list
= 0664 #
create mask
= 0775#
directory mask " title="[share]
directory mask " style="visibility: visible; width: 654px; height: 193px;">
rootn8s- node: mount . o username—lisi / '192.168.0.63/opt/share /test
•assuord for tisio//192.168.o.63/opt/share:
•ount error(2): no such
file or directory
tefer to the mount. cifs
manual oa e [e.
root"8s- no del
for share:
root*8s- nodel df
devtmpfs i .
fevtmpts
:mpfs
: mpfs
'dev/mapper/centos- root
sdal
dev/ mapper/ centos- home
man mount. c ifs)
tmpfs
tmpts
xfs
1.96
sog
1014m
466
13m
6.56
183m
33m
446
830m
46 g
27 q"
0%
19%
/ dev
/ dev/ shm
run
/ sys/fs/cgroup
/ boot
/ home " title="root"8s- node: mkdir / test
/ home " style="visibility: visible; width: 654px; height: 242px;">
清除遠端管理緩存指令
你 有 以 下 的 遠 程 連 接 .
\ \ 192 . 16 & 1.20\ipc$
繼 續 運 行 會 取 消 連 接 ;
你 想 繼 續 此 操 作 嗎 ? (y/n) cni : y
命 令 成 功 完 成 。 " title="\users\gecong>net use /d *
命 令 成 功 完 成 。 " style="visibility: visible; width: 419px; height: 179px;">
添加網卡
rootb10cathost network- scripts] # cp -p ifcfg- ens33 ifcfg- ens37
i rootßlocalhost network- scripts] # cp ifcfg- ens33 ifcfg- ens37
cp: r ifcfg- ens37"? y
i rootstocalhost network- scripts] # vim ifcfg- ens37 ' title='i rootelocalhost # cd /etc/sysconfig/network- scripts/
i rootstocalhost network- scripts] # vim ifcfg- ens37 ' style="visibility: visible; width: 570px; height: 89px;">
編輯配置檔案
proxy method=" none"
arowser only4no'
a00tprot0é' static'
defrouteq' yes n
name* ens37'
ens37
onboot=• yes'
20.10'
netmask=" o • " title="type* ethe rnetl
netmask=" o • " style="visibility: visible; width: 251px; height: 212px;">
切換到samba目錄,将配置檔案備份
修改samba伺服器配置檔案
first
cornment
= topt/
public— yes
writable = yes
hosts
losts 92.168.20. " title="i zzl
losts 92.168.20. " style="visibility: visible; width: 298px; height: 132px;">
建立使用者登入
i rootb10ca1host -l useradd zhian
i root610calhost -l pdbedlt -a zhian
new password:
retype new password: " title="i rootoiocaihost network- scriptsl cd
retype new password: " style="visibility: visible; width: 413px; height: 93px;">