avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

bash: sudo command not found

Tue Aug 21, 2018 10:19 pm

Hey,
I use the latest raspbian build and everything was working as expeced. suddenly the sudo command is not recognized anymore.
i ssh into the pi with the default user and get into a bash shell, when trying to run sudo i get "command not found" error.

any ideas what might cause this?

User avatar
Paeryn
Posts: 3056
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: bash: sudo command not found

Wed Aug 22, 2018 1:13 am

What is the exact error? Is the shell saying that sudo isn't found or is sudo saying whatever command you asked it to run isn't found?

Have you done anything to change the user's PATH environment variable, that holds the list of directories (separated by colons) that will be searched for commands.
She who travels light — forgot something.
Please note that my name doesn't start with the @ character so can people please stop writing it as if it does!

avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 5:02 am

it complains about sudo:

Code: Select all

pi@raspberrypi:~ $ sudo ls -l
-bash: sudo: command not found
by the way, when i start a new shell session, i get this error:

Code: Select all

-bash: gettext.sh: No such file or directory
i didnt do anything to the path, i actually didnt do anything at all :)
here is content of my path:

Code: Select all

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
i actually cant find sudo inside usr/bin at all

User avatar
RaTTuS
Posts: 10578
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: bash: sudo command not found

Wed Aug 22, 2018 7:26 am

avieln wrote:
Tue Aug 21, 2018 10:19 pm
Hey,...
i ssh into the pi with the default user and get into a bash shell, ...
a couple of things come to mind
1)
have you opened ports to the internet ??
have you changed your password ?

2)
is this a fake card ?

3)
grab a new card and install latest raspbian then recover any useful files off the old sdcard
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 11:22 am

I didnt open any ports (at least not that i know off) the pi is on my home wifi, but i did use apt get etc.
I didnt change the password, do you think it was hacked?

Not sur what you mean by fake card.. Its a simple sd card. Btw its the second time that my system becomes unusable in 2 months because of strange things like that..

What am i missing?

oldjake
Posts: 90
Joined: Fri Aug 03, 2018 12:39 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 12:05 pm

Have you changed the hostname and not rebooted? I'm sure I had this problem once and it was either that or, as someone else suggested, because I changed the password.

avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 12:12 pm

Nope, everything still as usual. Hostname is Raspberrypi and pass is default

oldjake
Posts: 90
Joined: Fri Aug 03, 2018 12:39 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 1:51 pm

pass is default
That worries me. Really default?

Last time I forgot to change the default password, I think it took about 2 hours for my Pi to get taken over for BC mining.

avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 1:55 pm

yea, i am to naive i guess (even though i'm behind a router).

can i somehow solve this? i was thinking about somehow logging as root (this is tricky since root is disabled and i have no sudo option to enable it). i can try to unmount the SD and access it through another pc.
other option will be just to reinstall everything (Again), which i dont want to :(

User avatar
davidcoton
Posts: 5360
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: bash: sudo command not found

Wed Aug 22, 2018 1:58 pm

oldjake wrote:
Wed Aug 22, 2018 1:51 pm
pass is default
That worries me. Really default?

Last time I forgot to change the default password, I think it took about 2 hours for my Pi to get taken over for BC mining.
Why should that worry you? OP says there are no ports open, so external hacks are not likely.

A faulty SDCard is more likely, search for "fake SDCard" and pick up one of the test utilities (this will overwrite the current contents, so back up anything important first, using another Linux PC, or a Windows PC with an ext4 filesystrem driver). Then re-write the card (or a replacement) with a fresh Raspbian Stretch system, using Etcher to write it.
Location: 345th cell on the right of the 210th row of L2 cache

avieln
Posts: 6
Joined: Tue Aug 21, 2018 10:16 pm

Re: bash: sudo command not found

Wed Aug 22, 2018 2:01 pm

in this case again no escape from reformatting and starting over then

oldjake
Posts: 90
Joined: Fri Aug 03, 2018 12:39 pm

Re: bash: sudo command not found

Fri Aug 24, 2018 7:48 pm

davidcoton wrote:
Wed Aug 22, 2018 1:58 pm
oldjake wrote:
Wed Aug 22, 2018 1:51 pm
pass is default
That worries me. Really default?

Last time I forgot to change the default password, I think it took about 2 hours for my Pi to get taken over for BC mining.
Why should that worry you? OP says there are no ports open, so external hacks are not likely.
Apart from port 22 with a default username and password. I guess it would also need port forwarding on the router to be really dangerous but are you really advocating *not* changing the default password when just about every piece of advice is that you should change it?

User avatar
davidcoton
Posts: 5360
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: bash: sudo command not found

Fri Aug 24, 2018 9:30 pm

Yes, without port forwarding it is not a major risk. If your network is compomised elsewhere, it may make it easier for someone to wreck the Pi.
AIUI the standard advice applies to the situation where you are trying to provide external access, when such security advice is absolutely essential -- use a non-standard pot (externally), lock the Pi account and don't use an easy password.
I believe there are alternative secure logon arrangements for ssh which avoid the need for a password which are strongly recommended.
Location: 345th cell on the right of the 210th row of L2 cache

Return to “Troubleshooting”