Ubuntu – How to get the shell prompt back after using Gedit from the terminal

command line

I'm trying to update my APT sources list in terminal by using gedit. My question is once I reach this point I need the command prompt "root@bt:/ect/apt#" back. the line is just blank. How do I recall this line of code?

root@bt:~# cd
root@bt:~# cd /etc/apt/
root@bt:/etc/apt# ls
apt.conf.d     sources.list     sources.list.d     trusted.gpg
preferences.d  sources.list~    sources.list.save  trusted.gpg~
secring.gpg    sources.list.bt  trustdb.gpg        trusted.gpg.d
root@bt:/etc/apt# gedit sources.list

I have tried googling this and I also checked the help file and I cant find anything on this. Any help would be appreciated.

Best Answer

If you append a & at the end of the line for example

gedit somefile &

Then you are editing somefile but gedit is running in the background so you get your command prompt back before you close gedit

terminal image

you will notice that a number is returned in this case 2388. That's the taskID of the instance of gedit that is running.

If you close the terminal you will kill the running gedit as its a child process of the terminal so you need to keep the terminal open until you have finished editing but you can run other commands.

If you want to close the terminal however you can break the link using the disown command with the number that was returned. In this case

disown 2388

You can now close the terminal if you wish and gedit will keep running.

Note: this does not only apply to gedit it works with all programs regardless as to if they have a GUI or not