Hot answers tagged screen
54
You want to be using GNU Screen. It is super awesome!
ssh me@myserver.com
screen #start a screen session
run-a-long-process
CTRL+a , d to detatch from your screen session
exit #disconnect from the server, while run-a-long-process continues
When you come back to your laptop:
ssh me@myserver.com
screen -r ...
52
From their website:
How is tmux different from GNU screen? What else does it offer?
tmux offers several advantages over screen:
a clearly-defined client-server model: windows are independent entities which
may be attached simultaneously to multiple sessions and viewed from multiple
clients (terminals), as well as moved freely ...
39
The command to do this is join-pane in tmux 1.4.
join-pane [-dhv] [-l size | -p percentage] [-s src-pane] [-t dst-pane]
(alias: joinp)
Like split-window, but instead of splitting dst-pane and creating
a new pane, split it and move src-pane into the space. This can
be used to reverse break-pane. ...
35
You can do it in screen the terminal multiplexer.
To split vertically: ctrla then |.
To split horizontally: ctrla then S (uppercase one).
To unsplit: ctrla then Q (uppercase one).
To switch from one to the other: ctrla then tab
Note: After splitting, you need to go into the new region and start a new session via ctrla then c before you can use that ...
28
I use screen both locally and remotely. I find that I use screen because it gives me the ability to
Run multiple tasks without making multiple ssh connections to a remote server,
Run a long-running task in screen, detach, disconnect. The job will still be running in screen and I can come back later, reattach, and check its progress.
Have a more or less ...
22
One difference is in how the two act when multiple terminals are attached to a single session.
With screen, each attached terminal's view is independent of the others. With tmux, all attached terminals see the same thing.
Say you have two terminals attached to a single tmux session. If you type ^B 1 into one terminal, the other terminal also switches to ...
21
join-pane is the answer. I too was having problems with my attempts to use it based on the tmux documentation. I discovered that the -t and -s switches seem to accept [session]:window and not [session:]window. That is to say that specifying the session is optional, but including the : is mandatory. (I am using tmux 1.5)
Therefore, in order to add a pane to ...
17
Using GNU screen is your best bet.
Start screen running when you first login - I run screen -D -R, run your command, and either disconnect or suspend it with CTRL-Z and then disconnect from screen by pressing CTRL-A then D.
When you login to the machine again, reconnect by running screen -D -R. You will be in the same shell as before. You can run jobs to ...
15
Heck yes! Screen (along with synergy) is one of my favorite programs. I use it every time I connect to our servers, and often just on my local machine.
Beyond what others have already mentioned, screen protects you from blips in network connections. When I'm working remotely (coffee shop, airport, etc) our VPN doesn't always play well with some networks. ...
15
Let me see if I have deciphered your screen configuration correctly:
You use something like logfile "%t-screen.log" (probably in a .screenrc file) to configure the name of the log file that will be started later.
You use the title <hostname> (C-a A) screen command to set the title of a new window, or
you do screen -t <hostname> ssh0 ...
13
Yes, screen is useful. Here's why in 8 easy steps:
ssh you@somehost
screen
start doing something really important
unplug the router / turn off the power in the building / spill coffee on your laptop (etc[*])
panic
get things back up an running
ssh you@somehost
screen -d -r
continue doing what you were doing before #4
Ok, so that's 9 steps, but... you ...
12
tmux is fairly new compared with GNU screen. Advantages / Disadvantages is a tough question, as both programs solve approximately the same problem. tmux is BSD licensed, however while screen is GNU GPL. This matters to some people.
screen is more represented (on linux) at the moment, that is, you are more likely to find it on a given linux box than ...
11
Make your shell change the window title every time it changes directory, or every time it displays a prompt.
For your ~/.bashrc:
if [ "$TERM" = "screen" ]; then
screen_set_window_title () {
local HPWD="$PWD"
case $HPWD in
$HOME) HPWD="~";;
$HOME/*) HPWD="~${HPWD#$HOME}";;
esac
printf '\ek%s\e\\' "$HPWD"
}
...
11
Xpra claims to be exactly that:
So basically it's screen for remote X apps.
I haven't used it in a while, but it worked pretty well when I tried it. You start the server on the remote machine:
[remote] $ xpra start :13
Then you attach to the server from your local machine:
[local] $ xpra attach ssh:remote:13
And now anything displayed on X ...
10
Some terminals, such as xterm, support what is known as an “alternate screen”: there are separate screens for full-screen programs and for scrolling programs. In xterm, you can switch between the two screens with the “show alternate screen” command at the bottom of the Ctrl+mouse 2 menu.
This behavior is disabled by default in screen but can be enabled with ...
10
@radius is spot-on with the SCREENRC thing, but it wasn't a very complete answer, so I'll elaborate…
~/.bashrc
# Strip down a FQDN
hostname="$(hostname | sed 's/\..*//')"
# Use the case pattern for server groups
case "$hostname" in
mario|luigi|toad|koopa|bowser) export SCREENRC=~/.screenrc_prod;;
dev*|vm*) export SCREENRC=~/.screenrc_dev;;
esac
# ...
10
Mouse scrolling and elevators will work if you enable them in your .screenrc.
Screen FAQ
Q: My xterm scrollbar does not work with screen.
A: The problem is that xterm will not allow scrolling if the alternate text buffer is selected. The standard definitions of the termcap initialize capabilities ti and te switch to and from the alternate ...
10
screen has a ton of features. It doesn't just "daemonize" a process, it's more of a window manager for terminals.
It can be used if the process needs input at some point, you can go and check the process's output, reconnect to its terminal, ...
So no, it's not just a matter of preference, they are not the same thing at all.
9
The biggest difference in my use has been that in Gnu Screen you can only split frames horizontally, whereas in Tmux you can split both horizontally and vertically. This is kind of a moving target, though as I here tell that vertical split is making it's way into screen.
Other then that, things are about flat.
9
If you have a root shell in a screen session (detached or not, password-protected or not), and your screen executable is not setxid, then an attacker who gains your privileges can run commands in that shell. If nothing else, they can do it by ptracing the screen process.
If screen is setuid or setgid, and the session is detached and password-protected, then ...
9
Try detaching it first with screen -d. If that doesn't work, you can try, in increasing order of emphasis,
-d|-D [pid.tty.host]
does not start screen, but detaches the elsewhere running screen session. It has the
same effect as typing "C-a d" from screen's controlling terminal. -D is the equivalent
to the power detach key. ...
9
tmux and screen have different models so there is no exact equivalent.
In screen terms, a split lets you display multiple windows at the same time. next (C-a n) rotates windows through the active part of the split; this lets you rotate “hidden” windows through the active region of the split.
In tmux terms, a split divides a window into one or more panes. ...
8
If I understand correctly, you want to send input to a program running inside a screen session. You can do this with screen's stuff command. Use screen's -X option to execute a command in a screen session without attaching to it.
screen -S sessionname -p windowname -X stuff 'command1
command2
'
If you want to see the program's output, see the hardcopy, ...
8
It is not really possible to save a complete screen session.
What you can do is to create a proper .screenrc which will setup some things after you restarted your system.
Here are some comments to the things you listed:
The number of opened shells
The name of each shell
The current directory of each shell
I use something like this in my .screenrc to ...
8
You could start screen with the -L option. This will cause screen to create a file screenlog.n (the n part is numerical, starting with a zero) in the current working directory.
In your case this would look something like: screen -S session_name -L -X eval 'stuff "$cmd"\015'
As long as you remember to clean up afterwards, this should match what you are ...
8
I see two way to do this, the first one is to make a .screenrc file by host.
Like .screenrc_serverA, .screenrc_serverB, ...
In your shell startup script set SCREENRC to something like .screenrc_hostname
Of course you can use the source command of screen to include something like .screenrc_default in each custom .screenrc_… files so that they only ...
8
Hitting Ctrl+A then Esc should get you into a special mode to look through the scroll-back buffer much like hitting Esc in vim gets you into a mode where you can navigate the file rather than inserting into it.
If your scroll-back buffer doesn't have enough lines in it to be useful you can change this in your ~/.screenrc file:
defscrollback 10000
Once in ...
8
There is a screen command to do this. From the manual:
Command: sessionname [name]
(none)
Rename the current session. Note that for screen -list the name shows up
with the process-id prepended. If the argument name is omitted, the name
of this session is displayed.
Caution: The $STY environment variable still reflects
...
8
It doesn't work because cd is a shell built-in command (try which cd). Screen has a chdir command which you can use to achieve your goal: Put the following inside your .screenrc:
chdir /home/cataldo/Programs
Now start screen and you should be in the specified directory.
7
Try using screen -RR.
Example:
$ screen -ls
There are screens on:
5958.pts-3.sys01 (08/26/2010 11:40:43 PM) (Detached)
5850.pts-1.sys01 (08/26/2010 11:40:35 PM) (Detached)
2 Sockets in /var/run/screen/S-sdn.
Note that screen 5958 is the youngest. Using screen -RR connects to screen 5958. The -RR options is somewhat further explained ...
Only top voted, non community-wiki answers of a minimum length are eligible