8

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.

3

3 Answers 3

8

Use disown command:

gedit & disown

This way launched process is disconnected from the terminal it was launched in.

2
  • Is that tha same as nohup gedit & or is there some difference? Mar 31, 2015 at 15:58
  • Effect is similar, but when nohup is used, one wouldn't be able to send SIGHUP signal (e.g. using kill command) to the process. Note, however, that process may change it's behavior regarding signals itself. From man nohup: "nohup - run a command immune to hangups ...". From man bash: "Before exiting, an interactive shell resends the SIGHUP to all jobs [...] To prevent the shell from sending the signal to a particular job, it should be removed from the jobs table with the disown builtin or marked to not receive SIGHUP using disown -h."
    – andrybak
    Mar 31, 2015 at 18:02
3

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

1
  • Note that to background a command, you need to add a single ampersand (&) to the end of it.
    – terdon
    Mar 31, 2015 at 13:30
1

nohup command & will do the trick. You will get just one message in terminal , hit Enter and continue using terminal as before.

3
  • Be aware that nohup creates a nohup.out file in current directory. Mar 31, 2015 at 14:51
  • Yup, i know. That doesn't have any disadvantage, does it ? Mar 31, 2015 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. Mar 31, 2015 at 16:59

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