sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700

9,063

Solution 1

Open the terminal and type:

sudo chown -R root:sudo /var/lib/sudo   
sudo chmod -R 700 /var/lib/sudo  

If sudo still does not work, you'll have to fix it from a root shell from the GRUB menu by following the instructions from: How do I add myself back as a sudo user?.

Solution 2

"Writable by non-owner" means that the current permissions of /var/lib/sudo allow either the file's group group or the file's other group to write into the directory, whilst only the owner (root) should be able to do so.

Removing the write permission for the group group and for the other group (chmod go-w /var/lib/sudo) should suffice, however since the suggested permissions are 0700, just go for those:

sudo chmod 0700 /var/lib/sudo
Share:
9,063

Related videos on Youtube

Saifullah Alam
Author by

Saifullah Alam

Updated on September 18, 2022

Comments

  • Saifullah Alam
    Saifullah Alam over 1 year

    I get error message always when I work with sudo command.

    It shows always sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700.

    A while ago I changed the permission of /var folder to 777.

    How can I fix it?

    • jlliagre
      jlliagre over 8 years
      What command did you use to change /var permissions?
    • IanC
      IanC over 7 years
      It seems like the directory /var/lib/sudo doesn't have the right permissions. On my folder the permissions for this folder are: drwxr-xr-x root:root /var/lib/sudo So you could run: sudo chown root:root /var/lib/sudo (just to make sure you have the right owner:group for the folder) and sudo chmod 755 /var/lib/sudo to fix the permissions
  • Saifullah Alam
    Saifullah Alam over 8 years
    sudo permission properties showing: owner: root group :root
  • kos
    kos over 8 years
    @SaifullahAlam Which "sudo" are you talking about? Anyway, have you tried my command? It should fix the problem.
  • Saifullah Alam
    Saifullah Alam over 8 years
    i tried your both command. firstly tried : sudo chmod 0700 /var/lib/sudo then tried sudo chmod go-w /var/lib/sudo. have i try it from root(#)?
  • kos
    kos over 8 years
    @SaifullahAlam No, just run sudo chmod 0700 /var/lib/sudo and nothing else. Then try to run sudo (for whatever purpose) again. The message should be gone.
  • Saifullah Alam
    Saifullah Alam over 8 years
    sorry for disturbing. it not works. i tried.
  • kos
    kos over 8 years
    @SaifullahAlam No problem. Please install tree by running sudo apt-get install tree and add the output of sudo tree -a /var/lib/sudo to your question, and drop me a comment here so I know that you updated your question, I think you need to fix something else as well.