• samba服务配置记录


    操作系统

    #查看系统内核
    [root@localhost ~]# uname -a
    Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
    [root@localhost ~]#
    

      

    #查看编译信息
    [root@localhost ~]# cat /proc/version
    Linux version 3.10.0-957.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018
    [root@localhost ~]#
    

      

    #查看系统版本信息
    [root@localhost ~]# cat /etc/issue
    S
    Kernel 
     on an m
    
    [root@localhost ~]# cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core) 
    [root@localhost ~]# 
    

      

    安装samba

    #查看是否已经安装了samba
    [root@localhost ~]# rpm -qi samba
    Name        : samba
    Epoch       : 0
    Version     : 4.9.1
    Release     : 10.el7_7
    Architecture: x86_64
    Install Date: 2020年04月14日 星期二 09时40分57秒
    Group       : Unspecified
    Size        : 2037345
    License     : GPLv3+ and LGPLv3+
    Signature   : RSA/SHA256, 2019年12月03日 星期二 23时54分34秒, Key ID 24c6a8a7f4a80eb5
    Source RPM  : samba-4.9.1-10.el7_7.src.rpm
    Build Date  : 2019年12月03日 星期二 01时50分11秒
    Build Host  : x86-01.bsys.centos.org
    Relocations : (not relocatable)
    Packager    : CentOS BuildSystem <http://bugs.centos.org>
    Vendor      : CentOS
    URL         : http://www.samba.org/
    Summary     : Server and Client software to interoperate with Windows machines
    Description :
    Samba is the standard Windows interoperability suite of programs for Linux and
    Unix.
    [root@localhost ~]#
    

      

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

      

    配置并启动samba

    # 先看我配置之后的文件内容
    [root@localhost ~]# cat /etc/samba/smb.conf
    # See smb.conf.example for a more detailed config file or
    # read the smb.conf manpage.
    # Run 'testparm' to verify the config is correct after
    # you modified it.
    
    [global]
    	workgroup = WORKGROUP # 这里改成与windows一样的工作名字
    	security = user
    
    	passdb backend = tdbsam
    
    	printing = cups
    	printcap name = cups
    	load printers = yes
    	cups options = raw
    
    # 这里注释掉home目录的访问,否则samba访问时可以看到home目录
    #[homes]
    	#comment = Home Directories
    	#valid users = %S, %D%w%S
    	#browseable = No
    	#read only = yes
    	#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
    
    # 以下内容是我从隔壁的 smb.conf.example 文件中拷贝过来修改的
    # 大概就是 开放 /home/tools 目录
    # 只有系统 root 组下的用户可以进行写操作(write list)
    # 其他用户只有读权限(read only)
    # A publicly accessible directory that is read only, except for users in the
    # "root" group (which have write permissions) -> "write list":
    [tools]
           comment = shared tools folder
           path = /home/tools
           public = yes
           writable = no
           printable = no
           read only = yes
           write list = +root
    
    [root@localhost ~]#
    

      

    # 添加一个系统用户 zhangsan,并且创建同名主目录,即 /home/zhangsan
    [root@localhost ~]# useradd -m zhangsan
    
    # 更改系统用户密码,这个是SSH或者桌面登陆用的,也可以不设置密码。
    # 根据提示设置密码。
    [root@localhost ~]# passwd zhangsan
    
    # 将 zhangsan 添加到samba用户,根据提示设置samba登陆密码
    [root@localhost ~]# smbpasswd -a zhangsan
    
    # 启用 shangsan 用户
    [root@localhost ~]# smbpasswd -e zhangsan
    
    # 我设置的共享目录是 /home/tools,新建的是zhangsan的系统用户
    # 我把 tools的属主改成 zhangsan 了,这一步不操作应该可以可以
    [root@localhost ~]# chown -R zhangsan /home/tools
    
    
    # 启用samba服务,这样重启电脑后就会自动启动samba了
    [root@localhost ~]# systemctl enable smb.service
    
    # 启动samba服务
    [root@localhost ~]# systemctl start smb.service
    
    [root@localhost ~]#
    # 好了,去windows下试试看吧
    

      

    目前使用 zhangsan 登陆后,只能读取,如果要使用root用户进行读写,需要使用 “smbpasswd -a root” 将root添加到samba,并且设置密码,这样就能通过root登陆,然后进行读写操作了。

    注意samba密码跟系统的密码是不一样的,虽然名字一样,但是密码完全不是同一个。

    如果转载,请注明出处。https://www.cnblogs.com/ssdq/
  • 相关阅读:
    第6章 解决问题 6-1 机器学习解决问题(1)
    第5章 常见的算法和分类 5-2 机器学习常见算法和分类(2)
    Linux中Shell数组的笔记
    Linux中Shell数组的笔记
    Linux中Shell中取消变量和特殊变量的笔记
    Linux中Shell中取消变量和特殊变量的笔记
    Linux实现MYSQl数据库的定时备份
    Linux中su和sudo的用法整理
    Linux用户组笔记整理
    Linux 用户管理命令笔记
  • 原文地址:https://www.cnblogs.com/ssdq/p/12696853.html
Copyright © 2020-2023  润新知