smaba

技术文章admin 发表了文章 • 0 个评论 • 13 次浏览 • 2019-03-12 11:12 • 来自相关话题

[root@localhost ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# cp /etc/samba/smb.conf.bak /etc/samba/smb.conf
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# groupadd xxzx
[root@localhost ~]# useradd yp -G xxzx
[root@localhost ~]# smbpasswd -a yp
New SMB password:
Retype new SMB password:
Added user yp.
[root@localhost ~]# mkdir -p /home/backup_v53
[root@localhost ~]# cd /home/
[root@localhost home]# chmod -R 0777 /backup_v53
chmod: 无法访问"/backup_v53": 没有那个文件或目录
[root@localhost home]# ls
backup_v53  yp
[root@localhost home]# chmod -R 0777 backup_v53/
[root@localhost home]# chcon -t samba_share_t backup_v53/
[root@localhost home]#
[root@localhost home]# systemctl restart smb.service
[root@localhost home]# systemctl restart nmb.service
[root@localhost home]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[backup_v53]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
        printcap name = cups
        security = USER
        workgroup = SAMBA
        idmap config * : backend = tdb
        cups options = raw


[homes]
        browseable = No
        comment = Home Directories
        inherit acls = Yes
        read only = No
        valid users = %S %D%w%S


[printers]
        browseable = No
        comment = All Printers
        create mask = 0600
        path = /var/tmp
        printable = Yes


[print$]
        comment = Printer Drivers
        create mask = 0664
        directory mask = 0775
        force group = @printadmin
        path = /var/lib/samba/drivers
        write list = @printadmin root


[backup_v53]
        path = /home/backup_v53
        read only = No
        valid users = @xxzx
[root@localhost home]# chown -R yp:xxzx backup_v53/
[root@localhost home]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@localhost home]# firewall-cmd --reload
success
[root@localhost home]# 查看全部
[root@localhost ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# cp /etc/samba/smb.conf.bak /etc/samba/smb.conf
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# vi /etc/samba/smb.conf
[root@localhost ~]# groupadd xxzx
[root@localhost ~]# useradd yp -G xxzx
[root@localhost ~]# smbpasswd -a yp
New SMB password:
Retype new SMB password:
Added user yp.
[root@localhost ~]# mkdir -p /home/backup_v53
[root@localhost ~]# cd /home/
[root@localhost home]# chmod -R 0777 /backup_v53
chmod: 无法访问"/backup_v53": 没有那个文件或目录
[root@localhost home]# ls
backup_v53  yp
[root@localhost home]# chmod -R 0777 backup_v53/
[root@localhost home]# chcon -t samba_share_t backup_v53/
[root@localhost home]#
[root@localhost home]# systemctl restart smb.service
[root@localhost home]# systemctl restart nmb.service
[root@localhost home]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[backup_v53]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
        printcap name = cups
        security = USER
        workgroup = SAMBA
        idmap config * : backend = tdb
        cups options = raw


[homes]
        browseable = No
        comment = Home Directories
        inherit acls = Yes
        read only = No
        valid users = %S %D%w%S


[printers]
        browseable = No
        comment = All Printers
        create mask = 0600
        path = /var/tmp
        printable = Yes


[print$]
        comment = Printer Drivers
        create mask = 0664
        directory mask = 0775
        force group = @printadmin
        path = /var/lib/samba/drivers
        write list = @printadmin root


[backup_v53]
        path = /home/backup_v53
        read only = No
        valid users = @xxzx
[root@localhost home]# chown -R yp:xxzx backup_v53/
[root@localhost home]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@localhost home]# firewall-cmd --reload
success
[root@localhost home]#

DOS 新建IIS 网站

技术文章admin 发表了文章 • 0 个评论 • 12 次浏览 • 2019-03-10 20:28 • 来自相关话题

echo Please use administrator privileges to run.
::请使用管理员权限执行
cd /d %~dp0
::站点名称
set name=2605h

::绑定域名和端口号
set domain=%name%.ak:80
::网站源文件物理路径
set physicalPath="%cd%wwwroot\%name%"
 
::设置权限
echo Y|cacls %physicalPath% /T /G Everyone:F
::删除同名网站
%systemroot%/system32/Inetsrv/APPCMD.exe delete site /site.name:%name%
::删除同名程序池
%systemroot%/system32/Inetsrv/APPCMD.exe delete AppPool /AppPool.name:%name%
::添加程序池
%systemroot%/system32/Inetsrv/APPCMD.exe add AppPool /name:%name% /managedRuntimeVersion:""
::添加网站
%systemroot%/system32/Inetsrv/APPCMD.exe add site /name:%name% /physicalPath:%physicalPath% /bindings:",http://www.%domain%"
::设置程序池
%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:%name% /[path='/'].applicationPool:%name%
 
pause 查看全部
echo Please use administrator privileges to run.
::请使用管理员权限执行
cd /d %~dp0
::站点名称
set name=2605h

::绑定域名和端口号
set domain=%name%.ak:80
::网站源文件物理路径
set physicalPath="%cd%wwwroot\%name%"
 
::设置权限
echo Y|cacls %physicalPath% /T /G Everyone:F
::删除同名网站
%systemroot%/system32/Inetsrv/APPCMD.exe delete site /site.name:%name%
::删除同名程序池
%systemroot%/system32/Inetsrv/APPCMD.exe delete AppPool /AppPool.name:%name%
::添加程序池
%systemroot%/system32/Inetsrv/APPCMD.exe add AppPool /name:%name% /managedRuntimeVersion:""
::添加网站
%systemroot%/system32/Inetsrv/APPCMD.exe add site /name:%name% /physicalPath:%physicalPath% /bindings:",http://www.%domain%"
::设置程序池
%systemroot%/system32/Inetsrv/APPCMD.exe set site /site.name:%name% /[path='/'].applicationPool:%name%
 
pause

DOS命令创建站点命令集合(常用调用IIS功能命令)

技术文章admin 发表了文章 • 0 个评论 • 15 次浏览 • 2019-03-10 10:53 • 来自相关话题

很多人都对各大IDC网站开发的建站助手感兴趣,之前我也写了一个简单的,而今天淋漓网络带来一种通过批处理来实现建站助手大部分功能的脚本命令给大家,希望大家在此基础上扩展,利用软件来运行批处理,来实现建站助手的简单开发;

