Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easily run X11 apps that require root UNIX

Some X11 applications need to be run as root or sudo-ed. For example, ethereal needs to be run as root, otherwise you won't get proper access to the network interfaces to sniff the traffic.

I was looking for a way to not have to open a shell, type sudo ethereal &, then close the shell each time I wanted to use the program. Instead, why couldn't it be as easy as setting up a shortcut in X11's Applications menu? If you try that (go to Applications -> Customize -> Add Item) and enter sudo ethereal as the command, it doesn't work. Probably because there is no window in which the password request can get displayed.

Here is the solution: instead, enter this as the command:

xterm -geometry 40x4 -e "sudo /sw/bin/ethereal"
What this does is open a small (40 by 4 character) xterm window, which then launches sudo. The result is that the small xterm window shows the password request, you enter it, then etheral launches. As an added bonus, when you close down ethereal, the xterm window closes as well.

    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[9,842 views]  

Easily run X11 apps that require root | 5 comments | Create New Account
Click here to return to the 'Easily run X11 apps that require root' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easily run X11 apps that require root
Authored by: timkingman on Feb 12, '04 11:38:37AM
Simply adding "sudo ethereal" to the Applications menu works fine for me, but that's because I have sudo set up to not prompt me for my password. Since we all know this is a grave security risk, you can have sudo not prompt for your password only when running Ethereal by adding this line to the end of /etc/sudoers :
yourusername  ALL=(root) NOPASSWD:/path/to/ethereal
replacing "yourusername" with your user name and "/path/to/etheral" with the full path to ethereal. (Mine is /opt/local/bin/ethereal from darwinports, find yours by running "which ethereal" at a command prompt.)

[ Reply to This | # ]
Easily run X11 apps that require root
Authored by: glusk on Feb 12, '04 12:30:09PM
Here's one:

tell application "X11" to activate

set results to do shell script "cd ~; DISPLAY=:0.0; export DISPLAY; PATH=$PATH:/usr/local/bin;  export PATH ; sudo /sw/bin/ethereal > /dev/null 2>&1 &" with administrator privileges


[ Reply to This | # ]
Easily run X11 apps that require root
Authored by: bitwiseshiftleft on Feb 12, '04 03:08:22PM
The designers of sudo knew this was annoying, so they provided an option.
sudo -b ethereal
runs it in the background

[ Reply to This | # ]
Easily run X11 apps that require root
Authored by: aranor on Feb 13, '04 11:22:36AM

Well, yeah, but you still have to open a terminal window for that. And if you stick -b into the line posted in this hint, it doesn't work, since the parent xterm process will close down after the sudo -b executes, and ethereal will be closed down with it.



[ Reply to This | # ]
Easily run X11 apps that require root
Authored by: Anonymous on Feb 14, '04 02:13:43AM

following will get rid of xterm window after entering password

xterm -geometry 40x4 -e "sudo ls"; sudo ethereal

you can replace 'ls' w/ anything that does something and quit.



[ Reply to This | # ]