普通用户su 到root,无需密码方式,及iptables封掉本机某个端口,core文件配置

一. 普通用户su到root无需密码:

随着服务器越来越多,普通用户转到root下,去查密码表是个很繁琐的事,发现有如下方式比较方便(需要root操作)

vi /etc/pam.d/su
 将 auth这一列的注释号 去除
# Uncomment the following line to implicitly trust users in the "wheel" group.
auth            sufficient      pam_wheel.so trust use_uid

然后将登陆用户加入 wheel组
usermod -G wheel $username (gpasswd -a $username wheel)

这样从$username su 到root就无需密码了。

将某个用户从wheel组中删除:gpasswd -d $username wheel

二. iptables封掉本机某个端口:

查看本机iptables设置情况: iptables -L -n

封掉本机(本机ip:hostname -i获取,假设本机ip为:192.168.68.32)8888端口input: iptables -A INPUT -d 192.168.68.32 -p tcp --dport 8888 -j DROP

封掉本机(本机ip:hostname -i获取,假设本机ip为:192.168.68.32)8888端口output: iptables -A OUTPUT -d 192.168.68.32 -p tcp --dport 8888 -j DROP

清除预设表filter中的所有规则链的规则: iptables -F

清除预设表filter中使用者自定链中的规则: iptables -X

相关链接

三. core文件配置:

1.core文件的生成开关和大小限制
---------------------------------
 1
) 使用ulimit -c命令可查看core文件的生成开关。若结果为0,则表示关闭了此功能,不会生成core文件。
 2
) 使用ulimit -cfilesize命令,可以限制core文件的大小(filesize的单位为kbyte)。ulimit -cunlimited,则表示core文件的大小不受限制。如果生成的信息超过此大小,将会被裁剪,最终生成一个不完整的core文件。在调试此 core文件的时候,gdb会提示错误。

在用户的~/.bash_profile里加上ulimit -c unlimited来让特定的用户能产生core文件,而ulimit -c 1024 可以设置core文件大小

2.core文件的名称和生成路径
----------------------------
若系统生成的core文件不带其它任何扩展名称,则全部命名为core。新的core文件生成将覆盖原来的core文件。
1
/proc/sys/kernel/core_uses_pid可以控制core文件的文件名中是否添加pid作为扩展。文件内容为1,表示添加pid作为扩展名,生成的core文件格式为core.xxxx;为0则表示生成的core文件同一命名为core
可通过以下命令修改此文件:
echo "1" > /proc/sys/kernel/core_uses_pid
2
proc/sys/kernel/core_pattern可以控制core文件保存位置和文件名格式
可通过以下命令修改此文件:
echo "/corefile/core-%e-%p-%t" > core_pattern
,可以将core文件统一生成到/corefile目录下,产生的文件名为core-命令名-pid-时间戳
以下是参数列表:
    %p - insert pid into filename 
添加pid
    %u - insert current uid into filename 
添加当前uid
    %g - insert current gid into filename 
添加当前gid
    %s - insert signal that caused the coredump into the filename 
添加导致产生core的信号
    %t - insert UNIX time that the coredump occurred into filename 
添加core文件生成时的unix时间
    %h - insert hostname where the coredump happened into filename 
添加主机名
    %e - insert coredumping executable name into filename 
添加命令名

相关链接

 

原文地址:https://www.cnblogs.com/276815076/p/3468922.html