linux安装samba显示依赖包(10分钟学会使用Linux搭建samba服务器文件共享服务器)

前言:在局域网内有很多实现文件共享的方式和协议,可以建站,也可以简单地使用ftp、sftp、samba,对于大部分人的应用来说我们接触到的应该是samba,也就是在Windows系统中的输入\\192.168.1.1 访问到的那个地址,,接下来我们就来聊聊关于linux安装samba显示依赖包?以下内容大家不妨参考一二希望能帮到您!

linux安装samba显示依赖包(10分钟学会使用Linux搭建samba服务器文件共享服务器)

linux安装samba显示依赖包

Linux搭建SAMBA服务器(共享服务器) ---CentOS7

前言:

在局域网内有很多实现文件共享的方式和协议,可以建站,也可以简单地使用ftp、sftp、samba,对于大部分人的应用来说我们接触到的应该是samba,也就是在Windows系统中的输入\\192.168.1.1 访问到的那个地址,

如图所示:

我们今天呢就是需要搭建一个共享文件目录,方便局域网内资料的传输和共享。

1、准备工作

<1> 安装好Linux系统服务器,或者废旧电脑,(性能无所谓,1G运存,单核CPU都可以,网口最好千兆,硬盘要好一点 ) 一台,可以用EXSI或者VMware搭建一个虚拟机,我的主页有教程哦。

<2>有手就行!!!

2、实施步骤2.1 安装samba服务

有很多人这一步失败了,因为网络原因导致的服务安装失败,推荐更换安装源为阿里源或者清华大学源,当然科学上网也是可以的

首先,ssh登录到Linux,安装samba服务

[root@localhost ~]# yum -y install samba-* 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured repositories failed (未知), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=<repoid> ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> or subscription-manager repos --disable=<repoid> 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64

我这边是新安装的系统,执行yum命令时出现了报错,一般定位应该是yum.repos.d/CentOS-Base.repo这个文件问题,更换源即可。详见我的另一篇文章《centos7更换源》https://www.toutiao.com/article/7099662507022746145/,

更换之后继续执行

[root@localhost ~]# yum -y install samba-* //yum安装samba服务 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; 未知的错误" 正在尝试其它镜像。 http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyuncs.com; 未知的错误" 正在尝试其它镜像。 base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 153 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 247 kB 00:00:00 (3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:19 (4/4): updates/7/x86_64/primary_db | 16 MB 00:00:49 正在解决依赖关系 --> 正在检查事务 ---> 软件包 samba.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba.x86_64.0.4.10.16-18.el7_9 将被 更新 --> 正在处理依赖关系 libwbclient = 4.10.16-18.el7_9,它被软件包 samba-4.10.16-18.el7_9.x86_64 需要 --> 正在处理依赖关系 libwbclient = 4.10.16-18.el7_9,它被软件包 samba-4.10.16-18.el7_9.x86_64 需要 ---> 软件包 samba-client.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-client.x86_64.0.4.10.16-18.el7_9 将被 更新 --> 正在处理依赖关系 libsmbclient = 4.10.16-18.el7_9,它被软件包 samba-client-4.10.16-18.el7_9.x86_64 需要 ---> 软件包 samba-client-libs.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-client-libs.x86_64.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 samba-common.noarch.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-common.noarch.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 samba-common-libs.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-common-libs.x86_64.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 samba-common-tools.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-common-tools.x86_64.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 samba-dc.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-dc-libs.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-devel.x86_64.0.4.10.16-18.el7_9 将被 安装 --> 正在处理依赖关系 pkgconfig(tevent),它被软件包 samba-devel-4.10.16-18.el7_9.x86_64 需要 --> 正在处理依赖关系 pkgconfig(talloc),它被软件包 samba-devel-4.10.16-18.el7_9.x86_64 需要 ---> 软件包 samba-krb5-printing.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-libs.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 samba-libs.x86_64.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 samba-pidl.noarch.0.4.10.16-18.el7_9 将被 安装 --> 正在处理依赖关系 perl(Parse::Yapp::Driver),它被软件包 samba-pidl-4.10.16-18.el7_9.noarch 需要 --> 正在处理依赖关系 perl(Parse::Yapp),它被软件包 samba-pidl-4.10.16-18.el7_9.noarch 需要 ---> 软件包 samba-python.x86_64.0.4.10.16-18.el7_9 将被 安装 --> 正在处理依赖关系 python-tevent,它被软件包 samba-python-4.10.16-18.el7_9.x86_64 需要 ---> 软件包 samba-python-test.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-test.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-test-libs.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-vfs-glusterfs.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-winbind.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-winbind-clients.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-winbind-krb5-locator.x86_64.0.4.10.16-18.el7_9 将被 安装 ---> 软件包 samba-winbind-modules.x86_64.0.4.10.16-18.el7_9 将被 安装 --> 正在检查事务 ---> 软件包 libsmbclient.x86_64.0.4.10.16-5.el7 将被 升级 ---> 软件包 libsmbclient.x86_64.0.4.10.16-18.el7_9 将被 更新 ---> 软件包 libtalloc-devel.x86_64.0.2.1.16-1.el7 将被 安装 ---> 软件包 libtevent-devel.x86_64.0.0.9.39-1.el7 将被 安装 ---> 软件包 libwbclient.x86_64.0.4.10.16-5.el7 将被 升级 ...... 已安装: samba-dc.x86_64 0:4.10.16-18.el7_9 samba-dc-libs.x86_64 0:4.10.16-18.el7_9 samba-devel.x86_64 0:4.10.16-18.el7_9 samba-krb5-printing.x86_64 0:4.10.16-18.el7_9 samba-pidl.noarch 0:4.10.16-18.el7_9 samba-python.x86_64 0:4.10.16-18.el7_9 samba-python-test.x86_64 0:4.10.16-18.el7_9 samba-test.x86_64 0:4.10.16-18.el7_9 samba-test-libs.x86_64 0:4.10.16-18.el7_9 samba-vfs-glusterfs.x86_64 0:4.10.16-18.el7_9 samba-winbind.x86_64 0:4.10.16-18.el7_9 samba-winbind-clients.x86_64 0:4.10.16-18.el7_9 samba-winbind-krb5-locator.x86_64 0:4.10.16-18.el7_9 samba-winbind-modules.x86_64 0:4.10.16-18.el7_9 作为依赖被安装: libtalloc-devel.x86_64 0:2.1.16-1.el7 libtevent-devel.x86_64 0:0.9.39-1.el7 perl-Parse-Yapp.noarch 0:1.05-50.el7 python-tevent.x86_64 0:0.9.39-1.el7 更新完毕: samba.x86_64 0:4.10.16-18.el7_9 samba-client.x86_64 0:4.10.16-18.el7_9 samba-client-libs.x86_64 0:4.10.16-18.el7_9 samba-common.noarch 0:4.10.16-18.el7_9 samba-common-libs.x86_64 0:4.10.16-18.el7_9 samba-common-tools.x86_64 0:4.10.16-18.el7_9 samba-libs.x86_64 0:4.10.16-18.el7_9 作为依赖被升级: libsmbclient.x86_64 0:4.10.16-18.el7_9 libwbclient.x86_64 0:4.10.16-18.el7_9 完毕!

