Software Management for Linux - Install, Uninstall, Upgrade and Dependency Management

1. Comparison: Installing and Uninstalling Software on Windows and Linux

Just like under Windows, many softwares also have installed and free versions, and there are such differences under Linux.
The installation software under Windows requires administrator rights during installation. It will add information about itself in the system registry, and may also add some files in some parts of the system. Typically, such software will provide a uninstall.exefile named . (The problem here is, can this uninstall.exe really uninstall the software? So various problems arise.)
Relatively, Linux package management tools, (common ones are apt-get/dpkg yum/rpm ) also requires root privileges. During installation, the software's dependencies, installation location, and other information will be written somewhere, and the reverse operation of the installation will be performed during uninstallation, but generally only the software itself is uninstalled, not the dependencies. If you use apt-get, you need to use the autoremove option, so that when uninstalling, the dependencies will be automatically uninstalled. (Online installation from software repositories and offline installation of deb rpm downloads belong to this category)

As for the installation-free software, Windows and Linux are similar. You only need to decompress the software (the downloaded software should be in tar.gz or zip format, which needs to be decompressed), and you can use it directly. The startup method of Linux should be the startup script in the bin directory, and on Windows, it is generally the exe program with the same name as the software in the installation directory.

The installation-free software requires the user to remember the installation location. When deleting, just delete the decompressed folder. (If using the program, it does nothing else.)

Windows has a large user base, and the installed software is the most popular. This method can facilitate users to manage their own installed software. And the compatibility of the Windows software system is particularly good. Software compiled on Xp ten years ago is likely to still run smoothly on the latest Win10. (This is also forced by the situation. On Windows, it is almost impossible for ordinary users to compile from source code, so developers have no choice but to publish the exe format.)
And Linux is an open source operating system, so it cannot be included by default. Any non-open source software. If such non-open source software is required, users can only install it by themselves. The Linux-based software has the following features:

  1. Linux-based open source software, if it has a small user base or is updated quickly, may only release the source code tarball, which needs to be compiled and installed by itself, and the compiled version of each platform will not be released. Even if there is a compiled version, it may only provide deb rpm with a large user group, and may not be updated in time. (The Linux community advocates open source, which is very different from WIndows. However, this also makes the Linux software installation process criticized)
  2. Commercial software with a large user base, such as the Jetbrains series, only releases the general binary tar.gz package, that is, the installation-free version, while Oracle JDK only releases tar.gz and rpm. (Probably considering that many CentOS servers use JDK)
  3. Open source software with a large user base generally provides the source code of tar.gz and binary.tar.gz.

To sum up, in terms of Linux, general-purpose free installation packages seem to be very popular, and installation packages can only be used for specific distributions, which is not very popular.
Most of the people who use Linux are programmers, so the source version is also very popular. Installation from source code has greater freedom, and the compiled program can also be specific to your own computer, saving a lot of compatibility things. Simply put, it's faster and cooler.

Then the following three situations are discussed, respectively, to discuss the installation and uninstallation of the software.

2. Install-free binary tarball

This kind of package is generally in tar.gz or tar.xz format. After decompression, cd to the bin directory, and there will be a script or executable file with the same name as the software. Run it directly to start the software. And this kind of package seems to be universal on various distributions (eg. pycharm nodejs jdk etc.)
Generally, after installing the software on Linux, we all want to be able to start it directly in the shell. To do this, you need to understand the Linux shell environment variable configuration file

  • global environment
    • /etc/profile The shell environment configuration file of the system (only loaded once when each user logs in , modification is not recommended)
    • /etc/bash.bashrc The bash shell environment configuration file of the system (every time a new bash is started, it will be loaded. If you need a bash environment that is valid for all users, modify this)
  • User environment
    • ~/.profile [maybe ~/.bash_profile] User's personal shell environment configuration file, equivalent to the personal patch of /etc/profile. Generally it sets some user personal environment variables, and then executes ~/.bashrc.
    • ~/.bashrc User's personal bash shell configuration file (also loaded every time a new bash is opened)
  • source : Execute the specified shell script in the current shell. Often used for environment profiles. (In this way, the variables after running will exist in the current shell, and the so-called environment setting is completed. If it is a normal direct operation, a new shell will be enabled to run the script, and the environment will be destroyed when the operation ends.)

