当前位置: 首页 > news >正文

rm -rf 删除/下bin lib lib64 sbin软链接系统恢复

背景

        不小心删除了/bin/lib/lib64/sbin这些目录的软链接,导致系统中的各种命令都无法正常使用。在尝试多种方法后,包括添加环境变量和使用绝对路径执行命令无法恢复,最终不重装完美解决。

[root@centos-8 /]# ll
总用量 36
drwxr-xr-x     3 root     root       18 11月  1 00:00 app
lrwxrwxrwx     1 root     root        8 11月 14 15:52 bin -> /usr/bin
dr-xr-xr-x.    5 root     root     4096 11月  1 00:00 boot
drwxr-xr-x     3 postgres postgres   19 11月  1 00:00 data
drwxr-xr-x    19 root     root     3320 11月  1 00:00 dev
drwxr-xr-x.  131 root     root     8192 11月  1 00:00 etc
drwxr-xr-x.    3 root     root       22 11月  1 00:00 home
lrwxrwxrwx.    1 root     root        7 6月  22 2021 lib -> usr/lib
lrwxrwxrwx.    1 root     root        9 6月  22 2021 lib64 -> usr/lib64
drwxr-xr-x.    2 root     root        6 11月  1 00:00 media
drwxr-xr-x.    2 root     root        6 11月  1 00:00 mnt
drwxr-xr-x.    7 root     root       77 11月  1 00:00 opt
dr-xr-xr-x  1019 root     root        0 11月  1 00:00 proc
dr-xr-x---.    7 root     root     4096 11月  1 00:00 root
drwxr-xr-x    41 root     root     1160 11月  1 00:00 run
lrwxrwxrwx.    1 root     root        8 6月  22 2021 sbin -> usr/sbin
drwxr-xr-x.    2 root     root        6 11月  1 00:00 srv
dr-xr-xr-x    13 root     root        0 11月  1 00:00 sys
drwxrwxrwt.   68 root     root     8192 11月 14 15:52 tmp
drwxr-xr-x.   13 root     root      158 11月  1 00:00 usr
drwxr-xr-x.   21 root     root     4096 11月  1 00:00 var
drwxr-xr-x.    7 root     root       69 11月  1 00:00 web
[root@centos-8 /]# rm -rf bin lib lib64 sbin
[root@centos-8 /]# ll
-bash: /usr/bin/ls: 没有那个文件或目录
[root@centos-8 /]# ll
-bash: /usr/bin/ls: 没有那个文件或目录
[root@centos-8 /]# ln -s /usr/bin /bin
-bash: /usr/bin/ln: 没有那个文件或目录
[root@centos-8 /]# /usr/bin/ln -s /usr/bin /bin
-bash: /usr/bin/ln: 没有那个文件或目录
[root@centos-8 usr]# rz
-bash: /usr/bin/rz: 没有那个文件或目录
[root@centos-8 usr]# /usr/bin/rz
-bash: /usr/bin/lz: 没有那个文件或目录
[root@centos-8 usr]# /usr/bin/sz
-bash: /usr/bin/sz: 没有那个文件或目录
[root@centos-8 /]# export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib:/usr/lib64
[root@centos-8 /]# ln -s /usr/bin /bin

 解决方案

        此时只能执行cd pwd命令,登录也无法登录,网上找博客都是u盘恢复系统,因无法备份,放弃。        

        网上查找删除lib64恢复方法

绝对路径能找到,但是命令无法执行,找到库文件的绝对路径

