Linux: ln:差点酿成一个事故 不要轻易动文件libpcre2-8.so.0.7.1

没想到这个库的使用这么普遍,ls/cp/mv等基础的命令都用到了这个库:
[root@vmtca-2101 lib64]# ldd /usr/bin/cp
linux-vdso.so.1 (0x00007ffda1241000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5139eda000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007f5139cd1000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f5139acb000)
libc.so.6 => /lib64/libc.so.6 (0x00007f5139706000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f5139482000)
[root@vmtca-2101 lib64]# ldd /usr/bin/mv
linux-vdso.so.1 (0x00007ffe43092000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f76c50aa000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007f76c4ea1000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f76c4c9b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f76c48d6000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f76c4652000)

但是最终把pcre2引进来的不是coreutils,而是libselinux.so 这个文件。

稍微移动usr/lib64/目录下的这个文件,就可能导致cp/ls 执行不了,而且外围想要通过ssh登陆机器也会出现错误。所以办了坏事之后,千万不要着急退出当前的窗口,因为这个窗口是目前可操作的窗口。假如 mv libpcre2-8.so.0.7.1 libpcre2-8.so.0.7.1.bak
做了这个操作,我们应该怎么恢复回去呢?

使用ln命令,重新建立符号:libpcre2-8.so.0 -> libpcre2-8.so.0.7.1.bak

[root@vmtca-2101 lib64]# ldd /usr/bin/ln
linux-vdso.so.1 (0x00007f2d18720000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2d17f1e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2d184f4000)

是因为ls使用了以下的库

#rpm -qi libselinux-2.9-8.el8.x86_64
Name : libselinux
Version : 2.9
Release : 8.el8
Architecture: x86_64
Install Date: Fri Oct 6 13:02:17 2023
Group : Unspecified
Size : 173168
License : Public Domain
Signature : RSA/SHA256, Mon Dec 12 19:55:37 2022, Key ID 199e2f91fd431d51
Source RPM : libselinux-2.9-8.el8.src.rpm
Build Date : Mon Dec 12 17:21:40 2022
Build Host : x86-038.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager : Red Hat, Inc. http://bugzilla.redhat.com/bugzilla
Vendor : Red Hat, Inc.
URL : https://github.com/SELinuxProject/selinux/wiki
Summary : SELinux library and simple utilities
Description :
Security-enhanced Linux is a feature of the Linux® kernel and a number
of utilities with enhanced security functionality designed to add
mandatory access controls to Linux. The Security-enhanced Linux
kernel contains new architectural components originally developed to
improve the security of the Flask operating system. These
architectural components provide general support for the enforcement
of many kinds of mandatory access control policies, including those
based on the concepts of Type Enforcement®, Role-based Access
Control, and Multi-level Security.

libselinux provides an API for SELinux applications to get and set
process and file security contexts and to obtain security policy
decisions. Required for any applications that use the SELinux API.

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_36428903/article/details/134948385