Linux学习笔记
开启服务的命令
chkconfig
--list [servicename] 查看服务的状态
[root@station90 ~]# chkconfig --list cups
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果不加服务名则显示所有服务。
--level
表示启动级别共有[0-6]
[root@station90 xinetd.d]# chkconfig --level 24 cups off
[root@station90 xinetd.d]# chkconfig --list cups
cups 0:off 1:off 2:off 3:on 4:off 5:on 6:off
还有一些其他的用法需要注意
如果这个进程是独立守护进程我们可以向上面那样应用,但如果是非独立守护进程即在xinetd下面的进程则不可以这样应用
应该直接应用
chkconfig 进程名 on|off
比如
chkconfig tftp on
要想立即应用这个服务则必须这样
service xinetd restart
那么接着我们看一下 xinetd 下的默认控制规则
/etc/xinetd.conf
不过要先装这个服务这里不再赘述。
defaults
{
enabled =yes
允许用户使用这个服务
disabled =yes
拒绝用户使用这个服务
如果两者都是yes则是拒绝优先
log_type = SYSLOG daemon info
指日志类型和级别info指级别
log_on_failure = HOST
当远程客户端登录失败则记录其IP
log_on_success = PID HOST DURATION EXIT
用户成功登陆则记录为PID HOST DURACTION EXIT
no_access =22:24 00:06
这里指不允许被访问的时间是24小时制
only_from = 192.168.0.0/24
只允许被访问的网段或者网络地址
max_load = 0
可以最大下载数
cps = 50 10
指单位时间内有可有50个线程,如果超过则会暂停10秒
instances = 50
允许最多的并发访问量为50
per_source = 10
允许单个用户最多可以访问10个线程。
}
当然在单个服务中还有很多选项
比如/etc/xinetd.d/tftp文件中的内容
service tftp
{
disable = no
socket_type = dgram
在UDP中是以数据包定义的
protocol = udp
wait = yes
一般情况下UDP为YES而TCP为NO
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
接下来看一下tcp_wrappers的配置
只要被xinetd进程连接到libwrap.so 因此其下的服务受其影响而可以做tcp_wrappers
还有一些独立的守护进程比如
sendmail slapd sshd gdm vsftp portmap 等都可以做tcp_wrappers的配置
好我们做几个例子
配置文件在/etc/hosts.allow
/etc/hosts.deny
执行顺序是tcpd hosts.allow hosts.deny
例一 :
编辑/etc/hosts.allow
in.telnetd: 192.168.0.0/255.255.255.0 EXCEPT 192.168.0.39
编辑/etc/hosts.deny
in.telnetd: ALL
例二
编辑/etc/hosts.allow
in.telnetd: 192.168.0.0/255.255.255.0 : spawn /bin/echo `date` "from %c to %s" |mail -s "DD" root
编辑/etc/hosts.deny
in.telnetd: ALL
例三
编辑/etc/hosts.allow
in.telnetd: 192.168.0.0/255.255.255.0 : spawn /bin/echo `date` "from %c to %s" >> /var/log/telnet.log
编辑/etc/hosts.deny
in.telnetd: ALL
接下来学一下selinux
getsebool -a
可以查看文件是否启用了selinux
setsebool 标签=on|off
我们查看标签
ls -Zd file|directory
ps –Zc program
我们开启selinux
查看其选项
#getenfore
我们改变它通过0或者1,这里是布尔值
#getengorce 0