Linux中如何巧妙恢复被进程锁定的已删除文件
一、模拟场景 (1)编写脚本 test_del.sh,并执行 脚本内容 #!/bin/bash while true; do sleep 10000000 done (2)删除执行中的脚本 [root@dameng linuxscript]# rm test_del.sh rm: remove regular file 't…
Linux自定义函数递归显示目录
lsr () { find "${@:-.}" -print0 | sort -z | xargs -0 ls --color=auto -dlha; } 命令注释: ${@:-.}:传递给 lsr 函数的所有参数 (即路径),如果没有提供参数,则以。作为起点 (当前路径) -print0:处理特殊字符 sort -z:排序并处理特…
Linux下编写备份归档脚本
#!/bin/bash #备份归档 #创建备份归档目录 if [! -d "/backups"]; then mkdir -p /backups fi for file in $(find /backups -name "backup-*" -type f | sort -r | tail -n +5); do rm …
Linux下使用gzip在线归档日志文件
[dmdba@localhost log]$ gzip -c dm_DMSERVER_202403.log -c >/tmp/dm.out.log.20240424.gz && >dm_DMSERVER_202403.log 将日志文件 dm_DMSERVER_202403.log 重定向压缩到 /tmp/…
Linux可视化系统启动过程
[root@localhost ~]# systemd-analyze plot >boot.svg 然后通过 sz boot.svg 命令将文件传输到本地,使用浏览器打开此文件即可。如下图
Linux审计ssh登录失败的IP
grep -i "failed password" /var/log/secure | awk '{if ($11 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) print $11 ; else print $13 }' | uniq -c | sort -nr -k1…
Linux下硬盘测试命令dd
命令 dd if=/dev/zero of=/dmdata/test.sdf bs=32k count=40k oflag=dsync 等待测试完成即可 [root@dameng ~]# dd if=/dev/zero of=/dmdata/test.sdf bs=32k count=40k oflag=dsync 409…