Edit crontab with NANO on centos (crontab -e)

Problem: I don’t know where my root users crontab file is, and this doesn’t usually matter because using the command ‘crontab -e’ opens it for editing anyway… but it opens in VI and I am too stupid / lazy / in a rush to use VI.

[Edit – mid 2018: Earlier this year I went through about 3 weeks of IDE/Editor hell and taught myself Vim. It’s… wonderful]

Solution: The -e switch makes the file open in whatever the default editor for the environment is. To override this, pass the EDITOR environment var to the command when it’s run:

sudo env EDITOR=nano crontab -e

Please let me know if this nano tip was useful, just one click!
Nope, not helpful...Yep, more useful than not!+96 thumb, 124 overall.
Loading…

Comments

6 responses to “Edit crontab with NANO on centos (crontab -e)”

  1. Allan avatar
    Allan

    It was very nice!! I hate vim with a passion.

  2. Matt avatar
    Matt

    To make it permanent and effective for all users, put a .sh file in /etc/profile.d/ e.g.:

    $ nano /etc/profile.d/nano.sh
    export VISUAL=”nano”
    export EDITOR=”nano”

    Log out and log in, then crontab -e will open with nano.

  3. Aleksandr Zaldak avatar
    Aleksandr Zaldak

    Why one would mess with nano /etc/profile.d/nano.sh ? Just
    echo export EDITOR=”nano” >> /etc/profile

    1. Barry Docherty avatar
      Barry Docherty

      # It’s NOT a good idea to change this file unless you know what you
      # are doing. It’s much better to create a custom.sh shell script in
      # /etc/profile.d/ to make custom changes to your environment, as this
      # will prevent the need for merging in future updates.

      That’s why one would mess with nano /etc/profile.d/nano.sh

  4. Mike avatar
    Mike

    $ nano ~/.bash_profile
    export VISUAL=”nano”
    export EDITOR=”nano”
    $ source ~/.bash_profile

  5. Riz avatar

    I simply deleted the vi from /usr/bin with rm /usr/bin/vi and nano become the default editor automatically 😀

Leave a Reply

Your email address will not be published. Required fields are marked *