vault backup: 2025-12-04 09:12:56

This commit is contained in:
杜鹏飞
2025-12-04 09:12:56 +08:00
commit 71e83861de
300 changed files with 339584 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
>https://www.cnblogs.com/liujunqiao/p/10719942.html
* yum -y install epel-release
```#epel库里就有fail2ban 直接安装epel库就可以使用```
* yum -y install fail2ban
```#安装fail2ban```
* systemctl enable fail2ban
* cd /etc/fail2ban
* cp jail.conf jail.local
> 可以删除所有配置,配置以下内容
```
[sshd-iptables]
enabled = true
port = 22922
filter = sshd
# 过滤参数对应filter.d 目录下的动作
action = iptables[name=SSH, port=22922, protocol=tcp]
# 动作参数 对应actioin.d目录下的动作当前使用iptables
logpath = %(sshd_log)s
backend = %(sshd_backend)s
maxretry = 3
findtime = 10m
# 10分钟内输错3次
bantime = 60m
# 60分钟内禁止链接实际为iptables增加了reject规则
```
* systemctl start fail2ban
* systemctl status fail2ban
* fail2ban-client status
查看fail2ban已经操作的ip
> iptables -nL
```
Chain f2b-SSH (1 references)
target prot opt source destination
RETURN all -- 0.0.0.0/0 0.0.0.0/0
```
* 解封ip
```
fail2ban-client set sshd-iptables unbanip xxx.xxx.xxx.xxx
set 后面的参数 为 jail.local 里面 [xxxx] 对应的节点 sshd-iptables
```

View File

@@ -0,0 +1,58 @@
### 所有环境均为security用户
```
#### 设置用户 工作 目录
mkdir /data/security
useradd -d /data/security -m security
#### 设置用户密码
passwd security
asiainfo_4321
chown -R security:security /data/security
chmod 760 /data/security
usermod -d /data/security security
cp /etc/skel/.bashrc /root/
cp /etc/skel/.bash_profile /root/
yum install -y java-devel
#### 设置主机名称
hostnamectl set-hostname xxxxx
```
修改文件格式内容换行符号
``` sed -i s/\r// **.sh```
### **chmod u+x**
chmod是权限管理命令change the permissions mode of a file的缩写。。
u代表所有者
x代表执行权限。
 + 表示增加权限。
chmod u+x *.sh 就表示对当前目录下的*.sh文件的所有者增加可执行权限
### 切换系统用户
> sudo -i
### 自定义 命令
```
vi ~/.bashrc
alias mysql5.7='/data/cnds/mysql/link_mysql-5.7.37.sh'
```
### 图形化 ui 界面
https://blog.csdn.net/u011811066/article/details/131155350
### 免密 互信
> https://blog.csdn.net/m0_71751187/article/details/138846235
>

View File

@@ -0,0 +1,54 @@
nohup command > /dev/null 2>&1 &
> \> 和 >> 区别,> 会先清空,>> 做追加
### 查看 MAC 地址
ifconfig 这是最常用的方式
ip link show
cat /sys/class/net/eth0/address 查看eth0的mac地址
dmesg | [grep](https://so.csdn.net/so/search?q=grep&spm=1001.2101.3001.7020) eth0
### 开放端口
一个
iptables -I INPUT -s 172.22.0.0/16 -p tcp --dport 5432 -j ACCEPT
iptables -I INPUT -s 125.81.157.249 -p tcp --dport 8848 -j ACCEPT
-m comment --comment "allow SSH to this host from anywhere"
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
service iptables save
所有
iptables -I INPUT -s  172.3.2.0/24 -p tcp --dport 1:65535 -j ACCEPT
> iptables 语法
>https://blog.csdn.net/niuch1029291561/article/details/130935708
### 获取运行脚本 位置
> $(dirname $(readlink -f "$0")
### 获取运行进程
> ll /proc/进程号
### 统计当前目录 文件个数 文件 计数
> ls -hl|grep ^d|wc -l
### 查看文件 大小
> du -h -d 1
### 整体替换 文字
```shell
find /data/zhsq/countryside/juyuan/ -type f|grep yml$|xargs sed -i 's/qinghai-country/juyuan-country/g'
```
### 查找文件 内容 文件名
```shell
grep -rl "pattern" /path/to/directory
file1.txt
file2.txt
file3.txt
```
### 图形化界面
>https://blog.csdn.net/u011811066/article/details/131155350

View File

@@ -0,0 +1,22 @@
简易版
ls -l /dev/vd*
fdisk -l /dev/vdb
fdisk /dev/vdb
n p 1 回车两下 t 8e w
pvcreate /dev/vdb1
vgcreate datavg /dev/vdb1
lvcreate -l 100%VG -n datalv datavg
mkfs -t ext4 /dev/datavg/datalv
mkdir /data
mount /dev/datavg/datalv /data
vi /etc/fstab
/dev/datavg/datalv /data ext4 defaults 0 0

View File

@@ -0,0 +1,12 @@
### 由于windows格式直接复制过来导致无法在linux上运行
set ff 查看
set ff=xxx
```
unix
dos
```
ff -> fileformat
>
:help ff

View File

@@ -0,0 +1,39 @@
```
根据进程号查看运行路径 例子13129
[root@ict-dmp2-2859 puaiuc]# ll /proc/13129
dr-xr-xr-x. 2 root root 0 1月 25 17:35 attr
-rw-r--r--. 1 root root 0 1月 25 17:38 autogroup
-r--------. 1 root root 0 1月 25 17:38 auxv
-r--r--r--. 1 root root 0 1月 25 17:38 cgroup
--w-------. 1 root root 0 1月 25 17:38 clear_refs
-r--r--r--. 1 root root 0 11月 15 14:11 cmdline
-rw-r--r--. 1 root root 0 1月 25 17:38 comm
-rw-r--r--. 1 root root 0 1月 25 17:38 coredump_filter
-r--r--r--. 1 root root 0 1月 25 17:38 cpuset
lrwxrwxrwx. 1 root root 0 1月 25 17:38 cwd -> /usr/local/nginx
-r--------. 1 root root 0 11月 15 14:11 environ
lrwxrwxrwx. 1 root root 0 11月 15 14:11 exe -> /usr/local/nginx/sbin/nginx
```
容器查看
```
docker exec -it bash
docker ps -a
```
shell 启动脚本 启停
```
pid=`ps -ef|grep xxxxxxxxx|grep -v grep|awk '{print $2}'`
echo $pid
kill -9 $pid
./xxxx >> log.mock 2>&1&
echo '-------'
pid=`ps -ef|grep xxxxxxxxx|grep -v grep|awk '{print $2}'`
echo $pid
```
## 问题排查 进程 cpu 内存 占用
```
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
```