常用调用IIS功能命令:

iisweb /create方面
前言:使用此命令,前首先需要执行的命令:
cd %systemroot%\system32
下面是功能:
建立新站点
iisweb /create C:\MySource “My Site” /d www.linlik.com /80 /dontstart
(其中My Site是新建站点名称,www.linlik.com是主机头,/dontstart是创建站点状态为关闭,80为端口)

adsutil.vbs方面
前言:使用此命令,前首先需要执行的命令:
cd C:\Inetpub\AdminScripts
下面是功能
1、修改默认站点名称
Cscript.exe adsutil.vbs SET w3svc/1/ServerComment “Web Server Number 1″
(修改站点名字其中Web Server Number 1为默认站点名称,1为站点序号)
2、启用IIS站点父路径
cscript adsutil.vbs set w3svc/1/root/AspEnableParentPaths True
(其中True代表开启,false代表关闭,1代表站点序号)
3、设置IIS匿名用户

设置默认站点用户密码例子:
cscript.exe adsutil.vbs set w3svc/anonymoususerpass “password”

设置匿名用户名称:
cscript.exe adsutil.vbs set /w3svc/502540610/root/AnonymousUserName “username”

设置匿名用户密码
cscript.exe adsutil.vbs set /w3svc/502540610/root/AnonymousUserPass “password”

(其中502540610代表站点序号,username代表要设置匿名用户的账号名,password代表密码)
撤销用户访问文件或文件夹
cacls D:\system\client\autohost\wwwroot /t /e /c /r IUSR_AUTOHOST (撤销用户访问命令,其中IUSR_AUTOHOST代表要撤销用户的账号名)

给予文件或文件夹权限
Cacls D:\system\client\autohost\wwwroot /t /e /c /g linli:W (”F”表示完全控制,”C”表示更改,”W”表示写入.”R”表示读取运行,linli代表用户)
强制指定某个文件夹权限
cacls c:\1\1.txt /t /g everyone:r
(不用设置继承权,直接将指定文件设置只允许某个用户访问)

直接忽视y/n的命令
echo y|cacls D:\web\www /p everyone:f
以下是adsutil.vps全部功能
1、匿名访问集成windows验证
cscript adsutil.vbs set W3SVC/99/Root/AuthFlags 5
(5表示允许匿名访问集成)

以下是FTP
cscript adsutil.vbs set /MSFTPSVC/1/root/accesswrite true (设置默认FTP为可写)
cscript adsutil.vbs set MSFTPSVC/1/root/子目录名/accesswrite true (设置默认FTP下的子目录为可写) 查看全部
很多人都对各大IDC网站开发的建站助手感兴趣,之前我也写了一个简单的,而今天淋漓网络带来一种通过批处理来实现建站助手大部分功能的脚本命令给大家,希望大家在此基础上扩展,利用软件来运行批处理,来实现建站助手的简单开发;

常用调用IIS功能命令:

iisweb /create方面
前言:使用此命令,前首先需要执行的命令:
cd %systemroot%\system32
下面是功能:
建立新站点
iisweb /create C:\MySource “My Site” /d www.linlik.com /80 /dontstart
(其中My Site是新建站点名称,www.linlik.com是主机头,/dontstart是创建站点状态为关闭,80为端口)

adsutil.vbs方面
前言:使用此命令,前首先需要执行的命令:
cd C:\Inetpub\AdminScripts
下面是功能
1、修改默认站点名称
Cscript.exe adsutil.vbs SET w3svc/1/ServerComment “Web Server Number 1″
(修改站点名字其中Web Server Number 1为默认站点名称,1为站点序号)
2、启用IIS站点父路径
cscript adsutil.vbs set w3svc/1/root/AspEnableParentPaths True
(其中True代表开启,false代表关闭,1代表站点序号)
3、设置IIS匿名用户

设置默认站点用户密码例子:
cscript.exe adsutil.vbs set w3svc/anonymoususerpass “password”

设置匿名用户名称:
cscript.exe adsutil.vbs set /w3svc/502540610/root/AnonymousUserName “username”

设置匿名用户密码
cscript.exe adsutil.vbs set /w3svc/502540610/root/AnonymousUserPass “password”

(其中502540610代表站点序号,username代表要设置匿名用户的账号名,password代表密码)
撤销用户访问文件或文件夹
cacls D:\system\client\autohost\wwwroot /t /e /c /r IUSR_AUTOHOST (撤销用户访问命令,其中IUSR_AUTOHOST代表要撤销用户的账号名)

给予文件或文件夹权限
Cacls D:\system\client\autohost\wwwroot /t /e /c /g linli:W (”F”表示完全控制,”C”表示更改,”W”表示写入.”R”表示读取运行,linli代表用户)
强制指定某个文件夹权限
cacls c:\1\1.txt /t /g everyone:r
(不用设置继承权,直接将指定文件设置只允许某个用户访问)

直接忽视y/n的命令
echo y|cacls D:\web\www /p everyone:f
以下是adsutil.vps全部功能
1、匿名访问集成windows验证
cscript adsutil.vbs set W3SVC/99/Root/AuthFlags 5
(5表示允许匿名访问集成)

以下是FTP
cscript adsutil.vbs set /MSFTPSVC/1/root/accesswrite true (设置默认FTP为可写)
cscript adsutil.vbs set MSFTPSVC/1/root/子目录名/accesswrite true (设置默认FTP下的子目录为可写)

VMWARE网址

技术文章admin 发表了文章 • 0 个评论 • 18 次浏览 • 2019-03-09 17:25 • 来自相关话题

https://www.ctoclubs.com/2018/ ... .html

CentOS修改主机名

技术文章admin 发表了文章 • 0 个评论 • 20 次浏览 • 2019-02-28 09:36 • 来自相关话题

CentOS 6.5 修改主机名

1、临时修改主机名

# hostname 主机名

# bash

2永久修改主机名

# vim /etc/sysconfig/network




CentOS 7.2 修改主机名

1、临时修改主机名

    hostname 主机名

    

    重新连接shell,就可以,这种方式,只能修改临时的主机名,当重启机器后,主机名称又变回来了。

