Hi guys,
I have a very big problem, after I use a chmod command I have a problem with sudo.
Error message is: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set.
How can I solve it without reinstall raspbian or with reinstall but without lose all program?
Please, anyone could help me? I'm hopeless..
Re: Sudo problem (Raspbian)
We can't tell what else might be wrong.
It will be simplest to reinstall from scratch.
It will be simplest to reinstall from scratch.
Re: Sudo problem (Raspbian)
Well the command to set the set uid bit would be chmod u+s /usr/bin/sudo (think so anyway). But it won't let you do that unless you are root or can use sudo.
Can you get a root shell? then chmod u+s /usr/bin/sudo
Otherwise maybe mount your sd card in an sd reader on another Linux machine
Can you get a root shell?
Code: Select all
su -
Otherwise maybe mount your sd card in an sd reader on another Linux machine
Re: Sudo problem (Raspbian)
With comand su - ask me the password, I put "raspberry" becouse I have only one user (user: pi password: raspberry) but terminel reply me autentication failed.
I can reinstall OS but I would like to keep all program. If it's only method how can I do?
I can reinstall OS but I would like to keep all program. If it's only method how can I do?
- DougieLawson
- Posts: 40569
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Sudo problem (Raspbian)
If you can get to a root shell by adding init=/bin/bash to /boot/cmdline.txt
becomes
You should be able to do that with the NOOBS config editor. Hold [SHIFT] during boot.
If your card has plain Jessie (not NOOBS) insert it in a Windows system and edit cmdline.txt using Notepad++
Boot that and you've got a root shell which you can use to completely destroy your system (if you're not careful) or fix it if you pay attention to what you're doing.
Code: Select all
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Code: Select all
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash
You should be able to do that with the NOOBS config editor. Hold [SHIFT] during boot.
If your card has plain Jessie (not NOOBS) insert it in a Windows system and edit cmdline.txt using Notepad++
Boot that and you've got a root shell which you can use to completely destroy your system (if you're not careful) or fix it if you pay attention to what you're doing.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Sudo problem (Raspbian)
I try to add to cmdline.txt "init=/bin/bash" but the problem persist 

Re: Sudo problem (Raspbian)
How can I reinstall raspbian without lose my program?
Re: Sudo problem (Raspbian)
You don't. Did you not create a backup image or clone?Vairetz wrote:How can I reinstall raspbian without lose my program?
- DougieLawson
- Posts: 40569
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Sudo problem (Raspbian)
Get a brand new SDCard and a USB reader.
Build a rescue system on the new card. Mount the rubbished card in the reader, mount the reader in the RPi (booted from the rescue system). The GUI will automount the filessystems on there. Collect any valuable data and programs from the rubbished card. Count it as a hard lesson learned.
You can use that old card later as a system backup using the rpi-clone tool.
Always use sudo visudo to edit the /etc/sudoers file. Don't remove the last non-root user unless you can login as root (with PuTTY and a public/private key pair).
Build a rescue system on the new card. Mount the rubbished card in the reader, mount the reader in the RPi (booted from the rescue system). The GUI will automount the filessystems on there. Collect any valuable data and programs from the rubbished card. Count it as a hard lesson learned.
You can use that old card later as a system backup using the rpi-clone tool.
Always use sudo visudo to edit the /etc/sudoers file. Don't remove the last non-root user unless you can login as root (with PuTTY and a public/private key pair).
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Sudo problem (Raspbian)
Is it not an option to use visudo
Then set the root password
Code: Select all
visudo paswd root
- DougieLawson
- Posts: 40569
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Sudo problem (Raspbian)
visudo is used to edit the sudoers file (nothing more, nothing less). It checks for syntax errors before it saves the file, so you have a chance to avoid a smoking weapon and a large void in your foot.nl3prc wrote:Is it not an option to use visudoThen set the root passwordCode: Select all
visudo paswd root
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Sudo problem (Raspbian)
Ok, thank you very much
Now I'm reinstalling Raspbian OS and I promise that I create a backup before launchig inito crazy experiments
Now I'm reinstalling Raspbian OS and I promise that I create a backup before launchig inito crazy experiments

