I have this problem on fresh install of Debian 8 (after doing apt upgrade).

nano is installed but when I try to use it to open a file :

nano myfile.txt

I get:

-bash: /usr/bin/nano: No such file or directory

I removed and reinstalled nano I get:

Setting up nano (2.7.4-1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode

And using /usr/bin/editor myfile.txt I can open the file.

Why does this happen? How can I fix it?

migrated from serverfault.com May 3 '18 at 9:08

This question came from our site for system and network administrators.

  • ls -l /usr/bin/nano ls: cannot access '/usr/bin/nano': No such file or directory – Karlom May 3 '18 at 9:22
  • 1
    What does type nano give you? Presumably Bash has hashed it under the wrong path. Have you tried logging on anew to see if this is limited to your shell instance? – 0xC0000022L May 3 '18 at 9:47
  • 1
    Guys, for no obvious reason, nano command works now. As for type nano I get nano is hashed (/bin/nano). Really strange! I never had such issue before. – Karlom May 3 '18 at 9:50
  • @StephenKitt Could you explain what is cause of the problem , please. – GAD3R May 3 '18 at 10:03
  • 5
    @GAD3R nano used to include both /bin/nano and /usr/bin/nano (the latter as a symlink to the former). Going from Debian 8 to 9, nano dropped the symlink; upgrading the package would then result in the error in the question, until a new shell is started or hash -r is run. – Stephen Kitt May 3 '18 at 11:06

In Debian 8, nano includes both /bin/nano and /usr/bin/nano (the latter is a symlink to the former). In Debian 9, /usr/bin/nano is no longer included (see #767929 for details).

Presumably you upgraded from Debian 8 to a version of the package including the fix above. Your shell had remembered that nano was in /usr/bin/nano, but after the upgrade that was no longer the case. Running hash -r in your shell would fix that, as would starting a new shell.

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.