red hat 下alternatives命令用法

來源:互聯網
上載者:User
alternatives是Linux下的一個功能強大的命令。只能在root許可權下執行。如系統中有幾個命令功能十分類似,卻又不能隨意刪除,那麼可以用 alternatives 來指定一個全域的設定。

alternatives常用於同一個系統中安裝同一軟體的多個版本。比如為了開發需要,我需要安裝JDK1.4.2,同時還需要JDK1.6.10,我怎麼樣才能忽略安裝路徑,按照我自己的意思,使用我想要的java版本呢。

下面為您一一道來。

alternatives的命令列執行如下:
[root@localhost tools]# alternatives 
alternatives version 1.3.36 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage: alternatives --install <link> <name> <path> <priority>
  [--initscript <service>]
  [--slave <link> <name> <path>]*
  alternatives --remove <name> <path>
  alternatives --auto <name>
  alternatives --config <name>
  alternatives --display <name>
  alternatives --set <name> <path>

common options: --verbose --test --help --usage --version
  --altdir <directory> --admindir <directory>

說明:
alternatives --install <link> <name> <path> <priority>
其中,
install表示安裝
link是符號連結
name則是標識符
path是執行檔案的路徑
priority則表示優先順序

以java的安裝為例,我的Fedora 8下內建了兩種java版本,分別如下:

  Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
  2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java


我在目錄/tools/jdk安裝了java version "1.4.2_19"
[root@localhost test]# alternatives --install /usr/bin/java java /tools/jdk/bin/java 3
[root@localhost test]# alternatives --config java

There are 3 programs which provide 'java'.

  Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
  2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
  3 /tools/jdk/bin/java

Enter to keep the current selection[+], or type selection number: 3


我還在目錄/tools/jdk6下安裝了java version "1.6.0_12"
[root@localhost test]# alternatives --install /usr/bin/java java /tools/jdk6/bin/java 4
[root@localhost test]# alternatives --config java

There are 4 programs which provide 'java'.

  Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
  2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3 /tools/jdk/bin/java
  4 /tools/jdk6/bin/java

Enter to keep the current selection[+], or type selection number: 4

用alternatives --config java就可以選擇你想要的Java版本。


出處

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.