Method 1:
To run the "df -h" command as root:
su -c "df -h"
This will prompt the user for root password.
Method 2:
Alternatively, in /etc/sudoers find this line:
root ALL=(ALL) ALL
and duplicate it for your user johnsmith that you want to give admin privileges:
johnsmith ALL=(ALL) ALL
This way, johnsmith will be able to run any command requiring root rights, by first typing "sudo" in front of the command:
sudo df -h
Method 3:
You can use ssh to execute a command on the same machine:
ssh root@localhost "def -h"
will execute the same command in your server. If you don't want to be prompted for password, follow this tutorial for passwordless ssh:
http://linuxproblem.org/art_9.html
Method 4:
Use gksudo (graphical sudo):
gksudo "gnome-open %u"
Or, on KDE kdesu
:
kdesu <command>