Date created: Thursday, June 5, 2025 10:38:00 AM. Last modified: Thursday, June 5, 2025 10:40:39 AM

'screen' - Notes

Config

In ~/.screenrc:

startup_message off

# Scrollback history
defscrollback 1000000

termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'

# Enable scrolling using mouse wheel (alternate text buffer)
termcapinfo xterm* ti@:te@

Enter copy mode: CTRL+A [

Exit copy mode: Esc

Scroll half page up: CTRL+u

Scroll full page up: CTRL+b

Scroll half page down: CTRL+d

Scroll full page down: CTRL+f

Or enter op mode with CTRL+a then Esc, then use UP and Down arrows, Esc to exit again

New window: CTRL+a c

Next window: CTRL+a n

Previous window: CTRL+a p

Lock screen session: CTRL+a x

Detach session: CTRL+a d

 

To connect to an already attached screen by disconnecting the attached user;

screen -list
There is a screen on:
    3746.pts-4.node1	(18/10/12 13:26:37)	(Attached)
1 Socket in /var/run/screen/S-node1.
screen -D -r 3746

 

Scripts in Screen

To start a script running in a screen session for a specific user at boot time, without connecting to that screen session, add the following to /etc/rc.local:

sudo -u bensley screen -dmS mc /opt/mc/start_mc.sh

# start_mc.sh:
#!/bin/bash

cd "$(dirname "$0")"

while true
do
    /usr/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.1.18.2.jar nogui
done

 

screen with USB/serial

# Connect to a USB to serial adapter at 9600 baud:
$screen /dev/ttyUSB0 9600

# To send the break key enter CTRL+a then CTRL+b

# To quit screen type CTRL+a then CTRL+\

# To send a file via xmodem, on Linux:
$ apt-get install lrzsz
# or on Mac:
$ brew install lrzsz
# Start the xmodem transfer on the receiving device, then from within screen enter CTRL+a then a colon ":", then run:
exec !! sz -kbX vdsl_C897VAB_Fw_A39x3_Bond39x6.bin
# ^ Not that you must but running screen in the same folder as the folder that needs to be sent, relative paths like ~/blah.txt don't wor

 


Previous page: 'rtorrent' - Notes
Next page: 'sed' - Notes