Change default nano version

How to change nano default version when using with sudo command? I have installed nano editor version 2.9.7 located in /usr/local/bin directory but with sudo command used old version 2.0.6 from /usr/bin. Thanks for advance

MacBook Pro (Retina, 15-inch, Late 2013), macOS High Sierra (10.13.4)

Posted on Jun 1, 2018 6:25 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 1, 2018 8:06 AM

Sudo does not change the PATH environment variable.

By default, /usr/bin comes before /usr/local/bin, so the version of nano included will still be run.


The most likely explanation is that in your

.bash_profile or .bashrc (or similar file if you use another shell) you have created an alias - something like


alias nano=/usr/local/bin/nano




One way to get around this is to make /usr/local/bin come *before* /usr/bin in the path.

I have done this so that, for example, I can use a newer version of Python that is installed in /usr/local/bin.


To do that, just add the following like to .bash_profile:


export PATH="/usr/local/bin:$PATH"



NOTE: this change will make any programs with the same name that you install on /usr/local/bin take precedence over what is in /usr/bin.

2 replies
Question marked as Top-ranking reply

Jun 1, 2018 8:06 AM in response to vladimir_53

Sudo does not change the PATH environment variable.

By default, /usr/bin comes before /usr/local/bin, so the version of nano included will still be run.


The most likely explanation is that in your

.bash_profile or .bashrc (or similar file if you use another shell) you have created an alias - something like


alias nano=/usr/local/bin/nano




One way to get around this is to make /usr/local/bin come *before* /usr/bin in the path.

I have done this so that, for example, I can use a newer version of Python that is installed in /usr/local/bin.


To do that, just add the following like to .bash_profile:


export PATH="/usr/local/bin:$PATH"



NOTE: this change will make any programs with the same name that you install on /usr/local/bin take precedence over what is in /usr/bin.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Change default nano version

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.