본문 바로가기

리눅스

[draft] 우분투에서 기본 텍스트 편집기를 변경하는 방법

우분투에서 기본 텍스트 편집기를 변경하는 방법(ubuntu editor)

update-alternatives 명령어는 Debian 계열의 Linux 시스템에서 여러 프로그램 간에 대안을 선택하거나 설정하는데 사용됩니다. 주로 여러 버전의 소프트웨어를 시스템에 설치할 때 유용하게 활용됩니다.

기본 텍스트 편집기 변경(vim.basic)

update-alternatives --config editor
대체 항목 editor에 대해 (/usr/bin/editor 제공) 4개 선택이 있습니다.

  선택       경로              우선순위 상태
------------------------------------------------------------
* 0            /bin/nano            40        자동 모드
  1            /bin/ed             -100       수동 모드
  2            /bin/nano            40        수동 모드
  3            /usr/bin/vim.basic   30        수동 모드
  4            /usr/bin/vim.tiny    15        수동 모드

Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode

사용 가능한 텍스트 편집기 확인

update-alternatives --list editor
/bin/ed
/bin/nano
/usr/bin/vim.basic
/usr/bin/vim.tiny

수동으로 설정하기(vim.basic)

update-alternatives --set editor /usr/bin/vim.basic
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode

자동 모드로 설정된 텍스트 편집기를 찾아 시스템에서 최선의 대안으로 변경(Status: auto mode)

update-alternatives --auto editor
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode

이제 선택한 텍스트 편집기가 시스템의 기본 텍스트 편집기로 설정됩니다. 변경 사항은 즉시 적용되며, 이제부터는 editor 명령어나 다른 프로그램에서 기본 텍스트 편집기로 선택한 것을 사용하게 됩니다.

update-alternatives 사용법

기본 구문

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

사용법

더보기
$ update-alternatives --help
Usage: 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.
  --query <name>           machine parseable version of --display <name>.
  --list <name>            display all targets of the <name> group.
  --get-selections         list master alternative names and their status.
  --set-selections         read alternative status from standard input.
  --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>.
  --all                    call --config on all alternatives.

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

Options:
  --altdir <directory>     change the alternatives directory
                             (default is /etc/alternatives).
  --admindir <directory>   change the administrative directory
                             (default is /var/lib/dpkg/alternatives).
  --instdir <directory>    change the installation directory.
  --root <directory>       change the filesystem root directory.
  --log <file>             change the log file.
  --force                  allow replacing files with alternative links.
  --skip-auto              skip prompt for alternatives correctly configured
                           in automatic mode (relevant for --config only)
  --quiet                  quiet operation, minimal output.
  --verbose                verbose operation, more output.
  --debug                  debug output, way more output.
  --help                   show this help message.
  --version                show the version.