For running long lasting processes, I use screen, or byobu if you want a more friendly interface.
For screen, you can use:
screen [program] [args]
This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.
To re-attach to a previous session:
screen -r
If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.
Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:
- F2 start a new session
- F3 move to the next session tab on the left
- F4 move to the next session tab on the right
- F8 give a friendly name to the current session tab
- F9 opens a options menu
- CTRL+A+D detaches all sessions from the terminal.
WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.
apt-getprocess was still running. It should have died along with the whole process chain up to SSH. I've noticed thatdo-dist-upgradeautomatically starts in ascreen/byobusession: maybe in some circumstances,apt-getdoes the same? – nfirvine Oct 2 '12 at 17:41