关闭防火墙并且重启网络
yum install samba  samba-client samba-commmon -y
systemctl start smb
smbclient -L //172.25.254.104                         匿名用户登陆(vim /etc/hosts)
pdbedit -L                                                        显示smb用户
smbpasswd -a student                                        添加smb用户 只能添加系统上已经存在的
                 
[root@localhost ~]# pdbedit -x cq            删除 smb用户
[root@localhost ~]# pdbedit -L
smbclient -L //172.25.254.103 -U student                 以某一个用户登陆
ls 与 !ls                                                                    ls为列出共享目录的文件,!ls为列出,所在所在目录里的文件
 

mount //172.25.254.103/student /mnt/ -o username=student,password=111     挂载共享文件目录到mnt

cd /mnt

touch westos{1..9}

smbclient  //172.25.254.103/student  -U student

vim /etc/fstab                                                   设置开机挂载
此时把文件系统挂载在mnt目录下.这样就可以向共享文件系统里写文件了。

vim /etc/sysconfig/selinux
改成enforcing
重新启动系统
此时访问不了共享目录关闭火墙 打开smb
smbclient //172.25.254.104/student  -U student
Enter student's password:
Connection to 172.25.254.104 failed (Error NT_STATUS_CONNECTION_REFUSED) //当selinux开启时,不能和查看共享文                                                                                                                                             件系统
 
 getsebool -a | grep samb              查看共享文件系统的开关

[root@localhost ~]# setsebool -P samba_create_home_dirs on
[root@localhost ~]# setsebool -P samba_enable_home_dirs on    //打开创建目录查看目录的权限
 
[root@localhost ~]# vim /etc/samba/smb.conf          创建共享目录,并指定路径
         [linux]
         comment = dir from westos
         path = /westos
[root@localhost ~]# mkdir /westos/file{1..3}
[root@localhost ~]# systemctl start samb             重新启动
[root@localhost ~]# smbclient //172.25.254.104/student -U student  发现查看不了文件
setenforce 0                                                                                           把selinux变为警告模式
[root@localhost ~]# smbclient //172.25.254.104/student -U student 可以查看

[root@localhost ~]# restorecon -RvvF /westos/
[root@localhost ~]# semanage fcontext -a -t samba_share_t '/westos(/.*)?' //  查看配置文件后发现安全上下文不一致,生成安全上下文
[root@localhost ~]#  serenforce 1  //此时开启selinux
[root@localhost ~]# smbclient //172.25.254.104/student -U student //可以查看

 vim /etc/samba/smb.conf
         [linux]
         comment = dir from westos
         path = /westos
         [mnt]
         comment = dir from westos
         path = /mnt                 //设置系统共享目录
 systemctl restart smb
  setsebool -P samba_export_all_ro on  //开启一个大的权限不需要修改安全上下文就可以查看所有。
 smbclient -L //172.25.254.104 -U student //查看可以共享的目录
rm -rf /westos
mkdir /westos
touch /westos/file1

此时查看就不需要改安全上下文

 
yum install nfs-utils
systemctl start nfs                                          服务器上安装开启nfs
 showmount -e 172.25.254.103

vim /etc/exports   编辑文件
/westos               *(sync)  /以sync的方式共享/westos上的文件

exportfs -rv                                   重载,这个文件不能通过重启来生效

 exporting *:/westos

 
自动化挂载:
在客户端安装 yum install autofs.x86_64 -y
systemctl start autofs
vim /etc/sysconfig/autofs 配置文件可以更改停止时间
systemctl restart autofs.service
cd  /net/172.25.254.104/westos/  共享文件目录

实际挂载目录为  /net/172.25.254.103/westos/

vim /etc/auto.master 修改挂载目录


vim /etc/auto.nfs

systemctl restart autofs.service

vim /etc/auto.nfs
/westos    *(rw,sync)                               使文件具有可写的权限

/westos    *(rw,sync,anonuid=1001)                                指定文件产生的所有人

/westos    *(ew,sync,anonuid=1001,anongid=1000)指定文件所有组所有人

/westos    *(rw,sync,no_root_squash)    默认所有组所有人为root

/westos    *(ro) 172.25.254(rw,sync,no_rooot_squash)除了这个ip外的所有主机都仅仅有只读权限

 