[root@centos-8 /]# /usr/lib64/ld
ld-2.28.so            ldb/                  ld-linux-x86-64.so.2  
[root@centos-8 /]# /usr/lib64/ld-2.28.so /usr/bin/ln -s /usr/bin /bin
[root@centos-8 /]# /usr/lib64/ld-2.28.so /usr/bin/ln -s /usr/lib /lib
[root@centos-8 /]# /usr/lib64/ld-2.28.so /usr/bin/ln -s /usr/lib64 /lib64
[root@centos-8 /]# /usr/lib64/ld-2.28.so /usr/bin/ln -s /usr/sbin /sbin
[root@centos-8 /]# ll
总用量 36
drwxr-xr-x    3 root     root       18 11月  1 00:00 app
lrwxrwxrwx    1 root     root        8 11月 14 16:49 bin -> /usr/bin
dr-xr-xr-x.   5 root     root     4096 11月  1 00:00 boot
drwxr-xr-x    3 postgres postgres   19 11月  1 00:00 data
drwxr-xr-x   19 root     root     3320 11月  1 00:00 dev
drwxr-xr-x. 131 root     root     8192 11月  1 00:00 etc
drwxr-xr-x.   3 root     root       22 11月  1 00:00 home
lrwxrwxrwx    1 root     root        8 11月 14 16:50 lib -> /usr/lib
lrwxrwxrwx    1 root     root       10 11月 14 16:50 lib64 -> /usr/lib64
drwxr-xr-x.   2 root     root        6 11月  1 00:00 media
drwxr-xr-x.   2 root     root        6 11月  1 00:00 mnt
drwxr-xr-x.   7 root     root       77 11月  1 00:00 opt
dr-xr-xr-x  977 root     root        0 11月  1 00:00 proc
dr-xr-x---.   7 root     root     4096 11月 14 16:24 root
drwxr-xr-x   41 root     root     1160 11月  1 00:00 run
lrwxrwxrwx    1 root     root        9 11月 14 16:50 sbin -> /usr/sbin
drwxr-xr-x.   2 root     root        6 11月  1 00:00 srv
dr-xr-xr-x   13 root     root        0 11月  1 00:00 sys
drwxrwxrwt.  68 root     root     8192 11月 14 16:49 tmp
drwxr-xr-x.  13 root     root      158 11月  1 00:00 usr
drwxr-xr-x.  21 root     root     4096 11月  1 00:00 var
drwxr-xr-x.   7 root     root       69 11月  1 00:00 web

使用库文件绝对路径+命令绝对路径恢复删除的软连接

http://www.lryc.cn/news/510115.html

相关文章:

  • 并发与竞争
  • Java后端开发 ”Bug“ 分享——订单与优惠卷
  • Linux系统之tee命令的基本使用
  • idea 8年使用整理
  • 多个微服务 Mybatis 过程中出现了Invalid bound statement (not found)的特殊问题
  • k8s,service如何找到容器
  • 观察者模式和发布-订阅模式有什么异同?它们在哪些情况下会被使用?
  • docker compose deploy fate cluster
  • 字节跳动Java开发面试题及参考答案(数据结构算法-手撕面试题)
  • 网工日记:FTP工作模式
  • unity使用代码在动画片段中添加event
  • 嵌入式轻量级开源操作系统:HeliOS的使用
  • 解决VMware的ubuntu22虚拟机没有网络
  • 金属衬底介质片对平面波的反射-问题的解析求解和FEM求解
  • 2023 年 9 月青少年软编等考 C 语言四级真题解析
  • C++的内存四区
  • Java爬虫技术:按关键字搜索VIP商品详情
  • C++ —— 模板类与函数
  • 【软考高级】系统架构设计师复习笔记-精华版
  • 免费 IP 归属地接口
  • AIA - IMSIC之二(附IMSIC处理流程图)
  • 数据处理之数据规约
  • 爬虫代理服务要怎么挑选?
  • vue3组件调用解决奇怪问题的详细记录
  • 【物联网技术与应用】实验16:模拟霍尔传感器实验
  • 【机器学习案列】车牌自动识别系统:基于YOLO11的高效实现
  • 高精度问题
  • kong网关使用pre-function插件,改写接口的返回数据
  • 【QT开发自制小工具】PDF/图片转excel---调用百度OCR API接口
  • vue2 elementui if导致的rules判断失效