I screwed something and my system

Oops ! I’m ashamed and not lucid anymore : help appreciated

➜  Bureau sudo fdisk -l

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
➜  Bureau 

I screwed something before : don’t lecture as I know I was out of my brain.

6104  topgrade
 6105  ls -l /usr/bin/nopt\n
 6106  sudo chown -R $USER:$USER /usr/lib/node_modules\n
 6107  npm cache clean --force
 6108  topgrade
 6109  sudo chown -R $USER:$USER /usr/bin\n
 6110  cd nam
 6111  ls
 6112  ls -a
 6113  sudo chown root:root /usr\n
 6114  sudo chown -R root:root /usr/lib/node_modules\n
 6115  chown root:root sudo\nchmod 4755 sudo\n
 6116  cd /usr/bin
 6117  chown root:root sudo\nchmod 4755 sudo\n
 6118  lsblk
 6119  sudo blkid /dev/nvme0n1p5\n
 6120  cd...
 6121  cd
 6122  topgrade
 6123  sudo chown root:root /usr/bin/sudo
 6124  su -
 6125  pamac update
 6126  sudo pacman -Syu
 6127  chmod 4755 /usr/bin/sudo
 6128  sudo chmod 4755 /usr/bin/sudo
 6129  history
 6130  sudo chown -R root:root /usr/lib/node_modules
 6131  su -
 6132  ls -l /bin/su\nchmod u+s /bin/su\n
 6133  sudo chmod u+s /bin/su\n
 6134  sudo lsattr /bin/su\nsudo chattr -i /bin/su\n
 6135  cd Bureau
 6136  pacman -Qqe > installed_packages.txt\n
 6137  lsblk
 6138  sudo fdisk -l\n
 6139  cd 
➜  ~ 

You changed quite a bit, not sure what the consequences are.
But to fix sudo:
chmod u+s /usr/bin/sudo

after you somehow gain root access
perhaps through su or by accessing the system from the outside (USB boot)

1 Like

chroot is your friend!

1 Like

It’ll work - but is not needed to alter the setuid bit on one binary. :man_shrugging:
su root
is likely all that is needed
or just log in from a TTY as root (if possible, if that is enabled)

1 Like

True. Then a live environment, probably. Or the emergency shell.

And if Timeshift has a friendly day, it will help you undo everything

1 Like

Timeshift is your more aggressive friend.

Thanks all.
The issue is I don’t use timeshift, but Vorta on /home :confused:
and even with chroot from a live, I can chown root:root /usr/bin/sudo
But chmod 4755 /usr/bin/sudo brings me again /usr/bin/sudo must be owned by uid 0 and have the setuid bit set



so: this doesn’t work?:

su root



which both should result in confirming that you are root

chmod u+s /usr/bin/sudo

It should definitely be possible to access the system by booting a live USB and mounting the / partition and then
change to root (through sudo for example) and then target the file via it’s PATH

chmod u+s /run/media/some_name/usr/bin/sudo
as an example.

It would be weird if that would not work.

Apparently you did try to set the immutable attribute on su (via the already defunct sudo command)
Not sure whether that is a good idea - but root can always re-set it or simply ignore it.
… if it succeeded at all …

1 Like

Thank you all !
I could partially recover with

sudo mount /dev/my_root_disk /mnt
sudo mount /dev/my_home_disk /mnt/home
sudo manjaro-chroot /mnt
cd /usr/bin
chown root:root sudo
chmod 4755 sudo
sudo umount -R :mnt
sudo reboot

But system was too screwed… I couldn’t use appimages, nor flatpak…
Thus I do reinstall and… suffer a lot as my install was quite complex.

I’ll create a new thread to see how to have the best possible backup to save recovery time ! :sweat_smile:

Previously there were only different levels of backup (only configuration, only data, entire home, entire disk, disaster recovery…)

There are now also file systems that support snapshots. While this is no substitute for a good backup strategy, in your case (and countless others) a rollback to a previous snapshot would be completely successful. (The disk wasn’t broken)

A rollback can be done in a few minutes (faster than you find your backups)

You should familiarize yourself with the following topics:

  • File systems that can take snapshots (like btrfs)

  • Utilities that automatically create snapshots (hourly, daily, weekly, and for updates before and after) and delete old snapshots (like snapper or timeshift)

  • btrfs (You can find good Information about Btrfs in the wiki Btrfs - Manjaro)

  • timeshift (very easy to use, but inflexible)

  • snapper (more customizable, but needs some training)

1 Like