Screen: Difference between revisions
Line 24: | Line 24: | ||
=== Ctrl-a commands === | === Ctrl-a commands === | ||
Nearly all of screen's commands are used via the ctrl-a key combination. First, you press the ctrl and a keys together, then release. Next, press the key you want to run a command. These commands can be a little awkward and difficult to remember at first, but you'll soon get the hang of it. In this tutorial, the commands will be shown as ctrl-a and then a letter, with the following letter being associated with a command. | Nearly all of screen's commands are used via the ctrl-a key combination. First, you press the ctrl and a keys together, then release. Next, press the key you want to run a command. These commands can be a little awkward and difficult to remember at first, but you'll soon get the hang of it. In this tutorial, the commands will be shown as ctrl-a and then a letter, with the following letter being associated with a command. | ||
=== Creating a new window === | === Creating a new window === | ||
Line 31: | Line 30: | ||
Just hit ctrl and a together, then release them and hit c. This keybinding will open a new window (window 2) inside screen. Now you'll have two windows to use, so you'll have to learn how to use the ctrl-a commands to switch between them. | Just hit ctrl and a together, then release them and hit c. This keybinding will open a new window (window 2) inside screen. Now you'll have two windows to use, so you'll have to learn how to use the ctrl-a commands to switch between them. | ||
=== Switching windows=== | === Switching windows=== | ||
Line 46: | Line 44: | ||
ctrl-a window_number | ctrl-a window_number | ||
Using this command, you can specify exactly which window you want to jump to by hitting ctrl and a, then the number on the keyboard of your desired window. This is pretty useful for when you have a lot of windows open in screen. | Using this command, you can specify exactly which window you want to jump to by hitting ctrl and a, then the number on the keyboard of your desired window. This is pretty useful for when you have a lot of windows open in screen. | ||
=== Naming your windows === | === Naming your windows === | ||
Line 68: | Line 65: | ||
From this window you can view and go to any of your windows. The flags on the right indicate whether your window is logged in or not with $ symbol. | From this window you can view and go to any of your windows. The flags on the right indicate whether your window is logged in or not with $ symbol. | ||
=== Detaching and reattaching screen === | === Detaching and reattaching screen === | ||
Line 90: | Line 86: | ||
followed by the id listed above of the screen you want to reattach to. | followed by the id listed above of the screen you want to reattach to. | ||
=== Start and stop signals === | === Start and stop signals === | ||
Line 102: | Line 97: | ||
This should have you back in action very shortly. However, if your screen is frozen and you can't figure out why, try asking a member of [[Helpdesk]] and they should know the answer :) | This should have you back in action very shortly. However, if your screen is frozen and you can't figure out why, try asking a member of [[Helpdesk]] and they should know the answer :) | ||
=== Killing screen === | === Killing screen === | ||
Line 113: | Line 107: | ||
or even just type "exit" at the prompt. | or even just type "exit" at the prompt. | ||
===More commands=== | ===More commands=== |
Revision as of 02:09, 6 December 2007
Basics
Screen usually does not exist. This is the committee's general position on screen due to the disastrous and/or hilarious situations which often result from new members' attempts to get it working. However, for the purpose of this tutorial, screen does exist, and this is how you use it. (Blame coconut for this defiance.)
Omg, what's screen?
Screen is most commonly known as "that thing that lets you stay logged in to chat when you log out of RedBrick". It's a terminal multiplexer, which allows you to log into multiple terminal sessions from one terminal window and keeps them open when you go away to bed or whatever it is you do with your time.
Opening
Type "screen" at the prompt like this:
This will open a new screen session. First you'll see the screen startup message, which gives a little info on the program.
Just hit space/return as it says and you'll be running screen. You won't notice anything immediately different once running screen, instead, you'll be back at the same old terminal. Now, however, you have access to a large variety of commands and features that you didn't before.
Screen commands
Ctrl-a commands
Nearly all of screen's commands are used via the ctrl-a key combination. First, you press the ctrl and a keys together, then release. Next, press the key you want to run a command. These commands can be a little awkward and difficult to remember at first, but you'll soon get the hang of it. In this tutorial, the commands will be shown as ctrl-a and then a letter, with the following letter being associated with a command.
Creating a new window
When you start screen, it presents you with the normal single window terminal you're used to. You can, however, create many more and run them all within the one screen session. The following command will create another window for you:
ctrl-a c
Just hit ctrl and a together, then release them and hit c. This keybinding will open a new window (window 2) inside screen. Now you'll have two windows to use, so you'll have to learn how to use the ctrl-a commands to switch between them.
Switching windows
Once you have more than one window open, you can switch between them using some of the following commands:
ctrl-a n
This command will switch you over to the next window.
ctrl-a p
This one will bring you back to the previous window.
ctrl-a a
This will switch between the last two windows that you've been using.
ctrl-a window_number
Using this command, you can specify exactly which window you want to jump to by hitting ctrl and a, then the number on the keyboard of your desired window. This is pretty useful for when you have a lot of windows open in screen.
Naming your windows
You can give each of your windows its own name too for convenience by using this command:
ctrl-a A
This one might seem confusing first as the A is a capital letter in this case, but all you need to do is hit ctrl and a together and release as before, then hold shift and press a to get the capital. After you run it, you'll see a white bar appear at the bottom of your window, where you can change the name of your screen to whatever you like. In this case, the window has just been renamed to "chat".
After you've named a few windows, you can try this command:
ctrl-a "
Yup, even quotation marks can be used in screen commands. So as before you do ctrl-a, then hold shift and hit the 2 key to get the " :) This will bring up a convenient list of all your windows with their names.
From this window you can view and go to any of your windows. The flags on the right indicate whether your window is logged in or not with $ symbol.
Detaching and reattaching screen
One of the most popular features of screen is that it can keep you logged in even when you're offline. This means you can leave programs running or even stay on IRC even when you're not online. To this, you just detach from screen instead of exiting it. To detach from screen without exiting, use the following command:
ctrl-a d
You'll then be returned to the prompt with a message telling you screen has been detached, like so:
Later, you'll come back online and want to reattach to your screen session. To reattach a detached screen, use this command at the prompt:
screen -dr
The -d will dettach any "attached" screens and -r will reattach your screen.
If you have more than one screen session available, you will need to specify the screen id you wish to open. You'll be given a list of the currently available screens, so then you type:
screen -r
followed by the id listed above of the screen you want to reattach to.
Start and stop signals
Quite often it happens someone may end up using the stop signal command in screen by mistake. This command is:
ctrl-a s
and you should probably avoid using it! But as the s key is beside the a key, people will occasionally run this command by accident without knowing it. As this is a stop signal, it has the unfortunate side effect of freezing up your window :( Worry not however, for to fix it, all you need to do is use the start signal again to bring it back from the dead:
ctrl-a q
This should have you back in action very shortly. However, if your screen is frozen and you can't figure out why, try asking a member of Helpdesk and they should know the answer :)
Killing screen
Often enough new members (and sometimes even experienced people like goldfish) will make mistakes with screen that they can't fix. To kill screen altogether and start over, use:
ctrl-a \
Or, if you just want to kill a single window in screen, use:
ctrl-a k
or even just type "exit" at the prompt.
More commands
If you'd like to learn more about the program, a long list of screen commands can be found here: http://www.linuxdevcenter.com/linux/cmd/cmd.csp?path=s/screen