Ubuntu Unplugged Banner Image
April 16, 2013

Ubuntu Unplugged

We recently have started using Ubuntu as our preferred desktop OS – and we simply regretted not having left the Windows world earlier. Though some of us are undying Apple fans – we still had to accept the fact that Ubuntu was a pleasant surprise to the existing non Apple users / developers at our office.

Having said this – we didn’t have enough time to train all our developers on the system and simply asked them to test the waters themselves. As developers and users of Linux – we hoped the learning curve would be simple. As they say ignorance is bliss one of our early users was trying to setup Python / DJango on the system when accidentally he did :

chmod –R 777 /usr/bin
and voila “sudo” simply stopped working.It kept throwing an error saying that sudo must be setuid root.

Solution: Most files in /usr/bin should have 755, but some require the setuid bit set. /usr/bin/sudo is one such command After some research we realized the problem was the wrong file permissions. Setting the right permissions was simply not possible without the help of sudo.

Steps we followed to reset the permissions were :

  • Shutdown the computer
  • Boot into Recovery Mode –After BIOS load, hold down Shift key to access the grub menu –Once in grub menu, select the entry ending in “(recovery mode)”
  • From the next menu selected option to enter Root Session
  • At the root session, execute command mount -o remount,rw / to remount the filesystem as read-write
  • Following commands were executed
    • mount –o remount,rw /
    • chmod 4755 /usr/bin/sudo
    • chmod 0440 /etc/sudoers
    • chmod u+s /usr/bin/sudo
    • shutdown –r now
    • After booting back in normal mode “sudo” started working well !

Lesson learnt : NEVER change the permissions of system folders away from root*.

Information for new learners
What exactly is sudo ??
When working with terminals (Applications → Accessories → Terminal), any command can be run as an administrator by typing sudo before it. The /etc/sudoers file controls who can run what commands as what users on what machines and can also control special things such as whether you need a password for particular commands.