screen

Screen is needed once per few years so always forgetting its basics

# start new session
screen -q

# start new named session
screen -q -S macwashere

# list sessions
screen -ls

# connect
screen -r 2193920
screen -r macwashere

# detach from current session (Ctrl + A + D)
screen -d

# kill/remove (the same as `screen -r 2194114 ; quit`)
screen -X -S 2194114 quit

# check if inside screen session (STY env var is set)
echo $STY

# screen names
screen -ls | tail -n +2 | head -n -1 | awk '{print $1}' | sed 's/^[0-9]\+\.//'
# screen identifiers
screen -ls | tail -n +2 | head -n -1 | awk '{print $1}' | sed 's/\..*//'

# if someone connected to session (will print (Attached) for sessions where there is someone connected)
screen -ls

# remote detach
screen -S 2194534 -X detach