This question already has an answer here:

I am VERY new to the world of Linux. I'm running Ubuntu 15.04 on a Lenovo laptop. My terminal emulator is Gnome Terminal.

I know a few things. Let's say I type cd Documents/terminalpractice/python_folder. I then type, for example, touch askubuntu.py. I then use the command, gedit askubuntu.py.

At this point in time the text editor gedit will open up on my screen and I am free to attempt to code as much as I like. However, in the terminal window, I guess the gedit "process" is running? So I cannot use the terminal until I close out of gedit (I save and then click the 'X' in the top corner).

Why does this happen? I can use the graphical interface to open the folders, double click on my askubuntu.py, and that will open in gedit, without affecting what is going on in the terminal. I would like to know why this happens.

marked as duplicate by Sylvain Pineau command-line Sep 17 '15 at 16:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I don't know why it happens, but putting an & afterward should return it to the prompt. – TheWanderer Sep 17 '15 at 15:58
  • You are opening gedit in the foreground, open it in the background instead. – user332471 Sep 17 '15 at 16:51

Why does this happen?

When you just run:

 gedit filename

it runs the process in foreground. To send it to the background and continue using terminal, use:

gedit filename &

Note that this (and of course the one above) will run gedit as a sub-process of your terminal, so when you exit the terminal it will also exit gedit.

So to run it 'gracefully', use:

nohup gedit >/dev/null &

nohup will run gedit detached from terminal and hence it is immune to hangups. >/dev/null redirects the stdout to a special location dev/null, thereby preventing the creation of a nohup.out file.

See man nohup and this question for more information.

  • To make the answer complete, where filename goes in the last command with nohup – Fibo Kowalsky Nov 23 '18 at 11:01

That's normal. If you run a command the terminal doesn't get another command until finished with that one. The way to execute commands as you want is to press ALT + F2 and typing the command you need.

If you do it in the terminal it won't accept another command until the instructions of the present command ends.


It's like running a text-mode program or application: it starts running and the terminal (well, not the terminal but the command interpreter) won't be available until the application finishes running. For example, run "nano" and you'll see the same behavior (the command interpreter "steps aside" while the application runs).

Just because the application (gedit) opens an additional graphical window doesn't change the underlying, basic behavior.

When you launch a command on the terminal, you can ask the command interpreter to run it in the background by using &:

gedit blahblah &

If the command is already running (with the terminal "locked up"), you can press ctrl-z (which suspends the currently-running process - note that the gedit window becomes unresponsive), then type bg (which sends the suspended process into the background).


It's because you're launching gedit from the terminal, in the foreground. Any command you run in this way will hog the command prompt until the command has completed. So when you quit the window opened by gedit, your terminal prompt works again. You can run commands in the background by putting & at the end of the command.

You can view all background commands that you've launched by using the jobs command.

You can also press Ctrl+Z to suspend the command if you've run it normally, you can then send it to the background by typing bg.

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