2

I got a problem when I want to edit files using nano with sudo. When I enter the following command:

sudo nano /etc/exports

I got this error

sudo: nano: command not found

This is the return from echo $PATH:

/home/einzelkind/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib/mit/bin:/usr/local/sbin

I installed nano like this:

  1. Download the package with wget https://nano-editor.org/dist/
  2. extract the files with tar -xvJf
  3. ./configure --enable-utf8 --enable-nanorc
  4. sudo make
  5. sudo make install

Nano is installed in /usr/local/bin.

How to solve this problem?

1

2 Answers 2

3

Is /usr/local/bin in your $PATH? Anyway,

sudo /usr/local/bin/nano

should always work, no matter how $PATH is configured.

1
  • sudo /usr/local/bin/nano works! thank you!
    – Einzelkind
    Jun 21, 2017 at 11:09
0

Perhaps instead of echo $PATH try sudo echo $PATH
Seems root it uses a different one from the user: https://unix.stackexchange.com/questions/83191/how-to-make-sudo-preserve-path

Also, installing packages via package managers is, or so I heard multiple times, a better solution than building manually. Not only because of the ease of uninstallation!
Depending on your system it might be: apt-get, yum or pacman.

2
  • Your link is useful but the command sudo echo $PATH is not. The shell expands $PATH first, then sudo gets its value. Jun 21, 2017 at 11:20
  • Well, that's good to know. Thanks @KamilMaciorowski. So I guess the way to find the PATH for root would be to su first and then echo $PATH, hm? Anyway, as @jvb suggested - running with absolute path will suffice.
    – Votar
    Jun 21, 2017 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .