0

When I execute gksudo, I get some output in the terminal, I want to supress that output, but still get the output from the actual command. For example:

$ gksudo whoami
> #some gksudo related output
> root

When I try to dump the output to /dev/null like this:

$ gksudo &> /dev/null whoami

I get the prompt message without output, but the whoami result is also supressed.

2 Answers2

6

I realise this is resolved now but just picking on your comment:

I want to launch root commands from a GUI application, if there is a better way to prompt graphically for the sudo password I would like to know

pkexec is a relatively modern alternative that works slightly out of band compared to sudo/gksu. It should be available on all the Ubuntu desktops.

enter image description here

Oli
  • 299,380
3

All errors in a terminal are sent to stderr. To prevent displaying an error, you might need to redirect stderr, like this:

gksudo whoami 2> /dev/null
Eliah Kagan
  • 119,640
ob2
  • 3,653