要求:
- create vnc service for win7 access it via vnc viewer.
- 1TB disk for this Centos PC is used as Samba server, which used to share files. and nsn-intra user could access the folder via their personal win7 pc with map network drive.
- on this 1TB disk, create three folder with name: 1) "temp" 2) "pet_qcbak" 3) "pet_granny"
- on folder temp, the file rule is that delete the file after it was created 2 weeks later.
[root@localhost home]# rpm -qa | grep samba 已经安装的软件包,有些可以选择不安装 samba-libs-4.2.10-7.el7_2.x86_64 samba-4.2.10-7.el7_2.x86_64 samba-winbind-clients-4.2.10-7.el7_2.x86_64 samba-common-libs-4.2.10-7.el7_2.x86_64 samba-vfs-glusterfs-4.2.10-7.el7_2.x86_64 samba-common-4.2.10-7.el7_2.noarch samba-test-libs-4.2.10-7.el7_2.x86_64 samba-winbind-modules-4.2.10-7.el7_2.x86_64 samba-pidl-4.2.10-7.el7_2.noarch samba-winbind-krb5-locator-4.2.10-7.el7_2.x86_64 samba-client-4.2.10-7.el7_2.x86_64 samba-winbind-4.2.10-7.el7_2.x86_64 samba-dc-4.2.10-7.el7_2.x86_64 samba-devel-4.2.10-7.el7_2.x86_64 samba-client-libs-4.2.10-7.el7_2.x86_64 samba-dc-libs-4.2.10-7.el7_2.x86_64 samba-test-devel-4.2.10-7.el7_2.x86_64 samba-common-tools-4.2.10-7.el7_2.x86_64 samba-python-4.2.10-7.el7_2.x86_64 samba-test-4.2.10-7.el7_2.x86_64
[root@localhost home]# egrep -v "(^;|^#|^$)" /etc/samba/smb.conf 配置权限共享目录 [global] workgroup = LinuxSir server string = Linux Samba Server Sir # log files split per-machine: log file = /var/log/samba/log.%m # maximum size of 50KB per log file, then rotate: max log size = 50 security = user passdb backend = tdbsam # the following login script name is determined by the machine name # (%m): # the following login script name is determined by the UNIX user used: # use an empty path to disable profile support: # various scripts can be used on a domain controller or a stand-alone # machine to add or delete corresponding UNIX accounts: load printers = yes cups options = raw # obtain a list of printers automatically on UNIX System V systems: [homes] comment = Home Directories browseable = no writable = yes [public] comment = public path = /sambadata public = yes writable = yes[root@localhost home]# fdisk -l | grep sda //sda2作为共享硬盘 Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 1953525167 976249560 83 Linux [root@localhost home]# blkid /dev/sda2 //获取uuid /dev/sda2: UUID="1584f527-57d5-4d6e-a7f8-a29c6f069bdf" TYPE="xfs" [root@localhost home]# cat /etc/fstab | grep "/sambadata" //实现开机自动挂载 UUID=1584f527-57d5-4d6e-a7f8-a29c6f069bdf /sambadata xfs defaults 0 0 [root@localhost home]#[root@localhost ~]# mkdir -p /sambadata/{temp,pet_granny,pet_qcbak} //新建共享文件夹 [root@localhost sambadata]# id samba //用户id uid=1001(samba) gid=1001(samba) groups=1001(samba) [root@localhost sambadata]# smbpasswd -a samba //转换系统用户为samba用户 New SMB password: Retype new SMB password: [root@localhost sambadata]# pdbedit -L //查看 samba:1001: !!!!!!!!! 请关闭防火墙 centos7 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 centos6.x service iptables stop chkconfig --del iptables chkconfig iptables off 请关闭selinux: vim /etc/selinux/conf SELINUX=disabled //修改为disabled setenforce 0 //临时关闭实现定期删出2周前的文件:[root@localhost sambadata]# vim /usr/local/bin/clear //添加执行脚本命令 #!/bin/bash find /sambadata/temp/ -mtime +14 -name "*.*" -exec rm -rf {} ; [root@localhost sambadata]# chmod +x /usr/local/bin/clear //执行权限 [root@localhost sambadata]# crontab -e //执行自动化删除任务 * 2 * * * /usr/local/bin/clear
测试: