기본 crontab 편집기 변경 -100

기본 편집기를에서 (으) nano로 변경하려고 합니다 vim.

다음 명령을 실행했습니다.

sudo update-alternatives --config editor

update-alternatives --config editor

둘 다 이제 출력합니다.

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
* 3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

ssh 세션을 다시 시작하고 sshd를 다시 시작했지만 crontab -e는 여전히 nano에서 열립니다.

다른 무엇을해야합니까?



답변

ssh 세션을 시도한 다음

export EDITOR=vim

또는 가능

export EDITOR=/usr/bin/vim.basic

EDITOR 변수 설정 형식은 사용중인 쉘에 따라 다릅니다.

우분투에서는 로그온시 EDITOR 환경 변수를 설정할 수 있습니다. ~/.profile

SSH 세션은이라는 원격 호스트에서 유사한 파일 (있는 경우)을 읽습니다 ~/.ssh/environment. 이것은 ssh 데몬 설정에 의해 구체적으로 정의되어야합니다. 참조 man sshd_config및 찾아 PermitUserEnvironment자세한 내용은.


답변

간단히 실행 select-editor하면 원하는 편집기를 선택할 수 있습니다.


답변

내 개인적인 취향 …

cd /bin
mv nano nano_must_die
ln -s /usr/bin/vim nano


답변

“man crontab”에서 :

   The -e option is used to edit the  current  crontab  using  the  editor
   specified  by  the  VISUAL  or EDITOR environment variables.  After you
   exit from the editor, the modified crontab will be installed  automati‐
   cally.  If  neither  of  the environment variables is defined, then the
   default editor /usr/bin/editor is used.

EDITOR 환경 변수가 nano로 설정되어 있습니까?


답변

편집기를 임시로만 선택하려면 다음을 수행하십시오.

EDITOR=nano crontab -e

이것은 EDITOR명령에 대한 환경 변수를 설정합니다


답변

내 Ubuntu 12.04 컴퓨터 에서 선택한 편집기의 경로가 포함 된 파일을 crontab사용합니다 ~/.selected_editor. 그것을 편집하십시오 :

nano ~/.selected_editor

직접 편집하거나 사용했습니다 select-editor. 동일한 작업을 수행하는 스크립트입니다. 다음 줄을 편집하십시오.

SELECTED_EDITOR="/usr/bin/vim.basic"

IHMO 사용자는이를 위해 / etc 또는 / bin의 내용을 변경해서는 안됩니다. 시스템 수준의 작업이 아니라 사용자 수준의 것입니다.


답변

나는에 어려움을 겪고 있었다 select-editor하고 update-alternatives, 내 솔루션은 단순히 링크를 편집 할 수 있었다 :

  1. sudo rm /etc/alternatives/editor
  2. sudo ln -s /usr/bin/vim /etc/alternatives/editor

editor 이제 Vim을 엽니 다