"'sudo: nano' command not found" issue.
iMac, iOS 8.2
iMac, iOS 8.2
I feel left out. Could you try this.
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 -C
Everything there looks normal.
In addition to RC Charles suggestions please post a cut and paste of the complete line you enter when you get the error message. Without that there is no further I can go with this. Include the line before and the line after the command similar to what I did in my first post above.
regards
Not sure I understand what you're requesting RC:
Type in sudo bash, which will let me in root. Then, type in which nano, then type in nano /etc/hosts, then type in, one after the other, the rest of the lines you list, from number 05 to number 10, before typing exit at the very end?
Sorry for the quite likely silly confusion.
Oops, I just replied to GeoCo, so hopefully he will forget me 😊
Try the following:
script tmp.log
sudo nano /private/etc/hosts
...
exit
Then provide the hexdump output from the tmp.log
/usr/bin/hexdump -C tmp.log
The 'script' command will start a new command prompt, but capture everything that happens next in the 'tmp.log' file.
You then try your 'sudo' command.
When you are back at your command prompt, enter 'exit' to terminate capturing your output into 'tmp.log'
Finally, you use 'hexdump -C' to dump the captured data in hex. If there are any funny characters, they will show up.
I expect the output from hexdump will look something like:
hexdump -C tmp.log
00000000 6d 79 70 72 6f 6d 6f 74 3a 7e 20 6d 79 75 73 65 |mypromot:~ myuse|
00000010 72 6e 61 6d 65 24 20 73 75 64 6f 20 6e 61 6e 6f |rname$ sudo nano|
00000020 20 2f 70 72 69 76 61 74 65 2f 65 74 63 2f 68 6f | /private/etc/ho|
00000030 73 74 73 0a 73 75 64 6f 3a 20 6e 61 6e 6f 20 2f |sts.sudo: nano /|
00000040 70 72 69 76 61 74 65 2f 65 74 63 2f 68 6f 73 74 |private/etc/host|
00000050 73 3a 20 63 6f 6d 6d 61 6e 64 20 6e 6f 74 20 66 |s: command not f|
00000060 6f 75 6e 64 0a 6d 79 70 72 6f 6d 70 74 3a 7e 20 |ound.myprompt:~ |
00000070 6d 79 75 73 65 72 6e 61 6d 65 24 20 65 78 69 74 |myusername$ exit|
00000080 0a |.|
00000081
It will not be exactly this as I made up the tmp.log file for this example.
BobHarris wrote:
Oops, I just replied to GeoCo, so hopefully he will forget me 😊
Never!! Once I gather enough points to storm the lounge you're in for it, that's for sure 😀
Anyway back to the OP, without the OP cutting and pasting the EXACT line that is entered (and the surrounding context) into a post here there we're all just doing that thing into the wind that gets you all wet.
So nofare, not sure why you are reluctant to do this one easy step that evil go a long way towards solving this but that is your choice.
regards
Thanks everyone again for your generous time and efforts. I really appreciate it.
And yes, GeoCo, I'm ready to solve this little issue ... if at all possible.
GeoCo, here's what I got for "copy and paste the exact line that leads to the error message":
Last login: Fri Mar 20 13:45:53 on ttys000
Smith-iMac:~ smithjoe$ sudo nano /private/etc/hosts
Password:
sudo: nano /private/etc/hosts: command not found
Smith-iMac:~ smithjoe$
As for RC's request ... including the cut and paste request from GeoCo:
Last login: Fri Mar 20 13:45:53 on ttys000
Smith-iMac:~ smithjoe$ sudo nano /private/etc/hosts
Password:
sudo: nano /private/etc/hosts: command not found
Smith-iMac:~ smithjoe$ sudo bash
bash-3.2# which nano
/usr/bin/nano
bash-3.2# nano /etc/hosts
bash-3.2# /usr/bin/nano /etc/hosts
bash-3.2# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
bash-3.2# file="/etc/hosts"
bash-3.2# app="nano "
bash-3.2# $app$file
bash-3.2# 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
bash-3.2# exit
exit
Smith-iMac:~ smithjoe$
Hmm, curious and curious.
Cutting and pasting the line
sudo nano /private/etc/hosts
from your post into my terminal window works. And looking at the hex dump shows nothing out of the ordinary.
Not sure if we had you try this but in case we didn't try entering
sudo /usr/bin/nano /private/etc/hosts
Also try this to determine if this is a problem with your account or with the system you are on: create another user account with admin privileges, log into that account and try the command.
Let us know what happens then.
regards
After running sudo nano /private/etc/hosts, I got:
##
# 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 set up a new user with admin privileges and got this, i.e. the exact same error message.
Last login: Sat Mar 21 22:03:52 on ttys000
Smith-iMac:~ PaulRingo$ sudo nano /private/etc/hosts
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
sudo: nano /private/etc/hosts: command not found
Smith-iMac:~ PaulRingo$
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.
I still think you should try my 'script' idea above and then 'hexdump -C' the resulting log file.
'script' should capture what you typed and what was output.
The 'hexdump -C' should tell us if there are spaces that the shell would accept as token separators or something else (a space in hexdump would be '20'
&&& what happened here when you did nano??? This lines are copied from your post.
bash-3.2# which nano
/usr/bin/nano
bash-3.2# nano /etc/hosts
bash-3.2# /usr/bin/nano /etc/hosts
You where getting an error message before. Did you not get the error message & nothing happened when you typed/copied nano?
Robert
Well, there are other shells around. Perhaps, bash is bashed.
# invoke different shell.
mac $ tcsh
[macForRobert:~] mac% sudo nano /etc/hosts
Password:
# now nano comes up with the /etc/hosts file.
# all the shells are listed here for me. note: sh is a duplicate of bash.
# also, csh, ksh, zsh beside tcsh
[macForRobert:~] mac% ls /bindid you try both /etc/hosts and /private/etc/hosts ? They are the same file. /etc is linked to /private/etc
You could try textwrangler. It has a root mode which I have not used. Have just textwangler command line command.
Robert
nofare wrote:
After running sudo nano /private/etc/hosts, I got:
Wow, lets take a full stop here. Are you saying that when you cut and pasted the line from my post into your terminal window the command worked?
Need to clarify this before doing anything else.
I then set up a new user with admin privileges and got this, i.e. the exact same error message.
When you tried it in the new user account did you cut an paste my command or enter it from your keyboard? (assuming the command worked when you cut and pasted)
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 it is working when you cut and paste from my post but does not work when you enter it from your keyboard this is strange as you would expect other commends to misbehave also.
Give the other ideas a shot, don't overlook Linc's suggest to try it in safe mode, always a good idea.
Well, it looks like it's all fixed really. Not sure how.
I indeed did manage to access the Hosts file after running sudo nano /private/etc/hosts. So it worked ... so well in fact that I didn't notice it at first (that's how clueless I am with Unix commands). Still, I don't know what did the trick: the sequence of sudo bash + which nano + nano /etc/hosts ?
Who should I give the "This Solved My Question" mark? I wish I could give it to a few people, but ... there can be only one.
Just award to the people that were most helpful, in general, and stuck with you the longest (NOT me, as I have mostly been lurking). And if you choose to not award all the points that is perfectly acceptable.
Glad it is working for you now but hate it went there is no actual resolution 😟 Are you sure you did nothing that might have affected the problem? Did you do the safe boot at any time?
Has for the points, The awarding of points (specifically the solved points) serves two purposes, one it is a way to acknowledge and 'reward' in some small way the person who fixed your problem. The second, and possibly more import use of marking a post as solving the issue is to point future users to the post that solved your problem.
Remember ASC serve two purposes, one is to get your problem fixed but equally as important is to serve as a place you can come to and search for solutions for problems without having to go through the, as in this case, long drawn out back and forth. If posts could;t be marked as solving an issue a user would have to go through and read each thread looking to see if the issue was resolved. But on the other hand marking a post as solving an issue when it didn't will also make the system less efficient.
So in this case I would recommend you mark your last post as solved or add one last post explaining that the issue self resolved and mark that as solved. Doing this is OK, you won;t get the points of course but as least future user will know what happened.
As for the two helpfuls if you found any of the suggestions you got during this helpful then go ahead and mark those as such. Pointing out techniques or other troubleshooting ideas that you found worthwhile will help future readers.
Regards
"'sudo: nano' command not found" issue.