First get to know the ln and update-alternatvies commands.
LN Link
First, let's talk about the Linux link, which is divided into two kinds: symbolic link (symbolic link) and hard link (hard link).
We know that files have file names and data, which are divided into two parts on Linux: User data and metadata (metadata). User data, that is, file data blocks (data block), which is where the real content of the file is recorded, and metadata is the attached property of the file, such as file size, creation time, owner, and so on. In Linux, the inode number in the metadata (the Inode is part of the file metadata but it does not contain a filename, and the inode number, which is the index node number), is the file's unique identity rather than the filename. The file name is only for the convenience of people's memory and use, the system or program through the inode number to find the right file data block. The following illustration shows the process by which a program obtains the contents of a file through a filename.
To solve the shared use of the file, the Linux system introduces two kinds of links: Hard link (hard link) and soft link (also known as symbolic link, that is, soft link or symbolic link). Links for Linux systems to solve the shared use of files, but also brings the hidden file path, increase the security of permissions and save storage, and other benefits. If an inode number corresponds to multiple file names, these files are referred to as hard links. In other words, a hard link is one file that uses multiple aliases (the following figure hard link is an alias for file, they have a common inode). Soft links and hard links are different, if the file user data block in the contents of another file is the path name point, then the file is a soft connection. Soft link is a common file, but the content of the data block is somewhat special. A soft link has its own inode number and user data block.
Alternatives Mechanism
Alternatives is also known as the "alternative" mechanism, as shown below
There are some symbolic links (alternatives) under/etc/alternatives, and a substitute link can link a set of files that have priority, which can be selected as a substitute for links to real-world files;
Other symbolic links can be connected to a substitute link
Its scenario is this: for example, the current popular editor is Vim, Nano, Emacs, and Debian has its own vim.tiny. If the system installs these editors, how can you use a friendly (symbolic) link such as editor to map to your favorite editor? The
uses the alternatives mechanism to create a editor symbolic link under/etc/alternatives that points to vim, Nano, Emacs, and the current choice is vim; and then in/usr/ Bin then create a symbolic Link editor link to the replacement link editor, then we can use editor to open the editor, when you want to switch to Emacs, use the command update-alternatives--config Editor can choose another editor. Of course, if you do not use the alternatives mechanism can also, just want to change the time to do the manual symbolic link, this is my understanding.
Install Java
Online Search How to install Java is generally the use of the alternatvies mechanism, in fact, manually create symbolic links directly I think it is also very convenient, but may consider a number of Java versions bar. But no matter what, as long as the knowledge of the above theory can not understand how to install.
To download the Java version you need first, I download the Java7 Server JRE and extract it to "/usr/lib/jvm//jdk1.7.0_60" and then use the following command to install alternatives
The code is as follows |
Copy Code |
Update-alternatives--install/usr/bin/java Java/usr/lib/jvm/jdk1.7.0_60/bin/java 100 |
If alternatives Java does not point to just one Java, it needs to be configured with the following command
The code is as follows |
Copy Code |
Update-alternatives--config Java
|
More update-alternateives command options can be viewed using--HELP.