PCFreak Logo (c) Der PCFreak

Linux – Terminalbildschirm splitten

Einen guten Bericht zum Splitten von Terminalbildschirmen unter Linux habe ich bei Ruckman.net gefunden. Siehe hier:

http://ruckman.net/blog/comment.php?comment.news.11/

Da der Autor anscheinend gelegentlich am Blog rumbastelt und die Links sich ändern, hier der entsprechende Teil:

The secret is to use the “screen” command. And I will tell you all the commands you need in order to make it work wonders for you. But first a little copy and paste from the screen website: (LINK)

“Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. Each virtual terminal provides the functions of the DEC VT100 terminal and, in addition, several control functions from the ANSI X3.64 (ISO 6429) and ISO 2022 standards (e.g., insert/delete line and support for multiple character sets). There is a scroll back history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scroll back history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal.”

From the description above you will notice that there are some other advantages to using screen besides the ability to split screen your console. For instance, if you are using putty on a somewhat unstable internet connection and your connection is lost you will lose your console session and any program instance that is running. But if you are using screen your terminal instance will continue to run even if you lose your connection and all you have to do is reconnect and reattach to your screen session.

If you do not have screen, you can obtain it at the link listed above or from your Linux distros update command such as yum or apt-get.

I will now give you the commands you require to use screen efficiently. Any command when you are inside screen begins with “CNTL-A”.

To start you will have to call the first instance of screen. You can combine a lot of these commands into one command line argument but I prefer to show you one command at a time. Run the following command:

screen

You will now see the shell prompt again. To split screen hit the following key combinations:

CNTL-A

SHIFT-S

You will now need a second screen instance to run in the bottom window. Run the screen command again:

screen

Run a command such as “man”, “htop”, or top. You will notice that it fills the top half of the screen.

You will now have to toggle to the bottom screen by hitting the following key combinations:

CNTL-A

TAB

You will now be in the bottom window, although you will not see your command prompt yet. You will have to toggle through the instances of screen in the bottom window to get to it. Use the following key combinations to do this:

CNTL-A

N

or:

CNTL-A

P

The “N” stands for next and the “P” stands for previous. It just allows you to step forward and backward through as many instances of screen that you have running. If you see the same output in both windows just do the same key combo again to get to the next version of screen.

Once you get the shell prompt in the bottom screen you can run your second command and view the output from both running instances. You can now view a man page in the top window and craft your command below or view htop and iftop in the same window at the same time. You can also split the screen more times but I wouldn’t recommend it unless you have some decent resolution set for your text console which can be controlled in your boot options in grub or lilo but that is another lesson.

You may find a few more commands useful during your stay with screen. You may with to leave the current session running in the background and jump back to you regular console. You can do that by detaching which is done with the following key combo:

CNTL-A

D

Now that you are detached, which is what also happens during loss of connectivity, you may want to reattach to one of your screen instances. You will first need to list the instances of screen by typing the following command:

screen -list

You will the get a list similar to:

There is a screen on:
3880.pts-0.localhost (Detached)

To reattach to the instance listed above, type:

screen -r 3880.pts-0.localhost

The part after “-r” will change depending on your linux box.

You will notice that you are now back into your detached session of screen.

Now that you know the basics of screen, I am sure you will become accelerated at learning other Linux commands. Take care, and enjoy the ease of use!