Skip to content

Instantly share code, notes, and snippets.

View skylens's full-sized avatar
🎯
Focusing

skylens

🎯
Focusing
View GitHub Profile
@skylens
skylens / 禁止ping.md
Last active December 6, 2018 16:11
禁止ping

CentOS 下禁 ping

修改内核参数实现

  • 临时生效
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all 

iptables 白名单

iptables -vL
iptables -A INPUT -p tcp --dport 22 -s 192.168.149.1 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -s 10.181.242.242 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -s 10.180.221.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j DROP
service iptables save
service iptables restart

yum groups remove 'Server with GUI' 报错

yum groupremove 'X Window System' 'GNOME' 'Guest Desktop Agents'

CentOS 安装完后的需要安装的软件

CentOS 6

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm -y
yum makecache all
yum update -y
yum install net-tools bind-utils vim nano unzip zip xz wget ftp tmux lrzsz git htop lsof -y

编译安装 nmon

CentOS 下编译安装

yum install git ncurses-devel ncurses -y
yum groups install 'Development Tools'
cd nmon/
./build.sh

Linux 下进程相关操作

查看进程号,进程名为 'name'

ps -ef | grep "name" | grep -v grep | awk '{print $2}'

ps -ef | awk '/[n]ame/{print $2}'

ps x | awk '/[n]ame/{print $1}'

selinux 开启关闭

网上找到的脚本

#!/bin/bash  
#  -------------+--------------------   
# * Filename    :       selinux.sh           
# * Revision    :       2.0             
# * Date        :       2017-09-02

CentOS 7 安装 iptables

停用 firewalld 服务

systemctl stop firewalld
systemctl disable firewalld
systemctl mask firewalld

CentOS 6 上编译安装 openssh 7.9p1

准备

yum groupinstall 'Development Tools' -y
yum install wget vim nano mosh -y

下载对应的软件包

列出当前路径下最占用磁盘空间的前十个文件

du -a | sort -n -r | head -n 10

du - 计算目录的磁盘空间占用的大小,及文件大小 sort - 排序 head - 取出多少行