Programming Linux User Guide
Programming Linux User Guide
manage software
/opt vs /usr/local
/optis reserved for the installation of add-on application software packages.The
/usr/localhierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable among a group
of hosts, but not found in/usr
The biggest difference the two is that software under /usr/localwill be separated into multiple folders, /usr/local/bin, /usr/local/share, /usr/local/lib. And the software under /opt is not the case.
Using the former can be run directly, but I think it loses the flexibility of environment porting.
update-alternatives
With update-alternatives we can run different programs under a generic name.
The command uses symbolic links to keep track of alternatives. Then, update-alternatives accepts commands to manage alternatives without going through the underlying links.
Specifically,when python2 and python3 exist at the same time, we can jointly create a python(alternatives) for them, which is a symbolic link pointing to the specified version. Through update-alternatives, you can avoid operating the link, and quickly add more versions to python, switch versions, and delete a certain version.
update-alternatives works in two ways. The first auto mode when we add pythonX to python, we can set the priority. The second manual mode, specify a version by command.
# Imagine dealing with multiple versions of python(python2, python3)
# Installing New Alternatives(python)
$ sudo update-alternatives --install /usr/local/bin/python python \
/usr/bin/python2 20
$ sudo update-alternatives --install /usr/local/bin/python python \
/usr/bin/python3 40
# Viewing more information
$ update-alternatives --query python
$ update-alternatives --list python
# Changing Alternatives command manually
$ sudo update-alternatives --config python
# Setting Alternatives Mode to Auto
$ sudo update-alternatives --auto python
# Removing Alternative from Alternatives
# sudo update-alternatives --remove python /usr/bin/python2
[ref1](The update-alternatives Command in Linux | Baeldung on Linux) [ref2](How to Use update-alternatives Command on Ubuntu)

浙公网安备 33010602011771号