2、永久修改主机名

    hostnamectl set-hostname <hostname>

    reboot重启系统,重新连接shell,使用这种方式修改,可以永久性的修改主机名称!

      主机名成功修改后,/etc/hostname文件内容更新为最新主机名,但是/etc/hosts文件中主机名不变,需要手工修改 查看全部
CentOS 6.5 修改主机名

1、临时修改主机名

# hostname 主机名

# bash

2永久修改主机名

# vim /etc/sysconfig/network




CentOS 7.2 修改主机名

1、临时修改主机名

    hostname 主机名

    

    重新连接shell,就可以,这种方式,只能修改临时的主机名,当重启机器后,主机名称又变回来了。

2、永久修改主机名

    hostnamectl set-hostname <hostname>

    reboot重启系统,重新连接shell,使用这种方式修改,可以永久性的修改主机名称!

      主机名成功修改后,/etc/hostname文件内容更新为最新主机名,但是/etc/hosts文件中主机名不变,需要手工修改

CENTOS linux修改网卡名为eth0

技术文章admin 发表了文章 • 0 个评论 • 24 次浏览 • 2019-02-27 21:00 • 来自相关话题

linux修改网卡名为eth0
方法1:

1.编辑网卡的配置文件 vi /etc/sysconfig/network-scripts/ifcfg-ens33 将里面的NAME和DEVICE项修改为eth0,ONBOOT修改为yes。

2.重命名网卡配置文件ifcfg-ens33为ifcfg-eth0。

cd /etc/sysconfig/network-scripts/

mv ifcfg-ens33 ifcfg-eth0

3.编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUB_CMDLINE_LINUX变量中。

vi /etc/default/grub

GRUB_CMDLINE_LINUX=“crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet net.ifnames=0 biosdevname=0”

4.运行命令grub2-mkconfig -o /boot/grub2/grub.cfg来重新生成GRUB配置并更新内核参数。

5.reboot。

6.输入ifconfig确认。

方法2: 
(1)编辑/boot/grub2/grub.cfg文件 
GRUB_CMDLINE_LINUX ="rhgb quiet net.ifnames=0" 
(2)重启生效




Linux修改网卡ens33为eth0以及centos7下修改动态IP为静态IP地址
Linux修改网卡ens33为eth0以及centos7下修改动态IP为静态IP地址
上古杰作关注0人评论3639人阅读2018-08-30 17:58:48
修改网卡ens33为eth0
在使用RHEL和Centos7,发现网卡名称变成了EnoX,挺不习惯。现更改回旧名称eth0看着顺眼。

1.备份/etc/sysconfig/grub文件

cp /etc/sysconfig/grub /etc/sysconfig/grub.bak
2.编辑/etc/sysconfig/grub文件

vim /etc/sysconfig/grub
在GRUB_CMDLINE_LINUX后的双引号内添加

net.ifnames=0 biosdevname=0
顺序无所谓,注意各参数间空格。
3.重建GRUB配置文件

grub2-mkconfig -o /boot/grub2/grub.cfg
4.备份网卡配置文件和更改网卡文件为eth0

cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33.bak
mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
ens33可能和各位不一样,具体先ifconfig查看自己的ensx多少。
5.编辑/etc/sysconfig/network-scripts/ifcfg-eth0文件

vim /etc/sysconfig/network-scripts/ifcfg-eth0
把NAME和DEVICE由原来的ens33更改为eth0即可。
6.重启系统即可。

