Is it possible to do this? For example if I run "gedit tifatul.txt" via the command line, my terminal becomes blocked and I can't enter other command in this terminal before I quit gedit. Can I start a program (like gedit) without blocking the terminal? In windows I think this can be done like "start notepad tifatul.txt"
Asked
Active
Viewed 1.1e+01k times
59
TifatulS
- 1,265
- 3
- 12
- 13
-
What do you mean by blocked. – Apr 28 '13 at 15:32
-
@PedroDiniz meaning I can't type another command to the terminal while gedit is running. If you have windows, try the difference between running `notepad` (blocked) and `start notepad` (not blocked) – TifatulS Apr 28 '13 at 15:33
2 Answers
79
Just add & at the end of the command. This makes the new process to run in background and you can continue using your terminal. For example: gedit new_file.txt &
Daniel Yuste Aroca
- 1,611
- 2
- 16
- 18
-
By the way, do you know any documentation regarding this behaviour? Is it only for gedit? – TifatulS Apr 28 '13 at 15:38
-
1This feature of background process is provided by the shell, so it is not working only for gedit but for any command you run on shell. – Daniel Yuste Aroca Apr 28 '13 at 15:53
-
yeah, thanks for the answer. I was gonna accept but the system requires me to wait another couple of minutes – TifatulS Apr 28 '13 at 16:01
-
-
This feature is called running processes in background or running background processes. – Daniel Yuste Aroca Apr 28 '13 at 16:09
-
Any way to spawn a new process in a way that it can't output to the console? For instance, `nautilus . &` keeps sending various warnings and outputs to the console. **EDIT:** `exec nautilus . &` seems to work. **EDIT 2:** No it doesn't. :( **EDIT 3:** Oh it does. You just hit `Ctrl+C` to get out of the infinite block, but the program doesn't get killed. – Mateen Ulhaq May 17 '17 at 19:48
-
-
1Please add the warning of what happens if you close your terminal. – Jason Doucette Apr 03 '21 at 18:52
26
I would like to recommend you nohup gedit filename &. Simply gedit filename &, you're bearing the risk to accidentally close the terminal and lose your edit. If you don't like nohup.out being created each time, just redirect the output:
nohup gedit filename > /dev/null &
frozen-flame
- 451
- 2
- 6
- 9
-
What about this format nohup gedit filename > /dev/null 2>&1 & I saw it recommended in an archive from 2009 https://ubuntuforums.org/archive/index.php/t-1345506.html – Kevin Muhuri Aug 17 '20 at 12:46