"'sudo: nano' command not found" issue.
iMac, iOS 8.2
iMac, iOS 8.2
Surprise what I entered is valid bash 😉.
Here is what I see on the terminal with the exception of nano edit screen. nano is invoked, but the output goes away when the nano edit ends. the command exit returns you from being in root. Enter one command at a time. You may want to copy and paste to the terminal window.
me $ sudo bash
Password:
root # which nano
/usr/bin/nano
root # nano /etc/hosts
root # /usr/bin/nano /etc/hosts
root # echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/Developer/Tools:/usr/X11R6/bin:/Developer/Tools
root # # construct nano string. Can see what is in the string later.
root # file="/etc/hosts"
root # app="nano " # note trailing space
root # # will invoke nano.
root # $app$file
root # # see what exactly is in the string.
root # echo -n $app$file | hexdump -C
00000000 6e 61 6e 6f 20 2f 65 74 63 2f 68 6f 73 74 73 |nano /etc/hosts|
0000000f
root #So what happened when you did the nano /etc/hosts within the sudo bash command? Nothing? You didn't get the error message.
As GeoCo suggests, you should define a new user and see if that works. You could have something weird/wrong with your system. Any other problems?
If you like playing around without direction, you could try:
You may want to run these "standard" fixes if the problem persists.
1) Check the amount of free space on your harddrive. You should have a several gigs free.
2) You should run disk utility
Macintosh-HD -> Applications -> Utilities -> Disk Utility
a) verify the disk
b) update your permissions.
3) Try a safe boot.
Shutdown your machine. Hold down the shift key. Poweron. Wait awhile; wait awhile while you harddrive
is being checked.
nofare wrote:
So, at this point ... kinda stumped.
I'm going to try RC's suggestions and, well, hopefully the permission thing will help. Will report back.
Thanks again.
If that doesn't work, you may have to try a re-install of OS X
The problem isn;t that the command nano is not found, if that was the case the error message would be
sudo nano: command not found. For some reason the complete line
nano /private/etc/hosts
is being see as the command. That is the shell is trying to find a command called 'nano /private/etc/hosts'
This will show it better
bash-3.2$ sudo foo fog
sudo: foo: command not found
bash-3.2$ sudo 'nano /etc'
sudo: nano /etc: command not found
bash-3.2$
a
Nottice in the first line the command foo is not found and that way is reported. In the second command the error message is similar to what you get, the whole line is trying to be run. In this case because of the quotes around nano and /etc
As you have included a screenshot there is no way to see just what exactly is going on. Try running just
sudo nano
that most likely will work. You can also try something like
echo 'sudo nano /private/etc/hosts' | od -c
to see if anything strange is coming up between the last o in nano and the first /
I also suggest you cut and paste the command from the terminal rather then adding a screen capture.
Verify nano exists:
ls -l /usr/bin/nano
-rwxr-xr-x 1 root wheel 141088 Oct 31 22:53 /usr/bin/nano
Try:
sudo /usr/bin/nano /etc/hosts
You can see what your PATH looks like when running sudo using (copy and paste the following command into a Terminal session):
sudo sh -c 'echo $PATH'
nano is where it should be, and it should work as you described ( sudo nano /private/etc/hosts worked when I tried it)
See if you have nano set as an alias with: type nano (if it's not aliased you should see: nano is /usr/bin/nano)
But again the error isn;t telling you that the command nano can't be found, it is telling you a command called nano /private/etc/hosts can;t be found. Two very different things.
A few other things to try
run nano /private/etc/hosts directly from the prompt, no sudo. While you won;t have permissions on the file you're looking to see if the error message changes as a clue to want is up.
If it still fails with the SAME error message as you originally received then try running as a different user. This will help narrow the problem down to your environment or to the system.
Ah great minds think alike!! See my post above where I wrote
I also suggest you cut and paste the command from the terminal rather then adding a screen capture.
Given the replies from Tony T1 and BobHarris after my post and now this one it is obvious that no no actually reads previous posts. Now I'm new here but are you guys getting paid by the word or do you all just figure no now else has anything worthwhile to say? 😕
There have been many times someone explaining something differently, or the way the explanation has been visually presented, has been the trick that has gotten through to the person asking the question.
...are you guys getting paid by the word...
As you well know, we are not getting paid anything.
Thank you all for your time and help.
I tried, without sudo, nano /private/etc/hosts and got this (i.e. no error message):
GNU nano 2.0.6 File: /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
I then typed in sudo nano and got a blank screen, with at the top, right under the terminal window's top bar:
GNU nano 2.0.6 New Buffer
Ideas from prior posters. Could this be some type of keyboard problem? Define a new user and run from the new user.
To further discriminate the problem:
sudo bash
# this put you in root. Type exit when done with root. Be careful with what you type
which nano
nano /etc/hosts
/usr/bin/nano /etc/hosts
echo $PATH
file="/etc/hosts"
app="nano " # note trailing space
$app$file
echo -n $app$file | hexdump -Coutput from hexdump
00000000 6e 61 6e 6f 20 2f 65 74 63 2f 68 6f 73 74 73 |nano /etc/hosts|
0000000f
This indicates that sudo is taking the complete line and trying to run it as a command.
A few things to try, enter
sudo echo hello
and see if you get an error message along the same lines as you have been getting ie.
echo hello: command not found.
Make sure you do not have and alias called sudo in your environment. From the prompt enter
alias
and see if anything starting with sudo is shown.
Cut and paste the exact command you are typing in when you run
sudo nano /private/etc/hosts
into a reply window here so we can see if there is anything strange there.
regards
rccharles wrote:
Ideas from prior posters. Could this be some type of keyboard problem? Define a new user and run from the new user.
A keyboard problem could have been a possibility but I would think given that the command works without running it as sudo a keyboard problem seems less likely. A weird keyboard should affect the command with or without sudo, no?
Your idea of running sudo bash is a good one. I'd only add that the first two commands the OP should run after entering
sudo bash
would be
id
env
regards
I agree that approaching the problem from different angels is a good idea. My only concern is that given the error message the OP is getting the problem is not that nano cannot be found it is that the shell is trying to run the complete line
nano /private/etc/hosts
as a single command. A subtle but important difference.
And of course I realize you folks aren't getting paid, was trying to lighten the mood. Looking back at what I wrote I realize I failed.
regards
Here we go with the latest tests:
Ran:
sudo echo hello
Result:
hello
Ran:
alias
Result:
Last login: Wed Mar 18 14:50:14 on ttys000
Smith-iMac:~ smithjoe$ sudo echo hello
Password:
hello
Smith-iMac:~ smithjoe$ alias
Smith-iMac:~ smithjoe$
I then ran:
sudo bash
Result:
Smith-iMac:~ smithjoe$ sudo bash
bash-3.2# id
uid=0(root) gid=0(wheel) groups=0(wheel),1(daemon),2(kmem),3(sys),4(tty),5(operator),8(procview),9(procm od),12(everyone),20(staff),29(certusers),61(localaccounts),80(admin),701(com.app le.sharepoint.group.1),33(_appstore),98(_lpadmin),100(_lpoperator),204(_develope r),398(com.apple.access_screensharing),399(com.apple.access_ssh)
bash-3.2# env
SHELL=/bin/bash
TERM=xterm-256color
USER=root
SUDO_USER=smithjoe
SUDO_UID=501
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.TlpRVhfmsD/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
USERNAME=root
MAIL=/var/mail/root
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PWD=/Users/smithjoe
LANG=en_GB.UTF-8
SHLVL=1
SUDO_COMMAND=/bin/bash
HOME=/Users/smithjoe
LOGNAME=root
SUDO_GID=20
_=/usr/bin/env
bash-3.2#
"'sudo: nano' command not found" issue.