로그인
Sign in
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form

하나의 심볼릭 링크로 여러 개의 패키지 관리하기 - update-alternatives


1. 개 요

버전이 각기 다른 패키지에 대해서 동일한 심볼릭 링크를 사용해야 할 경우에 어떻게 해야 할까? 원하는 버전으로 실행하고자 한다면 매번 해당 버전으로 심볼릭 링크를 걸어주면 될 것입니다. 사용자가 아닌 여러 프로그램에서 각기 다른 버전을 사용한다면 사용자가 심볼릭 링크를 변경해 주지 않고서는 프로그램이 자동으로 적당한 버전으로 심볼릭 링크를 해 주기는 어렵습니다. 예를 들어 python을 생각해 보죠. 파이썬은 현재 pythion2버전과 python3 버전이 시스템에 동시에 깔려 있습니다.

alter_170956.jpg


파이썬이 현재 2버전으로 심볼릭링크되어 있는데, 다른 파이썬 프로그램이 3버전을 요구할 경우 python 명령이 실행되어질 때 2버전으로 동작하기 때문에 3버전으로 심볼릭 링크를 갱신해 주지 않는 한 오류가 발생될 수 있습니다. 여기서 딜레마가 발생할 수 있습니다. 스크립트로 3버전을 요구하는 프로그램에 대해서 3버전으로 심볼릭 링크 처리해 주면 동작하겠지만, 2버전을 요구하는 다른 프로그램에선 또 오류가 발생될 수 있습니다.


이러한 문제를 해결하기 위해서 고안된 것이 alternatives 도구로 데비안 리눅스에서 개발되었고, 넘버원 리눅스와 레드햇 리눅스 계열에서는 update-alternatives 명령을 사용하며 alternatives로 심볼릭링크되어 있으므로, 두 명령어중 한 명령으로 사용이 가능합니다. update-alternatives를 이용하면 여러 개의 패키지에 대해서 한 개의 심볼릭 링크를 통하여 관리할 수 있는 이점이 있는데, 오늘의 강좌에서는 이 명령어의 사용법에 대해서 알아보는 시간을 갖도록 하겠습니다.

2. Update-alternatives 사용법

 Usage: /usr/sbin/update-alternatives [<option> ...] <command>

Commands:
  --install <link> <name> <path> <priority>  [--slave <link> <name> <path>] ...
                                                        add a group of alternatives to the system.
  --remove <name> <path>      remove <path> from the <name> group alternative.
  --remove-all <name>               remove <name> group from the alternatives system.
  --auto <name>                          switch the master link <name> to automatic mode.
  --display <name>                      display information about the <name> group.
  --list <name>                             display all targets of the <name> group.
  --config <name>                       show alternatives for the <name> group and ask the
                                                        user to select which one to use.
  --set <name> <path>               set <path> as alternative for <name>.

<link> is the symlink pointing to /etc/alternatives/<name>.
<name> is the master name for this link group.
<path> is the location of one of the alternative target files.
<priority> is an integer; options with higher numbers have higher priority in
  automatic mode.

Options:
  --altdir <directory>                    change the alternatives directory.
  --admindir <directory>             change the administrative directory.
  --verbose                                     verbose operation, more output.
  --quiet                                          quiet operation, minimal output.
  --help                                            show this help message.
  --version                                       show the version.



1. 심볼릭링크 생성(--install)

  update-alternatives --install <link> <name> <path> <priority>  [--slave <link> <name> <path>] ...

 <link>

 심볼릭링크명이 위치할 경로명

 <name>

 /etc/alternatives 경로에 위치할 심볼릭링크명

 <path>

 패키지가 설치되어 있는 경로

 <priority>

 자동모드로 동작할 때 동작할 우선 순위


예제로 NVidia 그래픽 카드 드라이버의 ld.so.conf 에 대해서 gl_conf로 심볼릭 링크를 생성해 봅니다. 먼저 기존 심볼릭 링크를 제거하고 새로 생성해 봅니다.

 # update-alternatives --remove gl_conf /etc/nvidia-current/ld.so.conf

 # update-alternatives --remove gl_conf /etc/nvidia340/ld.so.conf

 # update-alternatives --remove gl_conf /etc/nvidia304/ld.so.conf


자, 그러면 다음과 같이 nvidia-current(nvidia 390 드라이버)의 ld.so.conf에 대해서 gl_conf로 심볼릭 링크를 추가합니다. 

 # update-alternatives --install /etc/alternatives/ld.so.conf  gl_conf /etc/nvidia-current/ld.so.conf 500


그 다음에도 nvidia340, nvidia304에 대해서 다음과 같이 심볼릭 링크를 합니다.

 # update-alternatives --install /etc/alternatives/ld.so.conf gl_conf /etc/nvidia340/ld.so.conf 400

 # update-alternatives --install /etc/alternatives/ld.so.conf gl_conf /etc/nvidia304/ld.so.conf 300


2. 심볼릭링크 수동모드및 확인(--config)

 update-alternatives --config <name>


여러 개의 패키지에 대해서 alternatives로 심볼릭링크를 걸어 놓았을 때 심볼릭링크 상태를 확인하거나 심볼릭링크 우선순위를 변경하고자 할 때는 --config 옵션을 사용합니다. 그러면 이 옵션을 사용하여 엔비디아 그래픽 카드의 ld.so.conf 파일에 대한 심볼릭 링크 목록을 확인해 봅니다.

 # update-alternatives --config gl_conf

 There are 4 programs which provide `gl_conf'.

  Selection    Command
-----------------------------------------------
*+    1        /etc/ld.so.conf.d/GL/standard.conf
        2        /etc/nvidia-current/ld.so.conf
        3        /etc/nvidia340/ld.so.conf
        4        /etc/nvidia304/ld.so.conf
Enter to keep the default[*], or type selection number:


네 개의 목록이 있습니다. 앞서 심볼릭링크를 추가할 때 nvidia-current를 500, nvidia340은 400, nvidia304은 300으로 우선순위도를 지정해 주었는데, 숫자가 높을수록 우선순위도가 높습니다. 현재 시스템에서 기본적으로 설정되어 있는 1번이 가장 높은 우선순위도로 되어 있습니다. 그러면 /etc/alternatives/gl_conf 심볼릭 링크의 상태를 확인해 봅니다.

 # ll /etc/alternatives/gl_conf
 lrwxrwxrwx 1 root root 34  4월 16 17:55 /etc/alternatives/gl_conf -> /etc/ld.so.conf.d/GL/standard.conf


현재 /etc/ld.so.conf.d/GL/standard.conf 파일이 gl_conf로 심볼릭링크되어 있습니다. 그러면 --config 옵션을 넣어 실행하여 기본값으로 3를 입력해 봅니다.

 # update-alternatives --config gl_conf

 There are 4 programs which provide `gl_conf'.

  Selection    Command
-----------------------------------------------
*+    1        /etc/ld.so.conf.d/GL/standard.conf
        2        /etc/nvidia-current/ld.so.conf
        3        /etc/nvidia340/ld.so.conf
        4        /etc/nvidia304/ld.so.conf

 Enter to keep the default[*], or type selection number:3

 Using `/etc/nvidia340/ld.so.conf' to provide `gl_conf'.

# ll /etc/alternatives/gl_conf
 lrwxrwxrwx 1 root root 25  4월 16 18:06 /etc/alternatives/gl_conf -> /etc/nvidia340/ld.so.conf


gl_conf 심볼릭링크가 /etc/nvidia340/ld.so.conf로 변경되었음을 확인할 수 있습니다. 이렇게 --config 옵션을 사용하여 수동으로 원하는 파일로 심볼릭링크를 갱신할 수 있습니다.


3. 자동 모드 (--auto)

  update-alternatives --auto <name>


자동모드는 우선순위도 값에 따라서 심볼릭링크가 결정되는데, 제일 높은 값이 먼저 선택되며, 자동으로 선택된 링크가 제거되면 다음 낮은 순위로 심볼릭링크가 갱신됩니다. 즉 세개의 엔비디아 그래픽 카드 드라이버만 있을 경우에 제일 순위도가 높은 dkms-nvidia-current 패키지가 제거되면 자동으로 dkms-nvidia-340 패키지가 gl_conf로 심볼릭링크 되는 것입니다.


4. 심볼릭링크 제거(--remove)

 update-alternatives --remove <name> 경로명/파일명


이 옵션에 대해서는 --install 옵션에 살펴보았듯이, 삭제하고자 하는 심볼릭링크 대상파일명을 지정해서 제거하면 됩니다.

5. 심볼릭링크 목록 확인( --display)

 update-alternatives --display <name>


alternatives로 설정된 심볼릭링크 목록을 확인하고자 할 때는 --display 옵션을 사용합니다.

 # update-alternatives --display gl_conf
 gl_conf - status is manual.
   link currently points to /etc/nvidia340/ld.so.conf
 /etc/ld.so.conf.d/GL/standard.conf - priority 500
    slave xorg_extra_modules: /usr/lib64/xorg/xorg-1.6-extra-modules
 /etc/nvidia-current/ld.so.conf - priority 500
 /etc/nvidia340/ld.so.conf - priority 400
 /etc/nvidia304/ld.so.conf - priority 300
 Current `best' version is /etc/ld.so.conf.d/GL/standard.conf.

--list 옵션을 사용하여 간단하게 심볼릭링크 목록을 확인할 수도 있습니다.

 # update-alternatives --list gl_conf
 /etc/ld.so.conf.d/GL/standard.conf
 /etc/nvidia-current/ld.so.conf
 /etc/nvidia340/ld.so.conf
 /etc/nvidia304/ld.so.conf


6. 심볼릭링크 변경하기(--set)

  update-alternatives --set <name> <path>


--config 옵션으로 심볼릭링크를 변경하는 방법에 대해서 알아 보았는데, --config 옵션은 목록을 확인하여 원하는 대상으로 심볼릭링크를 거는 것에 비해 --set 옵션은 심볼릭링크 목록을 알고 있는데 상태에서 바로 원하는 대상으로 심볼릭링크를 갱신하고자 할 때 사용됩니다. --config 옵션은 스크립트에 적용하기 어려우나, 이 옵션은 스크립트내에선 유용합니다.


  # update-alternatives --set gl_conf /etc/nvidia-current/ld.so.conf

  Using `/etc/nvidia-current/ld.so.conf' to provide `gl_conf'.


3. 연습해 보기

앞서 머릿말에서 파이썬을 예제로 들었는데, python 2버전과 3버전을 python으로 심볼릭링크명을 갖도록 설정하여 버전을 요구하는 프로그램에 따라서 심볼릭링크를 갱신하도록 연습해 보기 바랍니다.



























 # rm -f python

 # alternatives --install /usr/bin/python python /usr/bin/python2 200

 # alternatives --install /usr/bin/python python /usr/bin/python3 100

 # alternatives --set python /usr/bin/python3

 # ll /etc/alternatives/py*
 lrwxrwxrwx 1 root root 16  4월 16 18:44 /etc/alternatives/python -> /usr/bin/python3*

 # alternatives --set python /usr/bin/python2

 # ll /etc/alternatives/py*
 lrwxrwxrwx 1 root root 16  4월 16 18:44 /etc/alternatives/python -> /usr/bin/python2*




List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 넘버원 리눅스 팁은 FAQ 게시판으로 zharyong 2018.07.16 808
15 시스템 [플라즈마] 단축키 설정 방법 (수동) KDE 플라즈마에서 단축키 설정하는 방(KDE 제어판 단축키 설정) KDE 플라즈마에서 단축키 설정은 KDE 제어판의 단축키 설정에서 손쉽게 할 ... No1Linuxer 2020.07.14 536
14 시스템 [Funny Tip] 텍스트를 음성으로 1 file zharyong 2019.01.04 363
13 시스템 [부팅] 윈도7에서 No1.Linux 2018 SE Live 부팅 방법 file zharyong 2018.12.11 415
12 시스템 [시스템] 공인 인증서 anysign4pc 설치후 실행시 libNativeMng.so 오류 발생 anysign4pc 설치 후 실행 바이너리를 실행하였을 때 오류가 발생되는 경우 [root@localhost Downloads]# /opt/anysign4pc/amd64/AnySign.ex ... zharyong 2018.07.06 1031
11 시스템 [시스템] rpm 패키지는 어떻게 푸나? How to extract RPM package dir... file zharyong 2018.05.27 1255
10 시스템 [팁] xterm-256color': unknown terminal type 메시지및 MC에서 키보드 사... xterm-256color': unknown terminal type 대책및 MC에서 일부 키보드 사용이 안될 때 버전이 서로 다른 원격 No1.Linux 서버에 접속하... zharyong 2018.05.04 823
9 시스템 [MC] No1.Linux 2018 SE의 mc에서 ISO 파일 내용물을 보려면 file zharyong 2018.05.03 318
8 시스템 [컴파일오류] /usr/bin/ld: cannot find -lgtk-3 컴파일 오류 : /usr/bin/ld: cannot find -lgtk-3에 대한 대책 소스를 컴파일하다보면 다음과 같이 라이브러리 링크 문제가 발생되는 경우가... zharyong 2018.05.01 9601
7 시스템 [시스템] 쉘에서 set GTK_DEBUG 관련 오류 메시지가 발생되는 경우 file zharyong 2018.04.24 370
6 시스템 [시스템] DKMS(Dynamic Kernel Module Support)를 이용한 모듈 관리 DKMS(Dynamic Kernel Module Support) 모듈 관리 1. 개 요 DKMS(Dynamic Kernel Module Support)는 커널 모듈이 부팅시 생성되고, 활성... zharyong 2018.04.17 4751
» 시스템 [시스템] Alternatives(Update-altenatives)로 하나의 심볼릭 링크로 여러 패... 하나의 심볼릭 링크로 여러 개의 패키지 관리하기 - update-alternatives 1. 개 요 버전이 각기 다른 패키지에 대해서 동일한 심볼릭 링크... file zharyong 2018.04.17 5849
4 시스템 [시스템] 부팅화면을 바꿔 보고 싶으세요? 플리마우스 변경하기 1 file zharyong 2018.03.31 1452
3 시스템 [System] 바탕화면에 시스템 정보를 모니터하여 멋지게 꾸며볼까 - conky file zharyong 2018.03.31 1003
2 시스템 [시스템] 외국 배포판의 응용프로그램을 한글화(Localization)하는 방법 file zharyong 2018.03.24 381
1 시스템 [시스템] MD5SUM 체크섬 파일 만드는 방법과 검사하는 방법 데이터 무결점 체크섬 만드는 방법과 검사하는 방법 넘버원리눅스는 ISO 형태로 배포가 이뤄지고 있는데, 다운로드한 ISO 파일이 배포한 ... zharyong 2018.03.22 1460
목록
Board Pagination Prev 1 Next
/ 1