It is a home computer with only one user.

These commands have been used:

chown root:root /usr/bin/apt-get    
chmod 4775 /usr/bin/apt-get

How to reverse the commands and restore defaults?


Remove the dangerous setuid bit

sudo chmod 755 /usr/bin/apt-get

Nothing else is wrong.

To add a little more detail, here are the defaults:

$ stat -c '%a %A %U %G' /usr/bin/apt-get
755 -rwxr-xr-x root root

The command mentioned in the question added the setuid bit, shown as a leading 4 in octal permissions and an s in place of the x for owner in the human-readable form:

4755 -rwsr-xr-x

The setuid bit allows the user executing the program to do so with the EUID of its owner. In this case, it means the normal user running apt-get does so as root by default. Since apt-get is capable of completely destroying your system, as pointed out in comments by David Foerster and cat, giving it this permission setting (especially since the execute bit for others is set, as it is in this case, allowing literally any user to run the program) is extremely insecure.

The setuid bit, always kept to a minimum, is present by necessity on the sudo program

$ stat -c '%a %A %U %G' /usr/bin/sudo
4755 -rwsr-xr-x root root

To make this more secure, there is a strict policy about who may use sudo, configured in /etc/sudoers. If that file is corrupted or is not present, or if the permissions of sudo are wrong, sudo exits with errors.

  • 2
    apt-get autoremove --force-yes ubuntu-minimal for regular users. Yay! – David Foerster Jun 9 '17 at 20:41
  • 2
    one might add that the setuid bit is particularly more dangerous on apt than eg grep, ls etc because packages can contain installation triggers, arbitrary external scripts that run at various points during the dpkg child-process of apt – cat Jun 9 '17 at 21:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.