How to avoid Linux failure situations that could have been avoided? You can do it too

2024.01.10

Linux systems generally have potential problems in the following aspects that affect normal work:

  • hardware malfunction;
  • kernel error;
  • File system corruption;
  • software conflicts;
  • System update issues;
  • malicious software;
  • excessive load;
  • Configuration error.

This article continues to analyze questions 4-8.

software conflict

What are the manifestations of software conflicts under Linux?

Software conflict 1: The dependent library is missing and the software cannot find the dependent function.

For example, many developers install some basic class libraries from source code compilation to custom library paths, and then find that other software on the system and desktop start abnormally. The following is the error log of QT-related software startup failure:

…… libQt5XcbQpa.so.5: undefined symbol: FT_Property_Set
  • 1.

Searching based on keywords yields a lot of results. People often find that there are various effective and ineffective solutions on the Internet, and each one has its own version.

In this regard, my point of view is that it is recommended that Linux users should know what is happening, know why it is happening, and have a deep understanding of the root causes of Linux problems. And solve it from the root cause, draw inferences from one example, and solve similar problems independently after they occur.

For example, if the above error log is a problem that occurs after newly installing a self-compiled library file into the system directory, it is often caused by the library that the QT software depends on (such as libfreetype.so) being replaced with an incompatible version. The FT_Property_Set keyword can help us determine the scope of the problem related to freetype and can also be found in the /etc/ld.so.conf.d/.conf file.

It can be judged that this problem is not caused by the deletion of the libfreetype.so library, because if the system library libfreetype.so is deleted, the Qt error will be similar to required libfreetype.so library not found.

How to avoid it? The software can be called by using LD_LIBRARY_PATH locally, such as in a script and in front of the command line with LD_LIBRARY_PATY = path to the custom library + command. This can avoid problems of mutual interference and contamination between different environments and libraries.

Use conda environment isolation, python's venv environment isolation, etc.; use docker container environment to run different software, or even run different software in virtual machines such as virtualbox; these methods can also help avoid software conflicts.

Package conflict during installation 2:

For example, when installing a software package using centos' yum method, an error message appears. Try adding "--skip-broken" to skip uninstallable software packages or "--nobest" to not only use the best candidate for the software package)

This type of problem is often due to the existence of multiple different versions of software sources in the software source configuration. It is necessary to avoid duplicate different versions of the repository in the /etc/yum.d/*.repo file:

Otherwise, when installing the specified software name through yum, a version conflict will be prompted.

System update issues

Software conflicts caused by failed Linux system updates are often serious problems once they occur. Therefore, the editor recommends that before a major version update, you must make an off-machine backup of the system configuration files and data files.

The good news is that for major updates such as system upgrades and new kernel installations for distributions such as Deepin and Ubuntu, the original files will not be replaced after the update. Instead, a new boot menu entry will be created when the system starts, so that the new boot will start. The system will be the updated system; the system content of the old version can still be entered through the old boot entry. After an exception occurs in the new software system, you can enter the old system software and continue to use it.

Malware issues

Malware problems and overload problems are often encountered by operation and maintenance personnel. Malware is also responsible for system overload and abnormal network traffic. Malware intrusions include not only artificially installed malware, but also active intrusions. For example, website code vulnerabilities and system software external service vulnerabilities (such as nginx or nodejs software vulnerabilities) can be exploited by the outside world to implant malware into the system.

In this regard, the editor recommends that under Linux, enable the firewall, close non-essential external ports, do not use weak passwords, promptly update software with known vulnerabilities to safe versions, do not visit dangerous sites, and use isolation tools such as containers. Risky access operations.

Configuration error

The most common system problems caused by configuration errors encountered by Linux users are often the addition and modification of environment variable files, which affects the access effects of normal variables.

For Linux systems, environment variables are divided into system-level variables, user-level variables, and runtime environment variables within the script scope.

Global scripts and environment variables written at the system level written in /etc/profile. Scripts and environment variables written in the ~/.bashrc file will take effect after the user logs in from the shell or desktop. Variables in scripts that control the jvm startup process, such as tomcat's startup.sh, will only affect software within the scope of the script. Therefore, it will not affect the normal operation of the system or other user software. For example, the installation package of pycharm, which contains pycharm.sh [1], is a .sh file. The startup script of pycharm is also a .sh file. It puts the path of the library required for pycharm to run and uses the environment variables in the script to let pycharm The final binary is file-aware and loaded from the current subdirectory of pycharm (e.g. ./lib/libmy.so).

The dynamic library file search path written in /etc/ld.so.conf.d/xxxx.conf will be equivalent to the LD_LIBRARY_PATH variable that will scope the entire system.

In short, system-level configuration files should be changed as little as possible unless the content and principles of the system configuration file are clear. User-level configuration files can be modified and tested after modification. Software-level configuration files can be changed as needed without affecting other users.

TIPs:

Friends who know software development can also use the git function to do version management before modifying the configuration. This is to prepare for timely recovery after configuration file errors.

References:

[1]pycharm installation package, including pycharm.sh: https://download.jetbrains.com.cn/python/pycharm-community-2023.2.5.tar.gz