Ubuntu

gksudo and sudo not working

Asked by Jonas Lagerwall on 2012-05-25

I did a fresh install of 12.04 and for some reason sudo and gksudo aren't working. I don't know if I messed something up.

If I try
  sudo gedit foo.txt
I get
   sudo: command not found

If I try
   gedit foo.txt
it works just fine, but then I don't have the right permissions.

Same thing with gksudo. It doesn't matter which program I call, gedit is just an example.

Please help!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu sudo Edit question
Assignee:
No assignee Edit question
Solved by:
Jonas Lagerwall
Solved:
2012-05-29
Last query:
2012-05-29
Last reply:
2012-05-28

can you give the output of:

lsb_release -a; uname -a; echo $PATH

Thanks

Jonas Lagerwall (1-jonaz-k) said : #2

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
Linux tofs-HP-Pavilion-dv5-Notebook-PC 3.2.0-24-generic-pae #39-Ubuntu SMP Mon May 21 18:54:21 UTC 2012 i686 i686 i386 GNU/Linux
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

and the output of:

apt-cache policy sudo

Thanks

and:

ls -la /usr/bin/sudo

Thanks

Jonas Lagerwall (1-jonaz-k) said : #5

First, more info. I have tested some more.

I tried
   gedit /opt/lampp/etc/httpd.conf
which worked, but the wrong permissions

I tried
   gksudo gedit /opt/lampp/etc/httpd.conf
which didn't work

Then I tried
   gksudo gedit /etc/hosts
which DID work!

So I'm guessing it may not be sudo, but something else. But I have no idea what.

Have you been messing with permissions at all?

Jonas Lagerwall (1-jonaz-k) said : #7

Now I have, and the following works:
    sudo gedit /opt/lampp/etc/httpd.conf

but this doesn't:
   gksudo gedit /opt/lampp/etc/httpd.conf

I get:
   gksudo: command not found

apt-cache policy sudo:
sudo:
  Installerad: 1.8.3p1-1ubuntu3.2
  Kandidat: 1.8.3p1-1ubuntu3.2
  Versionstabell:
 *** 1.8.3p1-1ubuntu3.2 0
        500 http://se.archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main i386 Packages
        100 /var/lib/dpkg/status
     1.8.3p1-1ubuntu3 0
        500 http://se.archive.ubuntu.com/ubuntu/ precise/main i386 Packages

ls -la /usr/bin/sudo:
-rwsr-xr-x 2 root root 69704 maj 16 07:24 /usr/bin/sudo

And the output of:

groups

Thanks

Jonas Lagerwall (1-jonaz-k) said : #9

jonas adm cdrom sudo dip plugdev lpadmin sambashare

You need to be in the admin group to use sudo etc. Boot to root recovery mode and run:

usermod -a -G admin jonas

Then reboot by running:

reboot

Should be ok

Jonas Lagerwall (1-jonaz-k) said : #11

how do i boot to root recovery mode?

Hold shift at boot, select recovery mode and select root

Jonas Lagerwall (1-jonaz-k) said : #13

It says there is no such group. :(

But why does
   gksudo gedit /etc/hosts
work, but not
   gksudo gedit /opt/lampp/etc/httpd.conf
?

I can see why it's possible for the one to work and not the other, but shouldn't I get a better error message than "command not found"?

What is the output of:

ls -la /opt/lampp/etc/httpd.conf; ls -la /etc/hosts

Thanks

Jonas Lagerwall (1-jonaz-k) said : #15

Er,

for other reasons I deleted the whole /opt/lampp directory and now gksudo works just fine. I can no longer reproduce the error. :-/

Thank you for your help and your patience.