Multiple sessions with single console in linux?
Say I have only a single console, is it possible to simulate multiple consoles/sessions?
I'm looking for a linux command/method, not ubuntu/debian specific.
#console1
$ ..
#console2
$ console_switch 2
$ ..
#console1 again
$ console_switch 1
$ ..
Anything even like this available, even as a package?
Found package 'screen', but output isn't maintained between switching.
Solution 1:
The tmux
and screen
terminal multiplexers are popular for this. It is possible to see several windows at the same time by splitting vertically/horizontally; for example, Ctrl-B "
in tmux. There is even possibility to copy & paste text between windows.
The Emacs editor allows running interactive shells in its multiple buffers – again, with multiple buffers on screen, and with copy/paste between them. So does Vim (using the ":terminal
" command) and a similar but not quite identical feature exists in Neovim. (In my tests 5 years ago, Neovim's :terminal worked quite well, while Emacs' terminal emulation seemed rather lacking.)
A simpler alternative to tmux/screen is dtach
, which does not perform full terminal emulation but only allows detaching/reattaching, so the previous output remains. (However, this also means that detaching inside a full-screen program will not work well.)
The Heirloom toolchest appears to provide a version of shl
, "shell layers" which were present in Unix SVR3 (and died soon after, but still linger in stty swtch
). I can't get the toolchest to build at all, however, and I'm not sure the modern Linux kernels have the necessary support for shl
. If it worked, though, it would be almost exactly like in your example.
Finally, you can have multiple shell processes running as jobs:
$ bash
$ suspend
$ bash
$ suspend
$ jobs
[1]- Stopped bash
[2]+ Stopped bash
Solution 2:
In GNU Screen you can:
- split window with Ctrl+A,Shift+S,
- switch to the new split with Ctrl+A,Tab,
- open new screen with Ctrl+A,C,
- repeat.
Additionally to close current split press Ctrl+A,Shift+X.
Solution 3:
GNU Screen, tmux, and probably many many more. The term that you're looking for is terminal multiplexer I think.
Solution 4:
Not sure it's exactly what you're looking for, but screen / byobu seems similar. You don't switch with a command, but with a emacs-style key combo. If your distro has it as a package, I'd suggest byobu.
Edit: Byobu is a usability layer built on top of screen. As far as I know, their's not much that either can do that the other can't, but byobu often makes it much easier.