Easily run X11 apps that require root

Feb 12, '04 10:45:12AM

Contributed by: Greedo

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.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040206143212371