How do I get my shell prompt back after using Gedit from the terminal?
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.
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
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
The shell is waiting for gedit to return. If you want to tell the shell to not wait at this point you can ctrl + z to background gedit (which "freezes it), to "unfreeze" gedit, you'd have to run the command "fg" on the prompt you just got back.
In the future you can also launch programs without waiting for them to return, by running "command &". For example, "gedit /etc/apt/sources.list &", will get you gedit without monopolizing your shell.