PDA

View Full Version : GUI App for the SU command in Linux


TheShaner
08-23-2007, 10:01 PM
Hey all,

I'm looking for a GUI application that I can use to su to root while running Xfce (like a RunAs that Windows has). I don't want to have to open up a terminal just to use the su command on an app or file.

So if anyone knows of one, I'd appreciate it. That or a way to pass a password to the su command. I have a bash script that I tries to open files locked to root while running on another user. This other user is an admin account that was created to stay away from working as root, so that's why it's ok to have this script opening up these files.

So far I have:
#!/bin/bash

# su to root on the file specified
su -c "mousepad $1" root
It works great on command line since I can then just type in the password, but if I open up a file using the script (non-terminal use), I don't get any prompt for password. I tried piping the password in with an echo and it actually puts the password there but it doesn't register and fails.

-Shane

slushy77
08-25-2007, 01:07 AM
modify your script so that all references to su are removed e.g if your original script looked like this
#!/bin/bash

# run as root
su -c ls -l |& tee -a ls.log
, your modified script will look like


#!/bin/bash
#filename: myWonderfulScript.sh
#this script must be run as root
ls -l |& tee -a ls.log
then simply use the following to run the command
from the command line
sudo myWonderfulScript.shThis is far safer than using su as it uses the user's password instead of root's, and you only have to enter a password once. You will need to make sure sudo is installed and you might need to modify the sudoers file. if you really need to use a GUI to access su / sudo then you could install either gksu & gksudo or kdesu and use these to run your modified scripts. Remember to check the man pages for these commands as they are dangerous

ralph l mayo
08-25-2007, 08:01 AM
gksudo is a gui wrapper for sudo and su. gksudo <command> escalates to root and gksudo -u <user> <command> runs as other unprivileged users.

TheShaner
08-27-2007, 04:25 PM
Hey guys, thanks to both of you! After first installing sudo, I got gksu/gksudo working perfect after configuring sudoers. That's exactly what I was looking for.

-Shane