I work in a team. We have a CentOS Linux machine. There's a user there called www. We run cron jobs as that user, i.e. I can type sudo -u www crontab -e to see/edit the crontab, and my teammates do the same. However, I like to use nano as my editor, but the crontab opens in vim, because that's the EDITOR for the www user.

Is there a way I can get the crontab to open in nano, without changing the EDITOR setting for the www user? (e.g. via the addition of some additional command line parameter?) My teammates will continue to expect vim to open when they themselves run sudo -u www crontab -e.


You can specify the EDITOR variable as an argument to sudo:

sudo -u www EDITOR=nano crontab -e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.