[root@linfan ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:7b:4d:fb brd ff:ff:ff:ff:ff:ff
    inet 192.168.24.148/24 brd 192.168.24.255 scope global dynamic eth0
       valid_lft 1610sec preferred_lft 1610sec
    inet6 fe80::f395:669a:c751:9e90/64 scope link
       valid_lft forever preferred_lft forever
Linux下把动态Ip更改为静态Ip
我需要将ip修改为192.168.24.130

1.查看网关地址,我的是192.168.24.2

[root@linfan ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.24.2    0.0.0.0         UG    100    0        0 eth0
192.168.24.0    0.0.0.0         255.255.255.0   U     100    0        0 eth0
2.查看DNS, 我的是192.168.24.2

[root@linfan ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.24.2
3.配置网卡信息,我的是 vi /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID="e7b272e4-cf09-46cb-8f85-ab6c9c469979"
DEVICE="eth0"
ONBOOT="yes"
修改后为

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO="static"
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DNS1=192.168.24.2
IPADDR=192.168.24.130
NETMASK=255.255.255.0
GATEWAY=192.168.24.2
重启网卡

[root@linfan ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
验证:
ping www.baidu.com

[root@linfan ~]# ping www.baidu.com
PING www.a.shifen.com (119.75.216.20) 56(84) bytes of data.
查看ip


[root@linfan ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.24.130  netmask 255.255.255.0  broadcast 192.168.24.255
        inet6 fe80::f395:669a:c751:9e90  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7b:4d:fb  txqueuelen 1000  (Ethernet)
        RX packets 3607  bytes 327107 (319.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2139  bytes 304955 (297.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 查看全部
linux修改网卡名为eth0
方法1:

1.编辑网卡的配置文件 vi /etc/sysconfig/network-scripts/ifcfg-ens33 将里面的NAME和DEVICE项修改为eth0,ONBOOT修改为yes。

2.重命名网卡配置文件ifcfg-ens33为ifcfg-eth0。

cd /etc/sysconfig/network-scripts/

mv ifcfg-ens33 ifcfg-eth0

3.编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUB_CMDLINE_LINUX变量中。

vi /etc/default/grub

GRUB_CMDLINE_LINUX=“crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet net.ifnames=0 biosdevname=0”

4.运行命令grub2-mkconfig -o /boot/grub2/grub.cfg来重新生成GRUB配置并更新内核参数。

5.reboot。

6.输入ifconfig确认。

方法2: 
(1)编辑/boot/grub2/grub.cfg文件 
GRUB_CMDLINE_LINUX ="rhgb quiet net.ifnames=0" 
(2)重启生效




Linux修改网卡ens33为eth0以及centos7下修改动态IP为静态IP地址
Linux修改网卡ens33为eth0以及centos7下修改动态IP为静态IP地址
上古杰作关注0人评论3639人阅读2018-08-30 17:58:48
修改网卡ens33为eth0
在使用RHEL和Centos7,发现网卡名称变成了EnoX,挺不习惯。现更改回旧名称eth0看着顺眼。

1.备份/etc/sysconfig/grub文件

cp /etc/sysconfig/grub /etc/sysconfig/grub.bak
2.编辑/etc/sysconfig/grub文件

vim /etc/sysconfig/grub
在GRUB_CMDLINE_LINUX后的双引号内添加

net.ifnames=0 biosdevname=0
顺序无所谓,注意各参数间空格。
3.重建GRUB配置文件

grub2-mkconfig -o /boot/grub2/grub.cfg
4.备份网卡配置文件和更改网卡文件为eth0

cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33.bak
mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
ens33可能和各位不一样,具体先ifconfig查看自己的ensx多少。
5.编辑/etc/sysconfig/network-scripts/ifcfg-eth0文件

vim /etc/sysconfig/network-scripts/ifcfg-eth0
把NAME和DEVICE由原来的ens33更改为eth0即可。
6.重启系统即可。

[root@linfan ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:7b:4d:fb brd ff:ff:ff:ff:ff:ff
    inet 192.168.24.148/24 brd 192.168.24.255 scope global dynamic eth0
       valid_lft 1610sec preferred_lft 1610sec
    inet6 fe80::f395:669a:c751:9e90/64 scope link
       valid_lft forever preferred_lft forever
Linux下把动态Ip更改为静态Ip
我需要将ip修改为192.168.24.130

1.查看网关地址,我的是192.168.24.2

[root@linfan ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.24.2    0.0.0.0         UG    100    0        0 eth0
192.168.24.0    0.0.0.0         255.255.255.0   U     100    0        0 eth0
2.查看DNS, 我的是192.168.24.2

[root@linfan ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.24.2
3.配置网卡信息,我的是 vi /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID="e7b272e4-cf09-46cb-8f85-ab6c9c469979"
DEVICE="eth0"
ONBOOT="yes"
修改后为

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO="static"
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DNS1=192.168.24.2
IPADDR=192.168.24.130
NETMASK=255.255.255.0
GATEWAY=192.168.24.2
重启网卡

[root@linfan ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
验证:
ping www.baidu.com

[root@linfan ~]# ping www.baidu.com
PING www.a.shifen.com (119.75.216.20) 56(84) bytes of data.
查看ip


[root@linfan ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.24.130  netmask 255.255.255.0  broadcast 192.168.24.255
        inet6 fe80::f395:669a:c751:9e90  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7b:4d:fb  txqueuelen 1000  (Ethernet)
        RX packets 3607  bytes 327107 (319.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2139  bytes 304955 (297.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Linux文件夹文件创建、删除

技术文章admin 发表了文章 • 0 个评论 • 28 次浏览 • 2019-02-21 09:17 • 来自相关话题

Linux删除文件夹命令

     linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可。
直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字

 

 

 

删除目录、文件 rm(remove)

功能说明:删除文件或目录。
语  法:rm [-dfirv][--help][--version][文件或目录...]
补充说明:执行rm指令可删除文件或目录,如欲删除目录必须加上参数”-r”,否则预设仅会删除文件。 
参  数:
-d或–directory  直接把欲删除的目录的硬连接数据删成0,删除该目录。 
-f或–force  强制删除文件或目录。 
-i或–interactive  删除既有文件或目录之前先询问用户。 
-r或-R或–recursive  递归处理,将指定目录下的所有文件及子目录一并处理。 
-v或–verbose  显示指令执行过程。 

 


1 删除文件夹
de>rm -rf  fileNamede>

 

-删除文件夹实例:
rm -rf /var/log/httpd/access

将会删除/var/log/httpd/access目录以及其下所有文件、文件夹
需要提醒的是:使用这个rm -rf的时候一定要格外小心,linux没有回收站的

2 删除文件
de>rm -f  fileNamede>
使用 rm -rf 的时候一定要格外小心,linux没有回收站的

 

Linux添加文件命令

 

创建目录:mkdir(make directories)

功能说明:建立目录 
语  法:mkdir [-p][--help][--version][-m <目录属性>][目录名称]
补充说明:mkdir可建立目录并同时设置目录的权限。
参  数:
  -m<目录属性>或–mode<目录属性>   建立目录时同时设置目录的权限。
  -p或–parents   若所要建立目录的上层目录目前尚未建立,则会一并建立上层目录。
例:mkdir  test
创建文件 touch

功能说明:改变文件或目录时间。
语  法:touch [-acfm][-d <日期时间>][-r <参考文件或目 录>][-t <日期时间>] [--help]   [--version][文件或目录...] 或 touch [-acfm][--help][--version][日期时 间][文件或目录...] 
补充说明:使用touch指令可更改文件或目录的日期时间,包括存取时间和更改时间。
参  数:
-a或–time=atime或–time=access或–time=use  只更改存取时间。 
-c或–no-create  不建立任何文件。 
-d<时间日期>  使用指定的日期时间,而非现在的时间。 
-f  此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。 
-m或–time=mtime或–time=modify  只更改变动时间。 
-r<参考文件或目录>  把指定文件或目录的日期时间,统统设成和参考文件或目录的日期时间相同。 
-t<日期时间>  使用指定的日期时间,而非现在的时间。
例:touch test.txt (注:Linux下没有文件后缀名区分文件类型之说,系统文件类型只有可执行文件和不可执行文件) 查看全部


Linux删除文件夹命令

     linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可。
直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字

 

 

 

删除目录、文件 rm(remove)

功能说明:删除文件或目录。
语  法:rm [-dfirv][--help][--version][文件或目录...]
补充说明:执行rm指令可删除文件或目录,如欲删除目录必须加上参数”-r”,否则预设仅会删除文件。 
参  数:
-d或–directory  直接把欲删除的目录的硬连接数据删成0,删除该目录。 
-f或–force  强制删除文件或目录。 
-i或–interactive  删除既有文件或目录之前先询问用户。 
-r或-R或–recursive  递归处理,将指定目录下的所有文件及子目录一并处理。 
-v或–verbose  显示指令执行过程。 

 


1 删除文件夹
de>rm -rf  fileNamede>

 

-删除文件夹实例:
rm -rf /var/log/httpd/access

将会删除/var/log/httpd/access目录以及其下所有文件、文件夹
需要提醒的是:使用这个rm -rf的时候一定要格外小心,linux没有回收站的

2 删除文件
de>rm -f  fileNamede>
使用 rm -rf 的时候一定要格外小心,linux没有回收站的

 

Linux添加文件命令

 

创建目录:mkdir(make directories)

功能说明:建立目录 
语  法:mkdir [-p][--help][--version][-m <目录属性>][目录名称]
补充说明:mkdir可建立目录并同时设置目录的权限。
参  数:
  -m<目录属性>或–mode<目录属性>   建立目录时同时设置目录的权限。
  -p或–parents   若所要建立目录的上层目录目前尚未建立,则会一并建立上层目录。
例:mkdir  test
创建文件 touch

功能说明:改变文件或目录时间。
语  法:touch [-acfm][-d <日期时间>][-r <参考文件或目 录>][-t <日期时间>] [--help]   [--version][文件或目录...] 或 touch [-acfm][--help][--version][日期时 间][文件或目录...] 
补充说明:使用touch指令可更改文件或目录的日期时间,包括存取时间和更改时间。
参  数:
-a或–time=atime或–time=access或–time=use  只更改存取时间。 
-c或–no-create  不建立任何文件。 
-d<时间日期>  使用指定的日期时间,而非现在的时间。 
-f  此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容性问题。 
-m或–time=mtime或–time=modify  只更改变动时间。 
-r<参考文件或目录>  把指定文件或目录的日期时间,统统设成和参考文件或目录的日期时间相同。 
-t<日期时间>  使用指定的日期时间,而非现在的时间。
例:touch test.txt (注:Linux下没有文件后缀名区分文件类型之说,系统文件类型只有可执行文件和不可执行文件)

ORACLE 表空间

技术文章admin 发表了文章 • 0 个评论 • 31 次浏览 • 2019-02-21 08:50 • 来自相关话题

--修改表空间自动增长 每次50M 最大32G
ALTER DATABASE DATAFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DB'  
AUTOEXTEND ON NEXT 50M MAXSIZE 34359721984;  


--修改表空间 增加表空间文件
ALTER TABLESPACE USERS ADD DATAFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS03.DB' size 1000M;增加表空间



--查询表空间使用大小

select owner,tablespace_name ,round(sum(BYTES)/1024/1024,2) "USED(M)"

FROM DBA_SEGMENTS

GROUP BY owner,tablespace_name

ORDER BY SUM(BYTES) desc;

SELECT * FROM DBA_TABLESPACES -- 记录各个表空间的详细信息
SELECT * FROM DBA_TABLESPACE_USAGE_METRICS -- 记录各个表空间的使用状况
SELECT * FROM DBA_DATA_FILES -- 记录各个数据文件的详细信息
SELECT * FROM DBA_SEGMENTS -- 记录各个段的详细信息,与 DBA_TABLES,DBA_INDEXES,DBA_LOBS,DBA_PART_TABLES,DBA_PART_INDEXES,DBA_PART_LOBS,DBA_OBJECTS 搭配使用
SELECT * FROM DBA_LOBS    --BLOB 字段所对应的字段名称
SELECT * FROM DBA_INDEXES -- 分区索引需要通过 DBA_INDEXS 来找到对应的表名
SELECT * FROM DBA_EXTENTS -- 记录各个区间对象的详细信息 


--查询表空间 名称 表空间文件  是否自动增长  现在大小,最大的大小
SELECT T.TABLESPACE_NAME,D.FILE_NAME,     
D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS     
FROM DBA_TABLESPACES T,DBA_DATA_FILES D     
WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME     
 ORDER BY TABLESPACE_NAME,FILE_NAME;  
 
 
 
 select a.FILE_NAME,a.AUTOEXTENSIBLE,a.MAXBYTES,a.INCREMENT_BY  from  dba_data_files a;
 
 
SELECT UPPER(F.TABLESPACE_NAME) "表空间名",     
D.TOT_GROOTTE_MB "表空间大小(M)",     
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",     
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "使用比",     
F.TOTAL_BYTES "空闲空间(M)",     
F.MAX_BYTES "最大块(M)"    
FROM (SELECT TABLESPACE_NAME,     
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,     
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES     
FROM SYS.DBA_FREE_SPACE     
GROUP BY TABLESPACE_NAME) F,     
(SELECT DD.TABLESPACE_NAME,     
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB     
FROM SYS.DBA_DATA_FILES DD     
GROUP BY DD.TABLESPACE_NAME) D     
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME     
ORDER BY 4 DESC; 
 
 
select a.tablespace_name as "表空间名",
       a.bytes / 1024 / 1024 as "表空间大小(M)",
       (a.bytes - b.bytes) / 1024 / 1024 as "已使用空间(M)",
       b.bytes / 1024 / 1024 "空闲空间(M)",
       round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "使用比"
  from (select tablespace_name, sum(bytes) bytes
          from dba_data_files
         group by tablespace_name) a,
       (select tablespace_name, sum(bytes) bytes, max(bytes) largest
          from dba_free_space
         group by tablespace_name) b
 where a.tablespace_name = b.tablespace_name 查看全部

--修改表空间自动增长 每次50M 最大32G
ALTER DATABASE DATAFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DB'  
AUTOEXTEND ON NEXT 50M MAXSIZE 34359721984;  


--修改表空间 增加表空间文件
ALTER TABLESPACE USERS ADD DATAFILE 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS03.DB' size 1000M;增加表空间



--查询表空间使用大小

select owner,tablespace_name ,round(sum(BYTES)/1024/1024,2) "USED(M)"

FROM DBA_SEGMENTS

GROUP BY owner,tablespace_name

ORDER BY SUM(BYTES) desc;

SELECT * FROM DBA_TABLESPACES -- 记录各个表空间的详细信息
SELECT * FROM DBA_TABLESPACE_USAGE_METRICS -- 记录各个表空间的使用状况
SELECT * FROM DBA_DATA_FILES -- 记录各个数据文件的详细信息
SELECT * FROM DBA_SEGMENTS -- 记录各个段的详细信息,与 DBA_TABLES,DBA_INDEXES,DBA_LOBS,DBA_PART_TABLES,DBA_PART_INDEXES,DBA_PART_LOBS,DBA_OBJECTS 搭配使用
SELECT * FROM DBA_LOBS    --BLOB 字段所对应的字段名称
SELECT * FROM DBA_INDEXES -- 分区索引需要通过 DBA_INDEXS 来找到对应的表名
SELECT * FROM DBA_EXTENTS -- 记录各个区间对象的详细信息 


--查询表空间 名称 表空间文件  是否自动增长  现在大小,最大的大小
SELECT T.TABLESPACE_NAME,D.FILE_NAME,     
D.AUTOEXTENSIBLE,D.BYTES,D.MAXBYTES,D.STATUS     
FROM DBA_TABLESPACES T,DBA_DATA_FILES D     
WHERE T.TABLESPACE_NAME =D.TABLESPACE_NAME     
 ORDER BY TABLESPACE_NAME,FILE_NAME;  
 
 
 
 select a.FILE_NAME,a.AUTOEXTENSIBLE,a.MAXBYTES,a.INCREMENT_BY  from  dba_data_files a;
 
 
SELECT UPPER(F.TABLESPACE_NAME) "表空间名",     
D.TOT_GROOTTE_MB "表空间大小(M)",     
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",     
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') "使用比",     
F.TOTAL_BYTES "空闲空间(M)",     
F.MAX_BYTES "最大块(M)"    
FROM (SELECT TABLESPACE_NAME,     
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,     
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES     
FROM SYS.DBA_FREE_SPACE     
GROUP BY TABLESPACE_NAME) F,     
(SELECT DD.TABLESPACE_NAME,     
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB     
FROM SYS.DBA_DATA_FILES DD     
GROUP BY DD.TABLESPACE_NAME) D     
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME     
ORDER BY 4 DESC; 
 
 
select a.tablespace_name as "表空间名",
       a.bytes / 1024 / 1024 as "表空间大小(M)",
       (a.bytes - b.bytes) / 1024 / 1024 as "已使用空间(M)",
       b.bytes / 1024 / 1024 "空闲空间(M)",
       round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "使用比"
  from (select tablespace_name, sum(bytes) bytes
          from dba_data_files
         group by tablespace_name) a,
       (select tablespace_name, sum(bytes) bytes, max(bytes) largest
          from dba_free_space
         group by tablespace_name) b
 where a.tablespace_name = b.tablespace_name

CENTOS 7.4 LINUX SMB 共享的创建

技术文章admin 发表了文章 • 0 个评论 • 35 次浏览 • 2019-02-20 20:05 • 来自相关话题

首先我将解释安装Samba和匿名共享的方法。安装Samba运行yum install samba samba-client samba-common
安装之后请备份一份原始的Samba配置文件:mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
 
然后来新建我们的conf文件:vi /etc/samba/smb.conf 
[安装之后请备份一份原始的Samba配置文件:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
然后来新建我们的conf文件:

vi /etc/samba/smb.conf

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[Anonymous]
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no

:wq#保存并退出
mkdir -p /samba/anonymous
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service
在下面CentOs7的防火墙cmd会阻止Samba的访问,为了摆脱这个,我们运行:

[root@server1 ~]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@server1 ~]#
[root@server1 ~]# firewall-cmd --reload
success
[root@server1 ~]#
现在你可以在Windows中访问CentOS7的共享文件了,在命令提示行中输入:

\\centos
 
 [root@localhost media]# systemctl restart nmb.service
[root@localhost media]# systemctl restart smb.service

[root@localhost ~]# chmod -R 755 /media/share
[root@localhost ~]# reboot
Last login: Wed Feb 20 15:44:59 2019 from 100.101.100.27
[root@localhost ~]# groupadd smbgrp
[root@localhost ~]# useradd srijan -G smbgrp
[root@localhost ~]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Added user srijan.
[root@localhost ~]# mkdir -p /media/secured
[root@localhost ~]# cd /media
[root@localhost media]# ls
secured  share
[root@localhost media]# chmod -R 0777 secured/
[root@localhost media]# chcon -t samba_share_t secured/
[root@localhost media]# vi /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 = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[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]
        path=/media/share
        public = yes
        writable = yes
        valid users = sxs
        create mask =0644
        force create mask =0644
        directory mask = 0755
        force directory mask = 0755
        available = yes
[secured]
        path = /media/secured
        valid users = @smbgrp
        guest ok = no
        writable = yes
        browsable = yes
~
"/etc/samba/smb.conf" 53L, 999C written
[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service
[root@localhost media]# cd /media
[root@localhost media]# chown -R srijan:smbgrp secured/
[root@localhost media]# reboot
Last login: Wed Feb 20 16:40:13 2019 from 100.101.100.27
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp
[root@localhost ~]# vi /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 = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[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]
        path=/media/share
        public = yes
        writable = yes
        valid users = sxs
        create  mask  =0644
        force create mask  =0644
        directory mask = 0755
        force directory mask = 0755
        available = yes
[secured]
        path = /media/secured
        valid users = @smbgrp
        guest ok = no
        writable = yes
        browsable = yes
"/etc/samba/smb.conf" 53L, 1002C written
[root@localhost ~]# mkdir -p /samba/anonymous
[root@localhost ~]# systemctl restart smb.service
[root@localhost ~]# systemctl restart nmb.service
[root@localhost ~]# cd /samba
[root@localhost samba]# chmod -R 0755 anonymous/
[root@localhost samba]# chown -R nobody:nobody anonymous/
[root@localhost samba]# ls -l anonymous/
婊绋?0
[root@localhost samba]# chcon -t samba_share_t anonymous/
[root@localhost samba]# cd ..
[root@localhost /]# cd
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp


[Anonymous]
    guest ok = Yes
    path = /samba/anonymous
    read only = No
[root@localhost ~]# cd /samba
[root@localhost samba]# ls -l anonymous/
婊绋?0
[root@localhost samba]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Mismatch - password unchanged.
Unable to get new password.
[root@localhost samba]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
[root@localhost samba]# chown -R srijan:smbgrp secured/
chown: 鏍娉璁块?secured/": 娌℃椋涓浠舵珏?
[root@localhost samba]# cd ..
[root@localhost /]# cd media
[root@localhost media]# chown -R srijan:smbgrp secured/
[root@localhost media]# chcon -t samba_share_t secured/
[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service
[root@localhost media]# ^C
[root@localhost media]# chcon -t samba_share_t share/
[root@localhost media]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions
 
# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp


[Anonymous]
    guest ok = Yes
    path = /samba/anonymous
    read only = No

[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service 查看全部

首先我将解释安装Samba和匿名共享的方法。安装Samba运行yum install samba samba-client samba-common
安装之后请备份一份原始的Samba配置文件:mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
 
然后来新建我们的conf文件:vi /etc/samba/smb.conf 
[安装之后请备份一份原始的Samba配置文件:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
然后来新建我们的conf文件:

vi /etc/samba/smb.conf

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[Anonymous]
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no

:wq#保存并退出
mkdir -p /samba/anonymous
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service
在下面CentOs7的防火墙cmd会阻止Samba的访问,为了摆脱这个,我们运行:

[root@server1 ~]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@server1 ~]#
[root@server1 ~]# firewall-cmd --reload
success
[root@server1 ~]#
现在你可以在Windows中访问CentOS7的共享文件了,在命令提示行中输入:

\\centos
 
 [root@localhost media]# systemctl restart nmb.service
[root@localhost media]# systemctl restart smb.service

[root@localhost ~]# chmod -R 755 /media/share
[root@localhost ~]# reboot
Last login: Wed Feb 20 15:44:59 2019 from 100.101.100.27
[root@localhost ~]# groupadd smbgrp
[root@localhost ~]# useradd srijan -G smbgrp
[root@localhost ~]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Added user srijan.
[root@localhost ~]# mkdir -p /media/secured
[root@localhost ~]# cd /media
[root@localhost media]# ls
secured  share
[root@localhost media]# chmod -R 0777 secured/
[root@localhost media]# chcon -t samba_share_t secured/
[root@localhost media]# vi /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 = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[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]
        path=/media/share
        public = yes
        writable = yes
        valid users = sxs
        create mask =0644
        force create mask =0644
        directory mask = 0755
        force directory mask = 0755
        available = yes
[secured]
        path = /media/secured
        valid users = @smbgrp
        guest ok = no
        writable = yes
        browsable = yes
~
"/etc/samba/smb.conf" 53L, 999C written
[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service
[root@localhost media]# cd /media
[root@localhost media]# chown -R srijan:smbgrp secured/
[root@localhost media]# reboot
Last login: Wed Feb 20 16:40:13 2019 from 100.101.100.27
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp
[root@localhost ~]# vi /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 = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[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]
        path=/media/share
        public = yes
        writable = yes
        valid users = sxs
        create  mask  =0644
        force create mask  =0644
        directory mask = 0755
        force directory mask = 0755
        available = yes
[secured]
        path = /media/secured
        valid users = @smbgrp
        guest ok = no
        writable = yes
        browsable = yes
"/etc/samba/smb.conf" 53L, 1002C written
[root@localhost ~]# mkdir -p /samba/anonymous
[root@localhost ~]# systemctl restart smb.service
[root@localhost ~]# systemctl restart nmb.service
[root@localhost ~]# cd /samba
[root@localhost samba]# chmod -R 0755 anonymous/
[root@localhost samba]# chown -R nobody:nobody anonymous/
[root@localhost samba]# ls -l anonymous/
婊绋?0
[root@localhost samba]# chcon -t samba_share_t anonymous/
[root@localhost samba]# cd ..
[root@localhost /]# cd
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp


[Anonymous]
    guest ok = Yes
    path = /samba/anonymous
    read only = No
[root@localhost ~]# cd /samba
[root@localhost samba]# ls -l anonymous/
婊绋?0
[root@localhost samba]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Mismatch - password unchanged.
Unable to get new password.
[root@localhost samba]# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
[root@localhost samba]# chown -R srijan:smbgrp secured/
chown: 鏍娉璁块?secured/": 娌℃椋涓浠舵珏?
[root@localhost samba]# cd ..
[root@localhost /]# cd media
[root@localhost media]# chown -R srijan:smbgrp secured/
[root@localhost media]# chcon -t samba_share_t secured/
[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service
[root@localhost media]# ^C
[root@localhost media]# chcon -t samba_share_t share/
[root@localhost media]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[share]"
Unknown parameter encountered: "force create mask"
Ignoring unknown parameter "force create mask"
Unknown parameter encountered: "force directory mask"
Ignoring unknown parameter "force directory mask"
Processing section "[secured]"
Processing section "[Anonymous]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions
 
# Global parameters
[global]
    printcap name = cups
    security = USER
    workgroup = SAMBA
    idmap config * : backend = tdb
    cups options = raw


[homes]
    browseable = No
    comment = Home Directories
    inherit acls = Yes
    read only = No
    valid users = %S %D%w%S


[printers]
    browseable = No
    comment = All Printers
    create mask = 0600
    path = /var/tmp
    printable = Yes


[print$]
    comment = Printer Drivers
    create mask = 0664
    directory mask = 0775
    force group = @printadmin
    path = /var/lib/samba/drivers
    write list = @printadmin root


[share]
    create mask = 0644
    guest ok = Yes
    path = /media/share
    read only = No
    valid users = sxs


[secured]
    path = /media/secured
    read only = No
    valid users = @smbgrp


[Anonymous]
    guest ok = Yes
    path = /samba/anonymous
    read only = No

[root@localhost media]# systemctl restart smb.service
[root@localhost media]# systemctl restart nmb.service

Linux下搭建SMB文件共享服务,Linux/Windows互联互通

技术文章admin 发表了文章 • 0 个评论 • 39 次浏览 • 2019-02-20 14:15 • 来自相关话题

2018-01-26 16:25:35
一丶简介:
SMB协议是建立在NetBIOS协议之上的应用协议,是基于TCP138、139两个端口的服务,NetBIOS出现之后,Microsoft就使用NetBIOS实现了一个网络文件/打印服务系统。这个系统基于NetBIOS设定了一套文件共享协议,Microsoft称之为SMB(Server Message Block) 协议,这个协议被用于Lan Manager和Windows服务器系统中,实现不同计算机之间共享 打印机和文件等。因此,为了让Windows和Unix/Linux计算机相集成,最好的办法就是在 Unix/Linux计算机中安装支持SMB协议的软件。这样使用Windows的客户端不需要更改设置, 就能像使用Windows NT或Windows 2000服务器一样,使用Unix/Linux计算机上的共享资源了。

Samba使SMB协议运行在NetBIOS协议上,并且使用Windows的 NetBEUI协议让Unix/Linux服务器 可以在Windows的网络邻居上被访问到。

     Samba的守护进程
smbd 监听139 TCP端口 设置共享目录、打印等
nmbd 137. 138 UDP端口 管理群组、NetBIOS 等解析工作
二丶实验拓扑

1.SMB服务器:192.168.1.1 Linux1
2.SMB客户端:192.168.1.2 Linux2
3.SMB客户端:192.168.1.3 Windows

服务器上部署:

关闭IPtables,保证互联互通

知识点,samba 有四种安全级别,它们分别是:

share:用户不需要用户名和就可登陆samba 服务器

user:用户需要输入用户名和密码才可以登陆samba服务器

server:请自行查资料,不常用,略

domain:请自行查资料,不常用,略

[root@192.168.1.1 ~]# yum -y install samba
[root@192.168.1.1 ~]# vim /etc/samba/smb.conf

查找[Global]区域下 workgroup = WORKGROUP 修改为Windows下组名称
security = user

下面自行添加一个区域

[share] 共享名称
comment = sxs share 描述信息
path = /media/share 共享路径
guest ok = no 是否允许guest访问
browseable = yes 是否显示共享目录
writable = yes 是否允许写入
write list = sxs 允许写入的用户 ,@为组

可选项
//host allow = 192.168.80. 192.168.70. //允许访问服务器的主机

//client code page = 939 //支持简体中文共享名

ok,设置完成

[root@192.168.1.1 ~]# mkdir /media/share
[root@192.168.1.1 ~]# useradd sxs
[root@192.168.1.1 ~]# chmod 755 /media/share
[root@192.168.1.1 ~]# chown sxs.sxs /media/share
[root@192.168.1.1 ~]# smbpasswd -a sxs
输入两次密码
[root@192.168.1.1 ~]# /etc/init.d/smb start 启动相关服务
[root@192.168.1.1 ~]# /etc/init.d/nmb start

由于selinux问题导致即使文件中允许了访问,也无法实现实验的目的

解决办法:关闭selinux
[root@192.168.1.1 ~]# setenforce 0 临时关闭方法

另一解决办法:开发selinux中关于开放samba的相关服务

[root@192.168.1.1 ~]# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off

[root@192.168.1.1 ~]# 
#setsebool –P samba_enable_home_dir on

#setsebool –P samba_export_all_ro on

#setsebool –P samba_export_all_rw on

接下来Windows上面测试输入:\192.168.1.1\share 测试进入该共享目录,及写入无问题

Linux上面再测试一下

[root@192.168.1.2 ~]# yum -y install samba-client
[root@192.168.1.2 ~]# smbclient //192.168.1.1/share -U sxs
Enter sxs's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6]
smb: \>

OK,完成。 查看全部
2018-01-26 16:25:35
一丶简介:
SMB协议是建立在NetBIOS协议之上的应用协议,是基于TCP138、139两个端口的服务,NetBIOS出现之后,Microsoft就使用NetBIOS实现了一个网络文件/打印服务系统。这个系统基于NetBIOS设定了一套文件共享协议,Microsoft称之为SMB(Server Message Block) 协议,这个协议被用于Lan Manager和Windows服务器系统中,实现不同计算机之间共享 打印机和文件等。因此,为了让Windows和Unix/Linux计算机相集成,最好的办法就是在 Unix/Linux计算机中安装支持SMB协议的软件。这样使用Windows的客户端不需要更改设置, 就能像使用Windows NT或Windows 2000服务器一样,使用Unix/Linux计算机上的共享资源了。

Samba使SMB协议运行在NetBIOS协议上,并且使用Windows的 NetBEUI协议让Unix/Linux服务器 可以在Windows的网络邻居上被访问到。

     Samba的守护进程
smbd 监听139 TCP端口 设置共享目录、打印等
nmbd 137. 138 UDP端口 管理群组、NetBIOS 等解析工作
二丶实验拓扑

1.SMB服务器:192.168.1.1 Linux1
2.SMB客户端:192.168.1.2 Linux2
3.SMB客户端:192.168.1.3 Windows

服务器上部署:

关闭IPtables,保证互联互通

知识点,samba 有四种安全级别,它们分别是:

share:用户不需要用户名和就可登陆samba 服务器

user:用户需要输入用户名和密码才可以登陆samba服务器

server:请自行查资料,不常用,略

domain:请自行查资料,不常用,略

[root@192.168.1.1 ~]# yum -y install samba
[root@192.168.1.1 ~]# vim /etc/samba/smb.conf

查找[Global]区域下 workgroup = WORKGROUP 修改为Windows下组名称
security = user

下面自行添加一个区域

[share] 共享名称
comment = sxs share 描述信息
path = /media/share 共享路径
guest ok = no 是否允许guest访问
browseable = yes 是否显示共享目录
writable = yes 是否允许写入
write list = sxs 允许写入的用户 ,@为组

可选项
//host allow = 192.168.80. 192.168.70. //允许访问服务器的主机

//client code page = 939 //支持简体中文共享名

ok,设置完成

[root@192.168.1.1 ~]# mkdir /media/share
[root@192.168.1.1 ~]# useradd sxs
[root@192.168.1.1 ~]# chmod 755 /media/share
[root@192.168.1.1 ~]# chown sxs.sxs /media/share
[root@192.168.1.1 ~]# smbpasswd -a sxs
输入两次密码
[root@192.168.1.1 ~]# /etc/init.d/smb start 启动相关服务
[root@192.168.1.1 ~]# /etc/init.d/nmb start

由于selinux问题导致即使文件中允许了访问,也无法实现实验的目的

解决办法:关闭selinux
[root@192.168.1.1 ~]# setenforce 0 临时关闭方法

另一解决办法:开发selinux中关于开放samba的相关服务

[root@192.168.1.1 ~]# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off

[root@192.168.1.1 ~]# 
#setsebool –P samba_enable_home_dir on

#setsebool –P samba_export_all_ro on

#setsebool –P samba_export_all_rw on

接下来Windows上面测试输入:\192.168.1.1\share 测试进入该共享目录,及写入无问题

Linux上面再测试一下

[root@192.168.1.2 ~]# yum -y install samba-client
[root@192.168.1.2 ~]# smbclient //192.168.1.1/share -U sxs
Enter sxs's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6]
smb: \>

OK,完成。