Score:0

can not sudo to root in Ubuntu instance

nr flag

I have an error when i want to become root

╭─saviam@server ~ 
╰─$ sudo -i                                                                                                                                                                                           
   sudo: myPassword*: command not found
╭─saviam@server ~ 
╰─$                                                                                                                                                                                                    
vidarlo avatar
ar flag
What's the content of `/etc/passwd`? Does `sudo /bin/bash` work?
Romeo Ninov avatar
in flag
Do `sudo su -` work?
Score:1
pn flag
VGS

The error sudo: myPassword*: command not found can occur due to 2 different reasons:

  1. The PATH variable for user does not contains the path to sudo binary.
  2. sudo package was mistakenly removed from the server.

Solution for reason 1:

  • Check for the absolute path for sudo binary using command find /usr/bin/ /bin/ /usr/local/bin/ /sbin/ -type f -name sudo
  • You can use the the absolute path to run the sudo command, like /usr/bin/sudo -i , However this is temporary fix.
  • As a permanent fix, you need to add the absolute path of the sudo binary to user saviam's PATH variable.
  • Run command echo 'PATH="sudo_absolute_path:$PATH"' >> ~/.bashrc replacing sudo_absolute_path with actual path to sudo binary. It should be like /usr/bin or /bin etc.

Solution for reason 2:

  • If sudo package is missing from the server, you will need to install the package back.
  • For this, you will need to login with user root and install the package.
nightWolf avatar
nr flag
Thanks. The sudo binary path was missing from `PATH` variable. The solution worked.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.