I am new to Linux and using Terminal. If I open an application within terminal, I noticed that it renders my terminal session to be unusable and I can't enter any more commands.The Terminal session is focused on the task of running the application only. Is there a way to bypass this or do I just have to wait until I end my session with the process.
-
...And a bunch of others – Jacob Vlijm Mar 31 '15 at 13:53
-
@JacobVlijm: What is the "canonical" answer to this question, to which all dupes should refer? – krlmlr Mar 31 '15 at 14:38
-
@krlmlr It is one of these subjects that pass by on a regular base (in different variants). I already mentioned http://askubuntu.com/questions/106351/running-programs-in-the-background-from-terminal. A quick search also gives http://askubuntu.com/questions/319843/i-cant-use-the-terminal-while-gedit-command-is-running, http://askubuntu.com/questions/331451/how-do-i-run-an-application-with-arguments-from-the-command-line-without-losing. I also remember an extensive answer on the subject by KasiyA (couldn't find it in a quick search). Looking on StackOverflow, there are many more on the subject. – Jacob Vlijm Mar 31 '15 at 16:46
3 Answers
Use disown
command:
gedit & disown
This way launched process is disconnected from the terminal it was launched in.

- 337
-
Is that tha same as
nohup gedit &
or is there some difference? – Tulains Córdova Mar 31 '15 at 15:58 -
Effect is similar, but when
nohup
is used, one wouldn't be able to sendSIGHUP
signal (e.g. usingkill
command) to the process. Note, however, that process may change it's behavior regarding signals itself.From
– andrybak Mar 31 '15 at 18:02man nohup
: "nohup
- run a command immune to hangups ...". Fromman bash
: "Before exiting, an interactive shell resends theSIGHUP
to all jobs [...] To prevent the shell from sending the signal to a particular job, it should be removed from the jobs table with thedisown
builtin or marked to not receiveSIGHUP
usingdisown -h
."
There are a number of ways that you can continue working.
If you opened a gnome-terminal via CTRL-ALT-T you can choose File from the top menu bar and then choose to open a new tab or a new terminal window via the menu or with the shortcut keys with SHIFT-CTRL-T or SHIFT-CTRL-N respectively(while gnome-terminal has focus).
If you've opened a terminal session with CTRL-ALT-F1, you can switch to another with CTRL-ALT-F2 through F6.
Another option is to background the task as you launch it by placing an & at the end of the command for example dd if=infile of=outfile &
. you can string commands by putting a double ampersand between them. ls /home > dir.file && du /home/Downloads
for example.
Of course placing processes in the background requires a way of handling background tasks. the fg PID
command allows you to bring a process to the foreground. you can obtain the PID with the jobs
command more information on handling background tasks can be found here
you can also use nohup and disown as mentioned in the other good answers here. Differences between these approaches are discussed here

- 36,023
- 25
- 98
- 183
-
Note that to background a command, you need to add a single ampersand (
&
) to the end of it. – terdon Mar 31 '15 at 13:30
nohup command &
will do the trick. You will get just one message in terminal , hit Enter and continue using terminal as before.

- 105,154
- 20
- 279
- 497
-
Be aware that
nohup
creates anohup.out
file in current directory. – Beni Cherniavsky-Paskin Mar 31 '15 at 14:51 -
Yup, i know. That doesn't have any disadvantage, does it ? – Sergiy Kolodyazhnyy Mar 31 '15 at 15:51
-
Nothing beyond littering the filesystem if you use it regularly from various directories. I mainly felt it's worth mentioning to avoid surprises. But it tells the users it writes there, so won't really be surprising. – Beni Cherniavsky-Paskin Mar 31 '15 at 16:59