Extending from the above configuration files, when users install binary tarballs, there are usually two ways :

  1. One is to add the bin directory of the software to the PATH (this will make all executable files in the bin directory be added to the PATH, if you don't want this, please consider the second method), which is to add the relevant command into the shell configuration file. As for where it should be added, after reading the above instructions, you should already understand.

    For example, when installing a software, if everyone needs to use the software, it should be written in the system configuration, and if you basically only use bash, it is more convenient to write in bashrc (modifications can take effect immediately), otherwise select profile.
    If only you personally need the software, you must put it in the user configuration, and then consider whether you use other shells. Generally speaking, it is no problem to put it in bashrc, but in profile, sometimes it needs source /etc/profileto .

  2. The second is to add startup scripts to those directories that are included by default in the PATH (eg /usr/local/bin). (Written in python or shell) Jetbrains' software will prompt you to do so when it detects that the software's bin directory is not added to the PATH. (idea will add a python startup script named idea to /usr/local/bin)

If it is a software like JDK that needs to configure environment variables, then you need to manually configure JAVA_HOME, CLASSPATH, etc.

3. Install using the installation package

This method is similar to the Windows installation package, but the installation package can only be used for a specific distribution, because different distributions use different packaging mechanisms. The most common ones are dpkg and rpm, which also have corresponding online installation mechanisms, namely apt-get and yum.
To be continued

4. Compile and install from source

The benefits of compiling and installing from source code have already been said, with higher degrees of freedom, fewer compatibility problems, and higher performance. The disadvantage is that it is more troublesome to compile, and the installed software is not easy to manage.

gcc compilation suite (compile + link)

When it comes to compiling, it is usually c/c++ source code. Before explaining in detail, there are some directories here that need to be introduced first.

  • /lib, /lib64: Shared link libraries, including static link libraries *.a, and dynamic link libraries *.so. When compiling with gcc, the required link library will be queried from here by default. Libraries that are not in this column need -l单个链接库to -L/链接库所在文件夹be specified with or .
  • /usr/include: The place where the system header files are stored. When compiling with gcc, the required system header files will be queried from here by default. Header file directories that are not in this column need -I/头文件所在文件夹to be specified with (is an uppercase i)

make software build tool

When the software becomes large, it becomes unrealistic to manually call gcc again and again. At this time, in order to let the computer automatically handle the compilation and construction process of this kind of project, make was born, which depends on Makefile. (If the project becomes larger, even handwriting Makefiles becomes difficult, and cmake appears. Cmake is used to automatically generate Makefiles, and it depends on CMakeList.txt)
However, the popular open source software, makefile.txt's The generation rules have already been written in configure, all you need to do is

./configure
make
sudo make install

If you are using cmake, just cmake .replace it with ./configure. (Sometimes, in order to isolate and compile related files and source code, a build folder will be created first, and then run in this folder cmake ..)

Having said that, you still need to install the dependencies required for compilation before you can compile normally, otherwise an ./configureerror will be reported at this step. To install a software from source, the most painful part is not in make, but in dealing with dependencies. It would be nice if the installation of this dependency could also be automated. . .

Removal of source code installation software

Software installed from source code has many advantages, but the management of software is a bit troublesome. First of all, many software authors do not provide corresponding make uninstallcommands, so uninstalling software in this way is not universal.
After make installinstalling the software, you must remember to backup the generated software install_manifast.txt, and then delete the source code. (This file is usually write-protected)
After that, if you need to uninstall it, xargs rm < install_manifest.txtjust directly

A backup directory can be created to specifically back up data related to the system. /etc and the above install_manifest.txt (recommended to be renamed "software name _install_manifest.txt") can be counted as such.

refer to

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325074248&siteId=291194637
Recommended