Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The script below get's executed differently if run as a root user.


gnome-terminal -x sleep 10 
echo 'Why must I wait for sleep to finish?'

If its run as a regular user, message is printed alongside of the newly opened terminal that waits 5 seconds.

If run as a root user, the message isn't printed until the first command doesn't end.

System details:

  • Ubuntu 12.4
  • whereis gnome-terminal is the same for root and standard user

What is the explanation for such behavior?

share|improve this question
I was just investigating this behavior of the script. Interestingly, I found from the root terminal, I can execute the command gnome-terminal . However, if I login as a normal user and try to execute the command gnome-terminal, I get the error, Xlib: connection to ":0.0" refused by server Xlib: No protocol specified So, it seems like the script is trying to execute something as a non-authorized user and so we are getting different behavior. – Ramesh Mar 7 '14 at 17:31
@Ramesh sounds like your X server was started by root, I don't think that is the same behavior as the OP. – terdon Mar 7 '14 at 17:32
I can't reproduce this. What OS are you using? – terdon Mar 7 '14 at 17:34
the missing ' at the end of echo is here and not in the script? – Olivier Dulac Mar 7 '14 at 18:01

I can't reproduce this. Both as regular user and with sudo, the message is printed as soon as the gnome-terminal appears. Apparently, gnome-terminal is backgrounded automatically (you can see by running gnome-terminal directly from the command line), so the message is printed before the sleep command is finished. It is equivalent to running

gnome-terminal -x sleep 10 &

If you are really seing a different behavior when run as root, you might have a different gnome-terminal in root's $PATH.

share|improve this answer

When you run script as user, you already have one gnome-terminal window. If you tried to open second gnome-terminal window, it sends info to first and selfcloses (the same situation with Firefox, Chromium). When you run script as superuser, superuser have not gnome-terminal windows.

Try to close all gnome-terminal windows and run "gksu gnome-terminal". The script will behave same as user.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.