Linux操作系统:CentOS 7 -- 访问Samba共享

实 验 报 告

实验题目: 访问Samba共享

实验内容:

1.掌握Samba服务的安装方法。

2.了解Samba服务器配置的工作流程。

3.配置Samba客户端,访问Samba共享。

步骤

  • Widows客户端访问Samba共享

1.安装Samba前使用rpm命令检查系统是否安装Samba相关性软件。

[root@localhost ~]# rpm -qaa |grep samba

2.挂载镜像。

[root@localhost ~]# mount /dev/cdrom /iso

mount: /dev/sr0 写保护,将以只读方式挂载

3.安装前先清理缓存。

[root@localhost ~]# yum clean all

4.安装Samba服务。

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

5.安装完毕,再次使用rpm命令进行查询。

[lqq@localhost ~]$  rpm -qaa |grep samba

6.启动与停止Samba服务,设置重启服务。

[root@localhost ~]# systemctl start smb

[root@localhost ~]# systemctl enable smb

Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.

[root@localhost ~]# systemctl restart smb

[root@localhost ~]# systemctl stop smb

[root@localhost ~]# systemctl start smb

7.切换到Samba配置文件目录。

[lqq@localhost ~]$ su

密码:

[root@localhost lqq]# cd

[root@localhost ~]# cd /etc/samba

8.备份smb.conf。

[root@localhost samba]# ls

lmhosts  smb.conf  smb.conf.example

[root@localhost samba]# cp smb.conf  smb.conf.bak

[root@localhost samba]# ls

lmhosts  smb.conf  smb.conf.example  smb.conf.bak

9.修改配置文件,在文件尾部添加share文件。

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

10.创建share路径目录,并给予权限。

[root@localhost samba]# mkdir /opt/abc                                      #创建目录

[root@localhost samba]# chmod 777 /opt/abc                              #给全部权限

[root@localhost samba]# systemctl stop firewalld.service   #关闭防火墙

[root@localhost samba]# setenforce 0                                    #关闭增强功能

[root@localhost samba]# systemctl start smb.service            #开启Samba服务

11.修改配置文件,步骤同步骤9,设置tech用户写入功能。

[root@localhost samba]# vim smb.conf

12.创建tech和manger用户,

[root@localhost samba]# useradd tech

[root@localhost samba]# useradd manger

[root@localhost samba]# smbpassmd -a tech

[root@localhost samba]# smbpasswd -a tech

New SMB password:

Retype new SMB password:

Added user tech.

[root@localhost samba]# smbpasswd -a manger

New SMB password:

Retype new SMB password:

Added user manger.

#列出smb用户列表。

[root@localhost samba]# pdbedit -L

tech:1018:

manger:1019:

13.创建共享目录test。

[root@localhost samba]# cd /opt

[root@localhost opt]# mkdir test

[root@localhost opt]# ls

abc  rh  test

[root@localhost opt]#chmod 777 /opt/abc                             #给全部权限

[root@localhost opt]# systemctl start smb.service                 #开启Samba服务

14.获取目标IP地址。

[root@localhost samba]# ifconfig

15.利用测试机访问共享目录。

16.用tech用户登录。

17.创建一个文件到test文件夹里面。

18.在Linux查看创建的文件。

[root@localhost opt]# cd test

[root@localhost test]# ls

333.txt

·测试共享成果

1.拍摄当前虚拟机的快照,然后将虚拟机恢复快照到未安装Samba时的状态,克隆虚拟机Server1并命名client1。最后将CentOS恢复拍摄的快照状态。

2.在client1上安装samba-client和cifs-utils。

[lqq@localhost ~]$ su

密码:

[root@localhost lqq]# cd

[root@localhost ~]# mount /dev/cdrom /iso

mount: /dev/sr0 写保护,将以只读方式挂载

[root@localhost ~]# vim /etc/yum.repos.d/dvd.repo

[root@localhost ~]# yum install samba-client -y

[root@localhost ~]# yum install cifs-utils -y

3.使用smbclient命令行共享访问模式浏览共享文件夹,并新建一个testdir目录进行测试。

[root@localhost ~]# smbclient //192.168.179.131/test -U tech%123456

4.Linux客户端使用mount命令挂载共享目录。

[root@localhost ~]# mkdir -p /mnt/sambadata

[root@localhost ~]# mount -t cifs //192.168.179.131/test /mnt/sambadata -o username=tech

Password for tech@//192.168.179.131/test:  ******

5.用ls查看共享目录testdir。

[root@localhost ~]# cd /mnt/sambadata/testdir

[root@localhost testdir]# ls

6.在servic1访问共享目录,并在testdir目录下创建一个文件。

7.在client1中用ls查看共享目录testdir。

[root@localhost testdir]# ls

2030823046

8.共享目录创建成功。

其它

  • 17
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值