Re: Sudo problem (Raspbian)
Than the best way is to make a new sdcard with rasbian and then put the old card in a card reader and set the chown to root so you can then boot from the old card and use sudo again
- DougieLawson
- Posts: 40569
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Sudo problem (Raspbian)
There's an echo in here.nl3prc wrote:Than the best way is to make a new sdcard with rasbian and then put the old card in a card reader and set the chown to root so you can then boot from the old card and use sudo again
viewtopic.php?p=1039227#p1039227
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Sudo problem (Raspbian)
when the new system hase boot up do sudo passwd root to set the root pasword
enter su -
and than loggin as root with the password you just made
cd into your old system proberly it is in /media/pi/root/usr/bin
and enter chown root:root ./sudo
now you have set it back to root user
enter su -
and than loggin as root with the password you just made
cd into your old system proberly it is in /media/pi/root/usr/bin
and enter chown root:root ./sudo
now you have set it back to root user
Re: Sudo problem (Raspbian)
You saved my day
Just add a minor point: After adding this parameter, Raspbian will boot with the file system mounted as Read-Only, execute the following command to mount it as Read-Write:

Just add a minor point: After adding this parameter, Raspbian will boot with the file system mounted as Read-Only, execute the following command to mount it as Read-Write:
Code: Select all
mount -o remount,rw /
DougieLawson wrote: ↑Sat Sep 17, 2016 6:57 pmIf you can get to a root shell by adding init=/bin/bash to /boot/cmdline.txt
becomesCode: Select all
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Code: Select all
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash
You should be able to do that with the NOOBS config editor. Hold [SHIFT] during boot.
If your card has plain Jessie (not NOOBS) insert it in a Windows system and edit cmdline.txt using Notepad++
Boot that and you've got a root shell which you can use to completely destroy your system (if you're not careful) or fix it if you pay attention to what you're doing.
- DougieLawson
- Posts: 40569
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Sudo problem (Raspbian)
There are better things to add to /boot/cmdline.txt for systems running with systemd.
https://freedesktop.org/wiki/Software/s ... Debugging/
or
https://freedesktop.org/wiki/Software/s ... Debugging/
Code: Select all
systemd.unit=emergency.target
Code: Select all
systemd.unit=rescue.target
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 3
- Joined: Mon Dec 31, 2018 9:45 am
Re: Sudo problem (Raspbian)
Hey guys,
after searching around a multitude number of forums and websites, I found a solution for this issue:
First you must hold the "Shift" key on Raspberry boot to get into NOOBS recovery section of the Raspberry
then you should add the following command at the end of the "cmdline.txt" :
(do not remove or change any parts of the current commands in cmdline.txt at all)
click on Exit and let the raspberry getting restarted. Then you'll see the root shell but you can't still set a password for "root", because the directory of root config is in Read-only state. so you should firstly use the bellow command to mount and remount the OS Storage to renew write permission:
Now you can set a password for the root, using this command:
After setting a password for "root", Restart the raspberry, enter into Recovery mode again and remove the added command (init=/bin/bash) from "cmdline.txt", Exit and restart the Raspberry.
After loading the OS, open the command line and type "SU" to get root access. now enter the password you've set for root user. after getting root access, enter the following commands to restore the corrupt "SUDO" permissions:
it's done
after searching around a multitude number of forums and websites, I found a solution for this issue:
First you must hold the "Shift" key on Raspberry boot to get into NOOBS recovery section of the Raspberry
then you should add the following command at the end of the "cmdline.txt" :
Code: Select all
init=/bin/bash
click on Exit and let the raspberry getting restarted. Then you'll see the root shell but you can't still set a password for "root", because the directory of root config is in Read-only state. so you should firstly use the bellow command to mount and remount the OS Storage to renew write permission:
Code: Select all
mount -o remount,rw /dev/mmcblk0p7/
Code: Select all
mount /dev/mmcblk0p7/boot
Code: Select all
sudo passwd root
After loading the OS, open the command line and type "SU" to get root access. now enter the password you've set for root user. after getting root access, enter the following commands to restore the corrupt "SUDO" permissions:
Code: Select all
chown -R root:root /usr
Code: Select all
chmod 4755 /usr/bin/sudo
(you can use -R to set permissions recursively for all files and folders).
it's done
