I learnt some new things out of curiosity today, regarding working with multiple TTYs. Thought I’d write them down.
Firstly, multiple TTYs, why would you need them? I for once use them to keep processes running independent of my X session, things like my Wifi Hotspot, things whose output I keep on needing to inspect at times, but don’t want it to hang around inside my X session, incase I close it.
Also, when experimenting with different Desktop Environments, its actually very useful, because I can have processes running (even Music, thanks MPlayer) and yet close my X session.
Anyhow, getting down to business:
This is something you might need if you want to change your TTY from within a script. Usage goes
sudo chvt N where N is the one you want to shift to.
A utility to run a command in another TTY from the current terminal. Example:
sudo openvt /home/saksham/start_hotspot.sh
Using another TTY right inside the current one
Well, the answer happens to be SSH. You can log-in to another TTY from your current TTY with SSH. This might seem of no use, but it is very helpful with remote terminals, and obviously when you want processes in separate TTYs.
Then, now that your user’s key is set up, you can login with this
ssh -n -ttt user@localhost &. This logs your user in the next available TTY, and forks that SSH process to the background.
Using TMUX or Screen
Well, you can also have a TMUX or a Screen session running in another TTY, and send over the command you want to run there by sending it via TMUX/Screen.
This is it, try out having multiple TTYs if you ever get the need. And keep these tips in mind.