Since I use the *nix command screen
all day, and I couldn't find anyone starting this question, I figured it should be started. You know the drill: community wiki, one answer per features so we all can vote.

- 53,795
- 33
- 135
- 209

- 9,190
- 28
- 80
- 128
-
5screen is so useful it belongs on all the sites: http://stackoverflow.com/questions/70614/gnu-screen-survival-guide – Zac Thompson Nov 05 '09 at 09:14
11 Answers
I love using it for connecting to serial consoles, i.e.
screen /dev/ttyS0 19200
This command simply opens up a connection to serial port 0 (ttyS0) with a baud speed of 19200

- 3,359
- 3
- 32
- 46

- 14,907
- 10
- 53
- 83
-
this is one of my favorite things to freak people out with, truly one of screen's least expected features – epic9x Nov 09 '09 at 14:00
-
1And truly one of my favorites. No need to deal with, or configure, minicom, conserver, etc. I felt like a little kid in a candy store when I discovered this. – Scott Pack Nov 09 '09 at 14:21
-
Absolutely - it's nice to have a screen session open, split into two windows, with both USB-Serial dongles visible. – dotwaffle Nov 11 '09 at 11:00
The best feature of screen
is Byobu (formerly screen-profiles) which comes with Ubuntu by default since Jaunty: https://launchpad.net/byobu
It's a configuration manager with very nice defaults, tons of status notifications and useful keyboard shortcuts (i.e. f2 for new screen, f3-f4 for prev/next etc.)
I really don't go anywhere without it anymore :)
From KTamas's amswer: More than one person can use the same screen, i.e. if a friend of yours ssh
into your computer, then he can connect to your screen. It's great when two or three people are working on the same projects.
-
1This is much better for following what remote support users are doing, and killing their session if they're upto no good! – Tom O'Connor Oct 15 '11 at 18:40
Not exactly a "hidden feature"; but a properly setup .screenrc file can make a world of difference. One of the better examples out there can be found by googling screenrc and 'brad sims' - he has an excellent file to tinker with.
that said, my favourite setting would be bindkey:
# bind F7 to detach screen session from this terminal
# bind F8 to kill current screen window.
# bind F9 to create a new screen
# bind F10 to rename current screen window
# bind F11 to move to previous window
# bind F12 to move to next window
bindkey -k k7 detach
bindkey -k k8 kill
bindkey -k k9 screen
bindkey -k k; title
bindkey -k F1 prev
bindkey -k F2 next

- 852
- 5
- 8
-
2Considering that ctrl+a is used too often outside of screen (beginning of line in bash anyone?) I like this. – Scott Pack Nov 05 '09 at 12:42
-
1ctrl+a/ctrl+e for moving the cursor, but also when minicom is running in a screen. Ctrl+a,a,o for options... – petrus Sep 17 '10 at 17:52
I can't remember who I stole this from (someone on dotfile.org). I've modified it slightly for ssh:
#!/bin/sh
# scr - Runs a command in a fresh screen
#
# Get the current directory and the name of command
wd=`pwd`
cmd=$1
shift
# We can tell if we are running inside screen by looking
# for the STY environment variable. If it is not set we
# only need to run the command, but if it is set then
# we need to use screen.
if [ -z "$STY" ]; then
$cmd $*
else
# Screen needs to change directory so that
# relative file names are resolved correctly.
screen -X chdir $wd
# Ask screen to run the command
if [ $cmd == "ssh" ]; then
screen -X screen -t ""${1##*@}"" $cmd $*
else
screen -X screen -t "$cmd $*" $cmd $*
fi
fi
Then I set the following bash aliases:
vim() {
scr vim $*
}
man() {
scr man $*
}
info() {
scr info $*
}
watch() {
scr watch $*
}
ssh() {
scr ssh $*
}
It opens a new screen for the above aliases and iff using ssh, it renames the screen title with the ssh hostname.
Cheers z0mbix

- 251
- 1
- 3
- 10
-
:o. Did you lift and adapt it from me? https://gist.github.com/137214 – VxJasonxV Jan 12 '11 at 00:52
-
No, I think it was from a last.fm staff member who blogger about it once. – z0mbix Feb 02 '11 at 17:40
The ability to change the control key with -ethat when starting screen. I use it so I can nest screen sessions inside each other. Example: "screen -e ^w^x" makes the control key ctr-w.

- 1
- 1
One thing I find useful is that screen can emulate a larger width than your terminal. I find this useful if I'm using less
to real log files, and I don't want the lines to wrap. Using:
Ctrl-A:width -w 999
I can set screen
's with to be wider than my terminal, and log lines in less
won't wrap.

- 9,190
- 28
- 80
- 128
-
10FYI, the less option `-s` will tell it not to wrap lines. You can use `Left` and `Right` to scroll the lines. – MikeyB Nov 11 '09 at 06:16
Not a "hidden" feature, but the ability to share a screen session with another active user is very useful.
There are complicated ways to set up screen sharing, including access control permissions and user name management. What I most often do with coworkers is much more quick & dirty:
- Log into machine in question in new window.
- Allow anyone to write to my terminal:
chmod 777 $(tty)
- Sudo to their account:
sudo su <username>
- Share their screen:
screen -x <session>
This doesn't require any advance configuration or password sharing.

- 543
- 1
- 5
- 15
One nice feature: you can use backtick
to pull in extra info for display in a caption. For example, I have a script that output a one-line summary of new mail counts in various folders, and I have that appear in the bottom line if my screen session along with the hostname with a config that looks like this:
backtick 1 15 15 /home/waltermundt/bin/newmail
caption always
caption string "%{.kW}%1` example.com %{.bW}%-w%{.rW}%n %t%{-}%+w %{.gW}%h%{-}"
The key is the %1` bit, which refers to the output of backtick job 1.
(I use hardstatus
as the xterm title string and have it set differently, thus the use of caption
instead of hardstatus alwayslastline
.)

- 39,291
- 10
- 105
- 189

- 354
- 1
- 4
A little cheat sheet I have printed out for myself;
(Note: Everything is preceeded by Ctrl-A)
A: rename a window ": show a list of windows d: detatch session
And screen -D -R
to deattach and reattach a running session (in case you somehow lose access to your session).
None of these are really hidden features, but these are the features I find to be the most useful.

- 8,224
- 2
- 31
- 35

- 934
- 5
- 12
It's a core feature, but of course the best is Ctrl-A: to talk directly to screen. : screen -t title ssh hostname
etc.

- 1,033
- 10
- 10