gksudo and sudo not working

Asked by Jonas Lagerwall

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:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

can you give the output of:

lsb_release -a; uname -a; echo $PATH

Thanks

Revision history for this message
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

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

and the output of:

apt-cache policy sudo

Thanks

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

and:

ls -la /usr/bin/sudo

Thanks

Revision history for this message
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.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#6

Have you been messing with permissions at all?

Revision history for this message
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

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#8

And the output of:

groups

Thanks

Revision history for this message
Jonas Lagerwall (1-jonaz-k) said :
#9

jonas adm cdrom sudo dip plugdev lpadmin sambashare

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#10

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

Revision history for this message
Jonas Lagerwall (1-jonaz-k) said :
#11

how do i boot to root recovery mode?

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#12

Hold shift at boot, select recovery mode and select root

Revision history for this message
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"?

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#14

What is the output of:

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

Thanks

Revision history for this message
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.