linu samba服务的更多相关文章

  1. samba服务

    安装samba服务步骤ps -e 查看进程ps -e | grep 文件名 管道符的使用rpm -qa 安装包的查看rpm -qa | grep samba 抓Samba安装包 注释:包与包之间有依赖 ...

  2. OpenWrt中开启usb存储和samba服务

    在从官网安装的WNDR3800 15.05.1版本OpenWrt中, 不带usb存储支持以及samba, 需要另外安装 1. 启用usb支持 USB Basic Support https://wik ...

  3. 虚拟机利用Host-only实现在不插网线的情况下,虚拟机与主机实现双向通信,实现ssh连接以及samba服务实现共享

    为了不影响其他的虚拟网卡,我们在VMware下在添加一块虚拟网卡: 然后点击Next,选择连接方式: 点击Finish即可. 重新启动虚拟机,如果这是你手动添加的第一块虚拟网卡,那么应该是eth1. ...

  4. Samba服务配置简明笔记

    内部服务器之间拷贝数据,用root账号访问,没有做更复杂的设置. 1.用YUM安装samba服务器端及客户端: [root@tenjs05 init.d]# yum install samba sam ...

  5. 部署samba服务之后,在客户端用挂载访问的方式,错误信息:mount: block device //192.168.1.108/mysqldata is write-protected, mounting read-only mount: cannot mount block device //192.168.1.108/mysqldata read-only

    部署samba服务之后,在客户端用挂载访问的方式,错误信息:mount: block device //192.168.1.108/mysqldata is write-protected, moun ...

  6. (转)CentOs上配置samba服务

    前 言 在我们使用 Windows 作为客户机的时候,通常有文件.打印共享的需求.作为Windows 网络功能之一,通常可以在 Windows 客户机之间通过 Windows Network 固有的功 ...

  7. linux基础-第十七单元 Samba服务

    Samba的功能 Samba的安装 Samba服务的启动.停止.重启 Samba服务的配置 Samba服务的主配置文件 samba服务器配置实例 Samba客户端设置 windows客户端 Linux ...

  8. 配置samba服务一例

    问题: 在/data/share目录下建立三个子目录public.training.devel用途如下 public目录用于存放公共数据,如公司的规章制度 training目录用于存放公司的技术培训资 ...

  9. samba服务搭建及管理

    关闭防火墙 # /etc/init.d/iptables stop # chkconfig --level iptables off 关闭SELINUX # vim /etc/sysconfig/se ...

随机推荐

  1. 【总结整理】webGIS学习

    安装ArcGIS Server + ArcSDE + PostgreSQL + ArcMap安装(windows7)博客:https://blog.csdn.net/buqutianya/articl ...

  2. MSSQL数据库设计心得

    统一库名命名规则. 格式:公司简称_库名 如:Supesoft_Member  会员库 建库时,最好将初始大小设置为你认为可允许的最大容量.避免因为库太小,而出现系统自增加.在系统运行中,自动增加空间 ...

  3. grep多条件和sed合并两行

    grep多条件,最简单的方式是使用正则表达式: egrep "条件1|条件2"   sed合并两行,将 1 2 3 4 合并成: 1 2 3 4 sed '$!N;s/\n/\t/ ...

  4. 解决PendingIntent传递参数为空的问题

    PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent,  0); 在接收端,接收的数据一直为null,在google ...

  5. 有三个线程,a、b、c,a打印“T1”,b打印“T2”,c打印“T3”,a执行完后,b执行;b执行完后,c执行。如此循环100遍

    有三个线程,a.b.c,a打印“T1”,b打印“T2”,c打印“T3”,a执行完后,b执行:b执行完后,c执行.如此循环100遍. package com.company; /** * 测试三个线程协 ...

  6. Python入门:模拟登录(二)或注册之requests处理带token请求

    转自http://blog.csdn.net/foryouslgme/article/details/51822209 首先说一下使用Python模拟登录或注册时,对于带token的页面怎么登录注册模 ...

  7. Java50道经典习题-程序40 字符串排序

    题目:根据字符串内字符的ASCII码值对字符串数组进行排序.分析:字符串用ASCII码比较大小,规则是:1.比较首字母的ASCII码大小2.若是前面的字母相同,则比较之后的字母的ASCII码值3.若是 ...

  8. Java50道经典习题-程序42 求数字

    题目:809*??=800*??+9*??+1其中??代表两位数,若有这样得数,求??代表的两位数 public class Prog42{ public static void main(Strin ...

  9. 手把手教你如何制作和使用lib和dll_转载

    目录 静态库 什么是静态库? 怎么创建 如何使用 静态库的第一种使用方法 静态库的第二种使用方法 动态链接库 动态库是什么? 怎么创建 如何使用 隐式调用 显式调用 静态库什么是静态库?我们先来说一下 ...

  10. 算法训练 Balloons in a Box (枚举,模拟)

    问题描述 你要写一个程序,使得能够模拟在长方体的盒子里放置球形的气球. 接下来是模拟的方案.假设你已知一个长方体的盒子和一个点集.每一个点代表一个可以放置气球的位置.在一个点上放置一个气球,就是以这个 ...