Linux系統Samba檔案共享服務

2021-05-01 14:48:55 字數 4196 閱讀 7686

一、samba伺服器的安裝

確認安裝以下軟體包

[root@test ~]# rpm -qa|grep samba

samba-common-3.0.10-1.4e.9

samba-client-3.0.10-1.4e.9

system-config-samba-1.2.21-1

samba-swat-3.0.10-1.4e.9

samba-3.0.10-1.4e.9

二、samba伺服器的配置步驟

1.在smb.conf 檔案中進行共享資源的配置,包括使用者目錄、公共目錄等。

2.使用smbpasswd 命令建立samba 使用者賬號和設定賬號密碼。

3.使用testparm命令測試 smb.conf 配置檔案。

4.使用smb 指令碼啟動samba伺服器。

三、smb.conf 檔案的配置

1.認識smb.conf 檔案:samba伺服器的主配置檔案是smb.conf ,儲存在「/etc/samba/」中。

[root@test ~]# head -5 /etc/samba/smb.conf

# this is the main samba configuration file. you should read the

# smb.conf(5) manual page in order to understand the options listed

# here. samba has a huge number of configurable options (perhaps too

# many!) most of which are not shown in this example

#[root@test ~]# tail /etc/samba/smb.conf

;[myshare]

;   comment = mary's and fred's stuff

;   path = /usr/somewhere/shared

;   valid users = mary fred

;   public = no

;   writable = yes

;   printable = no

;   create mask = 0765

2.如果只需要檢視 smb.conf 配置檔案中的有效配置項,可以去除所有的注釋行和樣例行,使用的命令如下:

[root@test ~]# grep -v "^#" /etc/samba/smb.conf |grep -v "^;"

[global]

workgroup = mygroup

server string = samba server

printcap name = /etc/printcap

load printers = yes

cups options = raw

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

max log size = 50

security = user

socket options = tcp_nodelay so_rcvbuf=8192 so_sndbuf=8192

dns proxy = no

idmap uid = 16777216-33554431

idmap gid = 16777216-33554431

template shell = /bin/false

winbind use default domain = no

[homes]

comment = home directories

browseable = no

writable = yes

[printers]

comment = all printers

path = /var/spool/samba

browseable = no

guest ok = no

writable = no

printable = yes

四、建立samba使用者賬號

[root@test ~]# useradd st02

[root@test ~]# smbpasswd -a st02

new smb password:

retype new smb password:

startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. file successfully created.

added user st02.

[root@test ~]# cat /etc/samba/smbpasswd

st02:500:e8450c7e07112982aad3b435b51404ee:2d7f1a5a61d3a96fb5159b5eef17adc6:[u          ]:lct-49ed664b:

smbpasswd後面可以跟其它引數,如:

u       -h 顯示smbpasswd的命令格式幫助

u       -a 新增指定的使用者賬號

u       -d 禁用指定的使用者賬號

u       -e 啟動指定的使用者賬號

u       -x 刪除指定的使用者賬號

u       不使用任何命令選項時將更改使用者口令。

五、新增公共目錄

在smb.conf 檔案中新增名為[public]的共享資源,並設定如下內容:

[public]

path = /home/testpublic

public = yes

only guest = yes

writable = yes

六、測試smb.conf 檔案配置

[root@test home]# testparm

load smb config files from /etc/samba/smb.conf

processing section "[homes]"

processing section "[printers]"

processing section "[public]"

loaded services file ok.

server role: role_standalone

press enter to see a dump of your service definitions

# global parameters

[global]

workgroup = mygroup

server string = samba server

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

max log size = 50

socket options = tcp_nodelay so_rcvbuf=8192 so_sndbuf=8192

printcap name = /etc/printcap

os level = 33

dns proxy = no

idmap uid = 16777216-33554431

idmap gid = 16777216-33554431

cups options = raw

[homes]

comment = home directories

read only = no

browseable = no

[printers]

comment = all printers

path = /var/spool/samba

printable = yes

browseable = no

[public]

path = /home/testpublic

read only = no

guest only = yes

guest ok = yes

七、啟動samba伺服器

[root@test home]# service smb start

1.         service smb start  啟動samba服務

2.         service smb status 檢視samba服務狀態

3.         service smb stop  停止samba服務

八、利用windows // ip 測試訪問samba伺服器

通過samba設定linux系統目錄為共享

因為搭建了乙個apache伺服器,所以自己想通過windows來直接來修改www下的指令碼檔案,於是搭建了samba服務,配置如下 php browseable yes path var www html writable yes write list root 即允許root 通過 windows...

Linux檔案共享samba

samba可以實現windows和linux之間的檔案共享相互訪問 安裝samba yum install samba samba client samba common 主配置檔案在 etc samba smb.conf 會自動安裝服務指令碼 etc rc.d init.d smb 一 linux...

centos7 0 安裝配置samba檔案共享服務

作為依賴被安裝 pytalloc.x86 64 0 2.1.6 1.el7 samba common libs.x86 64 0 4.4.4 14.el7 3 samba common tools.x86 64 0 4.4.4 14.el7 3 samba libs.x86 64 0 4.4.4 1...