Programming Linux User Guide
manage software
/opt vs /usr/local
/opt
is reserved for the installation of add-on application software packages.The
/usr/local
hierarchy 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/local
will 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)
sdkman
Better software version management and software environment management than update-alternatives.
update-alternatives can only be used for version control, and sdkman can automatically set the JAVA_HOME environment variable.
Its principle is very simple, it will save all managed software under ~/.sdkman/candidates, and change the PATH variable very roughly to achieve the purpose
#$ sdk current
Using:
java: 14.0.2-zulu
gradle: 6.2.2
Imagine dealing with multiple version of java
# Installing sdkman
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
# List All SDK Candidates
# The list command shows all the available candidates,
# identified by a unique name, the description, the official website,
# and the installation command
$ sdk list
$ sdk list java
# Install and Manage Java Version
$ sdk install java Identifier # online
$ sdk install java _custome_identifier _path_to_target # localy
# Switching Between Versions
$ sdk use java Identifier # temporarily
$ sdk default java 14.0.1.j9-adpt # permanently
# Remove a Version
$ sdk uninstall java 14.0.1.j9-adpt
# Display the Version in Use
$ sdk current java
$ sdk current
[ref1](Guide to SDKMAN! | Baeldung)
标签:software,python,Programming,alternatives,update,User,sdk,Guide,usr From: https://www.cnblogs.com/ivanohohoh/p/17065724.html