Tuesday, May 22, 2012

2 Alternatives to GNU Screen for Linux Terminal Multitasking We’ve written about using GNU Screen to multitask in the Linux terminal in the past. GNU Screen is the granddaddy of these programs, but tmux and dvtm+dtach are other solutions you may prefer. Tmux is an improved rewrite of GNU Screen. Dvtm is a console multiplexer inspired by tiling window managers, and dtach adds the ability to detach from and reattach to dvtm sessions. Tmux As a rewrite of GNU Screen, tmux offers a variety of improvements. Some of the most important include a client-server model, which allows you to connect to a tmux session from multiple locations, and a cleaner configuration file format. Check out tmux’s FAQ to discover a list of ways it differs from GNU Screen. Use this command to install tmux on Ubuntu: sudo apt-get install tmux If you’re using another distribution, you’ll likely find it in your distribution’s package manager. To launch tmux after installing it, just run the tmux command. Unlike Screen, tmux comes with a status bar by default. To open an additional terminal window, use the Mod-c keyboard shortcut. The default modifer key combination is Ctrl-b. This means that you’ll have to press Ctrl-b and then c to create a new window. Each new window you open will appear in the status bar. By default, tmux only shows one window on the screen at a time. Here are some important keyboard shortcuts to get you started: Mod-X – Kill the current terminal. Mod-n – Focus next window. Mod-p – Focus previous window. Mod-# – Focus the specified window, where # is a number between 0 and 9. Mod-’ – Prompt for a window to select. Mod-% – Split the current window into two horizontally. Mod-” – Split the current window into two vertically To detach from the current session, use the Mod-d keyboard shortcut. To reattach to a session, run the following command: tmux attach For more keyboard shortcuts, run the man tmux command or read tmux’s manual on the web. Dvtm & Dtach Unlike GNU Screen and tmux, dvtm doesn’t allow you to disconnect and reattach to sessions. You’ll have to run dvtm with dtach to detach from and reattach to your sessions. Run this command to install dvtm and dtach on Ubuntu: sudo apt-get install dvtm dtach These programs should be available in other distribution’s software repositories, too. Run the dvtm command to launch dvtm. You’ll see a single terminal window. To open additional terminal windows, use the Mod-c keyboard shortcut. The default modifier key combination is Ctrl-g. This means that you’ll need to press Ctrl-g and then c to open a new terminal window. Like a tiling window manager, dvtm will lay out the terminal windows automatically. Unlike the other utilities, it displays them all on the screen by default. Here are some important keyboard shortcuts to get you started: Mod-x – Close the current window. Mod-j – Focus next window. Mod-k – Focus previous window. Mod-# – Focus the specified window, where # is the number of the window. Mod-q - Quit dvtm. For a full list, run the man dvtm command or check out dvtm’s manual page on the web. Dvtm also supports the mouse. For example, you can click one of the windows to select it. To detach from a dvtm session and reattach to it later, you’ll have to run it with the dtach command. To launch dvtm with dtach, use the following command: dtach -c /tmp/dvtm-session -r winch dvtm To detach from a dvtm session that’s been started with dtach, use the Ctrl-\ keyboard shortcut. To reattach to your dvtm session later, use the following command: dtach -a /tmp/dvtm-session -r winch You can use dtach to run, detach from, and reattach to other applications, too.


ximage

We’ve written about using GNU Screen to multitask in the Linux terminal in the past. GNU Screen is the granddaddy of these programs, but tmux and dvtm+dtach are other solutions you may prefer.
Tmux is an improved rewrite of GNU Screen. Dvtm is a console multiplexer inspired by tiling window managers, and dtach adds the ability to detach from and reattach to dvtm sessions.

Tmux

As a rewrite of GNU Screen, tmux offers a variety of improvements. Some of the most important include a client-server model, which allows you to connect to a tmux session from multiple locations, and a cleaner configuration file format. Check out tmux’s FAQ to discover a list of ways it differs from GNU Screen.
Use this command to install tmux on Ubuntu:
sudo apt-get install tmux
If you’re using another distribution, you’ll likely find it in your distribution’s package manager.
To launch tmux after installing it, just run the tmux command. Unlike Screen, tmux comes with a status bar by default.
To open an additional terminal window, use the Mod-c keyboard shortcut. The default modifer key combination is Ctrl-b. This means that you’ll have to press Ctrl-b and then cto create a new window.
Each new window you open will appear in the status bar. By default, tmux only shows one window on the screen at a time.
Here are some important keyboard shortcuts to get you started:
Mod-X – Kill the current terminal.
Mod-n – Focus next window.
Mod-p – Focus previous window.
Mod-# – Focus the specified window, where # is a number between 0 and 9.
Mod-’ – Prompt for a window to select.
Mod-% – Split the current window into two horizontally.
Mod-” – Split the current window into two vertically

To detach from the current session, use the Mod-d keyboard shortcut.
To reattach to a session, run the following command:
tmux attach
For more keyboard shortcuts, run the man tmux command or read tmux’s manual on the web.

Dvtm & Dtach

Unlike GNU Screen and tmux, dvtm doesn’t allow you to disconnect and reattach to sessions. You’ll have to run dvtm with dtach to detach from and reattach to your sessions.
Run this command to install dvtm and dtach on Ubuntu:
sudo apt-get install dvtm dtach
These programs should be available in other distribution’s software repositories, too.
Run the dvtm command to launch dvtm. You’ll see a single terminal window.
To open additional terminal windows, use the Mod-c keyboard shortcut. The default modifier key combination is Ctrl-g. This means that you’ll need to press Ctrl-g and then cto open a new terminal window.
Like a tiling window manager, dvtm will lay out the terminal windows automatically. Unlike the other utilities, it displays them all on the screen by default.
Here are some important keyboard shortcuts to get you started:
Mod-x – Close the current window.
Mod-j – Focus next window.
Mod-k – Focus previous window.
Mod-# – Focus the specified window, where # is the number of the window.
Mod-q - Quit dvtm.
For a full list, run the man dvtm command or check out dvtm’s manual page on the web.
Dvtm also supports the mouse. For example, you can click one of the windows to select it.
To detach from a dvtm session and reattach to it later, you’ll have to run it with the dtach command. To launch dvtm with dtach, use the following command:
dtach -c /tmp/dvtm-session -r winch dvtm
To detach from a dvtm session that’s been started with dtach, use the Ctrl-\ keyboard shortcut.
To reattach to your dvtm session later, use the following command:
dtach -a /tmp/dvtm-session -r winch
You can use dtach to run, detach from, and reattach to other applications, too.