linux *** 作 Samba服务器设置

linux  *** 作 Samba服务器设置,第1张

在Linux平台,以二进制程序包和源代码两种方式安装samba服务器,并整理相关配置文件,并给出基本应用 *** 作。

步骤:

1.机器上已经存在的samba服务,版本为3.0.21b,这是通过使用rpm命令得到的。如下:

# rpm –qa | grep samba

Samba-client-3.0.21b-2

Samba-common-3.0.21b-2

2.将上面的samba-client-3.0.21b-2卸载。使用命令:rpm –e samba-client-3.0.21b-2。

3.用rpm –e samba-common-3.0.21b-2来卸载common,因为依赖关系,不成功。

4.下载二进制程序包:

samba-common-3.0.23c-4.i386.rpm,

samba-client-3.0.23c-4.i386.rpm,

samba-doc-3.0.23c-4.i386.rpm,

samba -3.0.23c-4.i386.rpm。

5.安装这些程序包。分别使用命令:

rpm –Uvh samba-common-3.0.23c-4.i386.rpm

rpm –ivh samba-client-3.0.23c-4.i386.rpm

rpm –ivh samba-3.0.23c-4.i386.rpm

rpm –ivh samba-doc-3.0.23c-4.i386.rpm

使用选项Uvh来安装common是因为原来的common没有被卸载,因此应进行升级安装(U)。

6.安装完毕后,可以使用rpm –qa samba来确认。会输出samba-3.0.24c-4。

7.下面开始对samba服务进行配置。

8.首先,修改/etc/samba/lmhosts文件。加入一行,为本机上的Windows系统IP地址和主机名。这样才可以通过Windows来访问Unix的samba服务。

9.创建目录/export/sambadir作为共享目录。

命令:mkdir –p /export/sambadir

chmod 777 /export/sambadir

10.修改/etc/samba/smb.conf文件。这是samba的配置文件。

Security = user

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

Path = /export/sambadir

11.使用testparam来测试修改结果。

12.加入一个用户,并修改其密码。

13.使用chkconfig命令来设置在启动级别5中启动samba。命令如下:

Chkconfig –list | grep smb

Chkconfig –level 5 smb on

Chkconfig –list | grep smb

14.重新启动网络服务:

/etc/rc.d/init.d/cups stop

/etc/rc.d/init.d/smb restart

15.然后就可以在Windows系统中通过12步中设定的用户名和密码来访问Linux。

16.使用源代码的安装方式:下载samba-3.0.23c.tar.gz源代码包,解压。

Cd samba-3.0.23c/source

./autogen.sh

./configure –prefix=/usr –localstatedir=/var –with-configdir=/etc/samba –with-privatedir=/etc/samba –with-fhs –with-quotas –with-smbmount –enable-cups –with-pam_smbpass –with-syslog –with-utmp –with-swatdir=/usr/share/swat –with-shared-modules=idmap_rid –with-libsmbclient

Make

Make install

17.其余步骤与7之后相同。

这是我实验时写的,平台是redhat 9

实验要求:

Samba文件共享服务配置与访问,配置访问用户以及相应权限。

Tips:创建共享目录/test和/share,并且分别在/test下创建文件tf1(只读)tf2(读写) 在/share 下创建文件pf1(只读)和pf2(读写)

1、挂载本地yum源

[root@localhost /]# mkdir /media/cdrom

[root@localhost /]# mount /dev/cdrom /media/cdrom/

[root@localhost /]# vim /etc/yum.repos.d/rhel-source.repo

rhel-source]

name=Red Hat Enterprise Linux $releasever - $basearch - Source

basefile:///media/cdrom

enabled=1

2、关闭Selinux 和 IPtables

[root@localhost /]# vim /etc/selinux/config//路径

[root@localhost /]# setenforce 0//临时关闭Selinux

[root@localhost /]# /etc/init.d/iptables stop//关闭防火墙

3、安装samba服务

[root@localhost /]# yum install samba -y

4、创建共享用户

[root@localhost /]# smbpasswd -a smb

[root@localhost /]# smbpasswd -a smb

5、修改配置文件

[root@localhost /]# vim /etc/samba/smb.conf

workgroup = WORKGROUP//Win需要修改为工作组

server string = Samba Server Version %v

security = user //可以改为everyone

passdb backend = tdbsam

[test]

path = /test

public = yes

writeable = yes

valid users = smb

[share]

path = /share

public = yes

writeable = yes

valid users = smb

6、创建本地共享目录和文件权限

[root@localhost /]# mkdir /test /share

[root@localhost /]# chown -R smb.smb /test/ /share/

[root@localhost test]# touch tp1 tp2

[root@localhost test]# chmod 444 tp1

[root@localhost test]# chmod 666 tp2

[root@localhost test]# echo "111" >/test/tp1//ceshi 文本

[root@localhost test]# echo "222" >/test/tp2

[root@localhost test]# service smb restart//开启服务 测试


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8735212.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-20
下一篇 2023-04-20

发表评论

登录后才能评论

评论列表(0条)

保存