提示完毕后,我们的samba服务也是安装完成了

2.2 配置samba用户

[root@localhost ~]# useradd samba //新建一个名为samba的用户 [root@localhost ~]# smbpasswd -a samba //将samba用户设置为samba用户并设置密码 New SMB password: //设置密码 Retype new SMB password://重复密码 Added user samba. //ok [root@localhost ~]#

2.3 配置samba配置文件

服务器IP地址为:192.168.110.198

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.110.198 netmask 255.255.255.0 broadcast 192.168.110.255 inet6 fe80::cdb5:c9cf:586b:b139 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:69:f2:f0 txqueuelen 1000 (Ethernet) RX packets 85407 bytes 82725483 (78.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 67344 bytes 4369038 (4.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

进入samba文件目录

[root@localhost ~]# cd /etc/samba/ //进入samba配置文件目录 [root@localhost samba]# ls lmhosts smb.conf smb.conf.example //三个文件 smb.conf 是samba的配置文件 [root@localhost samba]# cp smb.conf smb.conf.bak //备份配置文件

创建一个新的目录用于存放共享文件夹

[root@localhost ~]# cd /home/samba/ //进入新建的samba账户的子目录,这里可以存放在任意位置,确保samba用户有对应的权限即可 [root@localhost samba]# mkdir sharedir //新建一个名为sharedir的目录 [root@localhost samba]# ls sharedir [root@localhost samba]# chmod 777 sharedir/ //赋予此目录最高权限 [root@localhost samba]# ls sharedir [root@localhost samba]#

效果如图所示

编辑smb.conf

方式1:sudo gedit smb.conf

[ooyy1102@localhost samba]$ sudo gedit smb.conf [sudo] ooyy1102 的密码:

文本框直接编辑

具体内容如下

#可直接复制自取 [global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw map to guest = Bad User #此处将所有匿名访问的用户都识别为guest用户 passdb backend = tdbsam #指向用户后台数据库,也就是我们新建的samba这个用户相关内容,也可以新增其他用户 [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = @printadmin root force group = @printadmin create mask = 0664 directory mask = 0775 [share_test] #新建共享目录名称为share_test path = /home/samba/sharedir #路径 public = yes writdable = yes create mask = 0644 #赋予权限 ,如果不希望其他人写入,这条可以注释掉 directory mask = 0755 ###如需要添加多个目录,依次创建目录和share_test目录即可

[root@localhost opt]# setenforce 0 [root@localhost opt]# systemctl stop firewalld.service //关闭防火墙

Windows上访问\\192.168.110.198

新建一个文件进行测试

完成!

欢迎留言提议!!!

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页