date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,339,090,327,000 |
I saw some body split their window to 2x2, I just want to know how to do that? I know the 'split' command in Screen can only split the window horizontally.
|
GNU Screen <4.01 may not support vertical split without a patch.
GNU Screen >4.01 supports vertical splitting.
The Patch is licensed under GPLv2. Some people say that the vertical split in GNU screen makes the application slow but I haven't tested. I use tmux (terminal multiplexer)
| How to split window vertically in GNU Screen? |
1,339,090,327,000 |
Somehow I managed to close a screen window without screen 'noticing' it, so the session is still flagged as attached. This prevents me from re-attaching to this session. What can I do?
me@iupr-serv8:~$ screen -r
There are several suitable screens on:
25028.pts-19.XXX-serv8 (01/05/2012 07:15:34 PM) (Attached)
... |
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 equivalen... | How to recover a 'lost' screen session? |
1,339,090,327,000 |
I am inside a screen (screen -Ra). I have a long command, and I am at the end. Instead of keeping the left arrow, how can you go to the beginning of the line?
CTRL-A works when I am in a normal window, but when I am inside a screen pressing CTRL-A gives me a message "No other window" - seems like CTRL-A is dispatched... |
Use Ctrl-a a, or change screen's escape keystroke (option -e).
| Shell: how to go to the beginning of line when you are inside a screen? |
1,339,090,327,000 |
I recently moved from GNU screen to tmux.
I find it quite similar but with bigger support (I switched due to problem with escape-time in neovim- resolution was only for tmux).
Unfortunately in tmux I'm unable to find a similar command to this:
screen -X eval "chdir $(some_dir)"
The command above changed the default d... |
tl;dr
Ctrl+b
:
attach -c desired/directory/path
Long Answer
Start tmux as follows:
(cd /aaa/bbb; tmux)
Now, any new windows (or panes) you create will start in directory /aaa/bbb, regardless of the current directory of the current pane.
If you want to change the default directory once tmux is up and running,... | How to change default new window directory from within the tmux |
1,339,090,327,000 |
I thought Moving tmux pane to window was the same question but it doesn't seem to be.
Coming from using GNU screen regularly, I'm looking for tmux to do the same things. On of the things I do regularly is have a couple of different windows open, one with some code open in vim, and a couple of terminals windows open t... |
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 div... | How do I cycle through panes inside a window in tmux like in screen? |
1,339,090,327,000 |
As root, I'm connecting to a remote host to execute a command. Only "standarduser" has the appropriate id-file and correct .ssh/config, so I'm switching the user first:
su standarduser -c 'ssh -x remotehost ./remotecommand'
The command works fine, but despite the fact that I used "-x" (disable X11-Forwarding) and hav... |
Seems like your root lacks some X11 magic cookie in the .Xauthority, which your standarduser has. Here is how to fix this.
SHORT VERSION (thanks to @Vladimir Panteleev)
standarduser@localhost:~$ sudo xauth add $(xauth list | grep "unix$(echo $DISPLAY | cut -c10-12)")
ORIGINAL LONG VERSION
To fix things, first detect ... | "su" with error "X11 connection rejected because of wrong authentication" |
1,339,090,327,000 |
Currently I have a shell script which logs messages to a log file like this:
log_file="/some/dir/log_file.log"
echo "some text" >> $log_file
do_some_command
echo "more text" >> $log_file
do_other_command
When executing this script, there is no output to screen, and, since I'm connecting to the server via putty, I hav... |
This works:
command | tee -a "$log_file"
tee saves input to a file (use -a to append rather than overwrite), and copies the input to standard output as well.
Because the command can detect that it's now being run in a non-interactive fashion this may change its behaviour. The most common side effect is that it disabl... | how to output text to both screen and file inside a shell script? |
1,339,090,327,000 |
I'm trying to run a minecraft server on my unRAID server.
The server will run in the shell, and then sit there waiting for input. To stop it, I need to type 'stop' and press enter, and then it'll save the world and gracefully exit, and I'm back in the shell. That all works if I run it via telnetting into the NAS box, ... |
I can solve at least part of the problem: why the stop part isn't working. Experimentally, when you start a Screen session in detached mode (screen -d -m), no window is selected, so input later sent with screen -X stuff is just lost. You need to explicitly specify that you want to send the keystrokes to window 0 (-p 0... | sending text input to a detached screen |
1,339,090,327,000 |
I am running an application with command $ grails run-app which prints log in terminal like below.
What I want is search a particular text (say user authorities) in this log so that I can verify further. One way using Logging Apis to write in text file but I want to search it in a terminal at the moment.
I found sim... |
Ctrl+a (default screen command prefix), [ (enter copy mode) followed by ?SEARCH_TEXT seems to work. Press n to go to the next occurrence. From there, you can copy words, lines, regions, etc to dump into files or paste later on (with Ctrl+a, ]).
| search text on the terminal output |
1,339,090,327,000 |
I'm trying to force GNU screen to create a "virtual" terminal, without attaching to it, execute script inside and NOT terminate session once script ends.
I tried many combinations, including:
screen -dmS udplistener /share/Sys/autorun/start_udp_listeners.sh
or
screen -S udplistener -X /share/Sys/autorun/start_udp_lis... |
To keep screen busy after the script completes, just keep something persistent running in a window. The simplest choice for that "something" is probably an interactive shell. Here's one way to do it (assuming bash as the choice of interactive shell):
screen -dmS session_name sh -c '/share/Sys/autorun/start_udp_liste... | Prevent GNU screen from terminating session once executed script ends |
1,339,090,327,000 |
I would like to force GNU screen to reflow to the existing terminal width when I reattach a session. It seems to me this worked properly before I upgraded a machine to CentOS 6, but I cannot figure out how to restore it. (TERM=xterm)
Whenever I reattach a session, regardless of state when I detached it, it launches at... |
after you reattach a ctrl-a F runs the "fit" command to resize the current window. if you reattach using the -A option it should resize all windows when you reattach. Are there others still attached to the screen session when you are attaching? For instance, are you having to use -x to reattach instead of -r? you ... | Force GNU screen to reflow to current terminal width on reattach? |
1,339,090,327,000 |
When I start screen, I get a message giving the version, copyright, and bug-reporting email address. I don't want to see this every time I start screen. Searching the man page didn't seem to result in a solution, and I am hoping that the experts here know a way to bypass this info page.
|
There's a setting for that:
# Don't display the copyright page
startup_message off # default: on
You can set that system-wide (in /etc/screenrc) or only for your account (in ~/.screenrc). Shortcut commands:
# Skipping the startup message for your account.
echo 'startup_message off' >> ~/.screenrc
# Skip... | How do you bypass or skip the intro message when starting screen? |
1,339,090,327,000 |
I make heavy use of screen's "log" command to log the output of a session to a file, when I am making changes in a given environment. I searched through tmux's man page, but couldn't find an equivalent. Is anyone aware of a similar feature in tmux, or do I have to write my own wrapper scripts to do this?
EDIT: I'm awa... |
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... | Is there an equivalent of GNU Screen's "log" command in tmux? |
1,339,090,327,000 |
I am using screen to split my terminals but I would like to be able to resize the horizontal dimension of the split screens.
If I do C-a :resize 10 I only change the vertical dimension to 10 lines. How do I achieve the same but for the horizontal dimension?
|
At least on Debian and Ubuntu, the resize command, when applied to a full height region performs a horizontal resizing.
If it works for you, then first split vertically, next perform a resizing of the width, then split horizontally.
| how to resize horizontally a screen region |
1,339,090,327,000 |
when starts session named any name like this screen -S name1
i want to open tabs windows in this screen session like when open tabs in gnome-terminal like this
gnome-terminal --tab -e "some commands"
so how to do this ?
|
1. Tabs in screen
You're looking for this to add to your .screenrc file:
screen -t tab1
screen -t tab2
Here's a nice basic .screenrc to get you started with a status bar etc. NOTE: This is typically located in your home directory /home/<username>/.screenrc.
screen -t validate #rtorrent
screen -t compile #irssi
screen... | How to open tabs windows in Gnu-screen & execute commands within each one |
1,339,090,327,000 |
I have a screen instance running, and I would need to execute some code inside the screen, and get the result out to my script.
The first part is quite easy, I just screen -S session_name -X eval 'stuff "$cmd"\015'.
(I modified a line I found in a script)
The second part, getting out the output, is trickier. How can I... |
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 afterwa... | How to get the output inside `screen` out to a script? |
1,339,090,327,000 |
Is it possible to persist the "state" of a GNU screen window (or just a standard shell) so that I can reload everything after a reboot:
The number of opened shells
The name of each shell
The current directory of each shell
The history of each shell
If possible, their environment variables
|
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 some... | Save complete GNU screen session state |
1,339,090,327,000 |
I've been using screen -dRaA -S x to open up a single session between different workstations as I move about. Handy.
Is it possible to connect multiple times to a single session, though, without disconnecting others? When I have two machines I'm quickly moving between even reconnecting starts to slow me down.
|
Try
screen -aAxR -S x
-x is the option that does what you want.
| Attach multiple times to a single screen session |
1,339,090,327,000 |
I am setting up a server where there are multiple developers working on multiple applications.
I have figured out how to give certain developers shared access to the necessary application directories using the setgid bit and default ACLs to give anyone in a group access.
Many of these applications run under a terminal... |
Yes, you can do it with screen which has multiuser support.
First, create a new session:
screen -d -m -S multisession
Attach to it:
screen -r multisession
Turn on multiuser support:
Press Ctrl-a and type (NOTE: Ctrl+a is needed just before each single command, i.e. twice here)
:multiuser on
:acladd USER ← use userna... | Sharing a terminal with multiple users (with screen or otherwise) |
1,339,090,327,000 |
I want to run a bash script in a detached screen. The script calls a program a few times, each of which takes too long to wait. My first thought was to simply open a screen and then call the script, but it appears that I can't detach (by ctrl-a d) while the script is running. So I did some research and found this inst... |
The shebang line you've seen may work on some unix variants, but not on Linux. Linux's shebang lines are limited: you can only have one option. The whole string -d -m -S screenName /bin/bash is passed as a single option to screen, instead of being passed as different words.
If you want to run a script inside screen an... | Run script in a screen |
1,339,090,327,000 |
I am using screen /dev/tty-MyDevice to look at traffic on my serial port.
Pressing Ctrl+D does not cause the screen to terminate.
What I have to do in order to terminate it?
|
Use the screen quit command (normally ctrl-A \).
| terminate screen monitoring serial port |
1,339,090,327,000 |
I have a shared home directory that is automounted via NFS on all the UNIX servers I log in to. I would like to have a single .screenrc that (for example) puts the hostname in the hardstatus line in a different colour to indicate when I am logged on to production versus development; our hostnames are such that this ca... |
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 .scr... | How can you change the GNU screen status line based on hostname? |
1,339,090,327,000 |
I have a window called 'Codes' in window 1, and I want to move it to window 7, is it possible?
|
Yes, it is possible. Go to window 1, type the command character (e.g. CTRL-A) and then type: :number 7. If there is already a window at 7, then the two windows will be swapped (window 7 will become window 1). From the manpage:
Change the current windows number. If the given number n is already
used by a... | How to move window in GNU Screen |
1,339,090,327,000 |
I have noticed that a logoff (log out) from my X user session will kill any tmux session I have initiated, even sessions I had run with sudo tmux and similar commands. I am sure that this formerly did not happen, but some recent change has effected this behavior.
How do I maintain these tmux (or screen) sessions, even... |
This "feature" has existed in systemd previously, but the systemd developers decided to effect a change in the default, to enable the setting for termination of child processes upon log out of a session.
You can revert this setting in your logind.conf (/etc/systemd/logind.conf):
KillUserProcesses=no
You can also run ... | Prevent Logoff from Killing tmux Session |
1,339,090,327,000 |
Every now and then some key combination clears my working (Gnu) screen and brings up this message:
Screen used by <username> on host01
Password:
What key combination causes this and what does it signify?
|
According to this source it's the key combination Ctrl+a and then x.
It signifies locking the screen and unlocking it with your password.
| What triggers this screen prompt "Screen used by <username> on host01."? |
1,339,090,327,000 |
I love screen, but it drives me nuts that I have to stop typing input, hit CTRL+A [, and then find what I need.
Is there a way to make the scroll wheel function normally, rather than scrolling commands?
Also, is it possible to enable Shift+PageUp/PageDn?
|
I use these settings with urxvt in my ~/.screenrc:
termcapinfo rxvt-unicode ti@:te@
termcapinfo rxvt ti@:te@
termcapinfo rxvt 'hs:ts=\E]2;:fs=07:ds=\E]2;screen07'
Those allow for scrollbar and mouse wheel to do "the right thing™".
Note that this is dependent on terminal type, so will not work if your terminal is not ... | Is there a way to make Screen scroll like a normal terminal? |
1,339,090,327,000 |
Let's say I have several shell "tabs" (or screens? sessions?) named bash1, bash2, etc. open in GNU screen. I want the status bar (i.e., the caption line) to display the names as "bash1 | bash2 | ..", with the currently open tab and the last open tab clearly marked.
How do I make this happen with my .screenrc?
|
Edit or create (if not present) /etc/screenrc or (~/.screenrc) and add below code
autodetach on
startup_message off
hardstatus alwayslastline
shelltitle 'bash'
hardstatus string '%{gk}[%{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= w}%?%+Lw%?%? %{g}][%{d}%l%{g}][ %{= w}%Y/%m/%d %0C:%s%a%{g} ]%{W}'
shellt... | GNU screen status bar - how to make it display shell session names? |
1,339,090,327,000 |
I'd like to be able to check progress and output of my existing screen sessions, but in a read-only manner, so as to prevent something from going wrong due to user error. Is there a way to do this?
|
Unfortunately, I think the answer is no. The asker of this question switched to tmux specifically because it has that feature (you pass the -r flag when attaching), so if you have the option to switch multiplexers it's probably your best choice
| Is there a way to run 'screen' in read-only mode? |
1,339,090,327,000 |
To navigate to the starting and end of a command, I usually use Ctrla and Ctrle.
However, when I work within a GNU screen, those keybinding do not work becuase perhaps they are being used by the GNU screen. Is there another way to move to the starting or the end of the command?
I am on CentOS6.2
|
Ctrl-A followed by the letter 'a' will send the Ctrl-A sequence to the shell.
Or you could map the screen command key to something other than Ctrl-A
| Ctrl-a does not take me to the beginning of the prompt while I am working within a GNU screen |
1,339,090,327,000 |
When I do this in my terminal:
echo -e "\xF0\x9f\x8d\xba"
I get a cool beer mug in my terminal: üç∫
However, when I start screen, and try the same, I'm getting a ÔøΩ. How do I get the nice beer mug?
This is my .screenrc:
nethack on
startup_message off
defscrollback 3000
hardstatus on
hardstatus alwayslastline
hardst... |
It's a apparently a known bug: No characters beyond the BMP are displayed, as screen apparently only has a two byte buffer for characters.
(It works in tmux).
| GNU Screen doesn't echo unicode characters correct |
1,337,145,221,000 |
Both terminal multiplexers (screen, tmux) and keyboard-driven tiling window managers (ratpoison, dwm, xmonad) provide similar functionality. Is there any benefit in using both at the same time? What about problems that may arise?
|
I use dwm and tmux. Before learning to use tmux, I would have multiple terminals open for different things, and have them in different tags. Now I can run everything inside of one tmux session, under a single tag, and can detach and reattach without losing state if I need to restart X.
| Does a terminal multiplexer have any benefit when used with a tiling window manager? |
1,337,145,221,000 |
While using Xorg X11, on KDE/Gnome/XFCE how can we scale the display/resolution for the whole desktop and/or per application? (when this is not available on the settings GUI)
The purpose is to keep the screen resolution unchanged (at max) while scaling the size (bigger/smaller) of the desktop/applications.
|
Linux display
This is detailed in depth on how does Linux's display works? QA.
On most desktops system (like KDE or Gnome) there are settings available on their respective settings panel, this guide is for additional/manual settings that can be applied to scale an application or the whole desktop. This reference artic... | How to scale the resolution/display of the desktop and/or applications? |
1,337,145,221,000 |
I can change the name of a window with Ctrl-a Shift-a. Instead of editing several window names by hand, is there a way to have them automatically named after the current directory?
|
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 '\... | GNU Screen: new window name change |
1,337,145,221,000 |
I'm curious about the security of leaving a root shell running inside a detached screen session. I typically never do this.
Aside from the potential of my non-root user account being compromised (password exposed, ssh key compromised, etc), are there other vectors of entry into a detached, password-protected screen se... |
I think it is a security issue, because that "Aside from the potential of my non-root user account being compromised" can be rather large.
But there are other increased risks beyond that. For example, you've now opened yourself up to a theoretical exploit which allows one to change permissions in the screen socket dir... | Is it secure to leave a root shell running in detached screen session? |
1,337,145,221,000 |
Every time I log into a VM with root, su into a user account, and try to use screen it throws an error:
Cannot open your terminal '/dev/pts/0' - please check.
A Stack Overflow post said I needed to use script /dev/null to fix it, and it works, but it still doesn't explain why I need to type script /dev/null. I would ... |
You cannot open /dev/pts/0 because it's owned by root, and after you su-ed into another user you're no longer able to open it via its path, but you're still able to use it via the opened handle to it, which was inherited from the parent process.
script /dev/null will create another pty, owned by the current user.
Anyw... | What does 'script /dev/null' do? |
1,337,145,221,000 |
When I need to open different processes or terminals that I need to check, I just open a new tab in my terminal and use different workspaces in my machine to keep everything organized.
I do some web development, using a Linux machine. I've seen that a lot of people use screen to accomplish what I'm doing, but I can't ... |
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 c... | Is screen useful? |
1,337,145,221,000 |
Suppose I have an attached screen, but I forgot to execute screen -L initially. Is it possible to enable and disable the logging of the currently attached screen without re-executing screen?
I know that it's possible to take what is essentially a screenshot of a currently attached screen by pressing Ctrl+a h (that key... |
To enable logging on the current window of a screen session, press Ctrl+AH (uppercase H, Shift+H if you prefer).
That actually toggles the logging state (so if the windows was being logged beforehand, it is now no longer logged).
That's the log command in screen, so you can also do Ctrl+A: and enter log (or log on to ... | GNU Screen: How to enable or disable logging while screen is already attached? |
1,337,145,221,000 |
I'm looking at tmux from screen, and have hit a bump while configuring the (highly configurable!) tmux key bindings.
Problem is, in my .screenrc I have
bindkey ^[[d prev
bindkey ^[[c next
bindkey ^[[a title
bindkey ^[[b screen 1
and the bindings work (they originally came from rxvt-tabbedex).
But in tmux there's appa... |
Try this (as a partial example):
bind -n S-Right next-window
bind -n S-Left previous-window
That should be enough to make it easy to get the other 2 settings working too. It works on my tmux installation (1.4) but YMMV.
You can also use the meta key (option on Macs, alt on PCs):
bind-key -n M-Right next-window
bind-... | How do I bind to Shift+{Left,Right} in tmux? |
1,337,145,221,000 |
I am using bash and GNU screen on centos7. I notice that if I ssh to another server, change the title (via ctrl+a+A), and log out of the server that my new title gets overwritten by USER@HOST:~. How can I stop it from doing this?
I've looked into dynamic titles and determined that's what's at play, but I'm unsure of h... |
As documented in the man page, screen looks for a null title-escape-sequence. bash sends this sequence via the PROMPT_COMMAND environment variable (for example, mine defaults to printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}".
To disable this feature for a particular window, I just run unse... | How do I stop screen from clobbering my titles? |
1,337,145,221,000 |
I use screen as my window manager through putty. Screen has been great, but I need a way to increase my buffer when I run commands. I have no buffer when I scroll up, no std out is saved beyond my window size on any terminal.
How can I increase this I can't seem to find an option in the commands? Ctrl + a ? doesn't s... |
Do Ctrl + a : then enter scrollback 1234 sets your buffer to 1234 lines. You enter scrollback mode ("copy mode") with Ctrl + a Esc, then move in vi-style, leave copy mode with another Esc
| Increase buffer size while running screen |
1,337,145,221,000 |
So let's say you boot up your Linux install all the way to the desktop. You start up a gnome-terminal/konsole/whatever so you have a tty to enter commands to.
Now let's say I SSH into that same machine. It will bind me to another tty to enter commands to.
Now let's say I want to "switch" my tty from my original SSH ... |
Maybe these schema can clarify the situation.
This is the usual setting:
Terminal (/dev/ttyX or /dev/pts/x)
device
|
(screen)<--[<output]----x-------(stdout) Process1
Terminal (keyboard)---[... | How can I switch between ttys without using screen? |
1,337,145,221,000 |
I'm using screen on debian lenny, and I would like to use the -R option. From man screen:
-R attempts to resume the youngest (in terms of creation time)
detached screen session it finds. If successful, all other com‐
mand-line options are ignored. If no detached session exists,
... |
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 ... | How to make screen -R attach to the youngest detached session? |
1,337,145,221,000 |
Is it possible to change the parent process of a process? If yes, how?
For example,
how does screen manage to attach a screen session and the processes running inside it to different shell processes? Is there change of parent process?
I seem to heard of other ways of change of shell process in which a program is run... |
The parent process id (ppid) of a process cannot be changed outside of the kernel; there is no setppid system call. The kernel will only change the ppid to (pid) 1 after the processes parent has terminated - if the process did not respond to a signal that the parent was terminated. For this to happen, the process nee... | Change the parent process of a process? |
1,337,145,221,000 |
Is there a way to present the GNU Screen session name and window title in the prompt of the shell (let us say, the Bash prompt defined by PS1)?
|
Screen supplies some environment variables (from screen(1) manpage):
STY Alternate socket name.
WINDOW Window number of a window (at creation time).
The "at creation time" means that if you renumber a window (using screen's number command), the shell will not be told about the change and $WINDO... | Showing GNU screen session name and window title in shell prompt |
1,337,145,221,000 |
My scenario is this:
I have a screen session running in a remote location. Inside this screen is a consoled-based program. When run without screen, this program starts in the terminal and accepts commands on its standard input.
What I want is a way to remotely send a command to screen so that this command is received ... |
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... | Sending input to a screen session from outside |
1,337,145,221,000 |
I'm working with emacs (on the terminal) and I use screen to switch between terminals. The key combination Ctrl+A is grabbed by screen. Is there a way to change screen key binding?
|
Sure, you can change the binding in either Screen or Emacs.
I use Ctrl+\ in Screen, which is used by very few applications. It's used in the terminal to send the QUIT signal — a stronger version of Ctrl+C, which fewer applications catch and may produce a core dump. That's rarely useful, and if you need it you can pres... | Working with screen and emacs |
1,337,145,221,000 |
When I search a terminal window in tmux, it sets the cursor the keyword search, but doesn't highlight the matching word. Screen used to do this, and it was much easier to visually find a match.
Thanks!
|
According to the developer1, this isn't currently possible in tmux.
[1] http://sourceforge.net/mailarchive/message.php?msg_id=27427973
| How do I highlight a search result in tmux? |
1,337,145,221,000 |
I have several long-running GNU screen sessions. I ssh to the box they're running on and run screen -d -r foo to detach them if they're connected anywhere else, and then attach them in my current window.
99% of the time this works fine, but on occasion I get this:
$ screen -d -r foo
[2430.foo detached.]
...and nothin... |
Not sure if I had the same issue as you, but sometimes I've the similar screen behaviour every time I network was accidentaly disconnected.
After a while ( about 10-15 minutes ) screen is available again for reconnection. After some invetigations, I've found a small note in the man page:
nonblock [on|off|numsecs]
... | GNU screen freezes trying to reattach |
1,337,145,221,000 |
I login as root and can not see the screen created by other others using screen -ls. I think the root user could have way to access those screen, but I can't find useful options of screen:
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
-4 Use IPv4.
-6 Use IPv6.
-a ... |
Unless the screen session in question is created with multiuser on, you can't. Even if you set your SCREENDIR variable to point at the other user's socket directory, screen will just complain that you don't own the directory and quit when you try to use it.
Of course, you can simply su to the other user and use screen... | How to access screen created by other users? |
1,337,145,221,000 |
I often leave tasks running within screen so that I can check on them later, but I sometimes need to check which command is running within the screen. It's usually a php script of sorts, such as
screen -d -m nice -n -10 php -f convertThread.php start=10000
I don't record which screens are running which command, but I... |
I recently had to do this. On Stack Overflow I answered how to find the PID of the process running in screen. Once you have the PID you can use ps to get the command. Here is the contents of that answer with some additional content to address your situation:
You can get the PID of the screen sessions here like so:
$ s... | Find out which command is running within a screen session |
1,337,145,221,000 |
I'm trying to make an ssh connection (via lsh) from one Ubuntu host to another from within screen. If I try to run mc right after that I get the following error:
Unknown terminal: screen-256color-s
Check the TERM environment variable.
Also make sure that the terminal is defined in the terminfo database.
Alternatively,... |
Finally, I've managed to figure out "obvious" package which supply screen-256-color-s (got to be installed on remote machine):
sudo apt install ncurses-term
fixed the problem for me: nice 256 colors and no need for ugly workarounds with environment variables. Hooray! :)
| ssh from screen leads to unknown terminal error |
1,337,145,221,000 |
I would like to know if there is a way to get tmux to behave like screen -D -R so I could say, have the command as a default command in Putty.
These screen switches would force detach of an existing screen session for my user (even if it was still active and logged-in somewhere else) and reattach it to the current ses... |
Yes: tmux attach -d || tmux new.
-d is necessary to behave like screen -D, ie, detach everybody else.
Connect by ssh, then attach or create could be something like:
$ cat bin/stmux
#!/bin/sh
exec ssh -t "$@" 'tmux attach -d || tmux new'
$ stmux my.remote.box
| Is there a tmux equivalent of "screen -D -R" |
1,337,145,221,000 |
I am looking for suggestions for a setup for my particular needs. I haven't done much linux since college and want to get back into it as a hobby. I have some not-too-powerful hardware (512 MB ram, single core). I want to do everything via text-based shells and editors, such as vim. My goal is to never touch the m... |
I read through your questions several times before I realized that I definitely have a recommendation for you: vim with tmux: http://tmux.sourceforge.net/
tmux is a screen 'multiplexor' that lets you have several windows and panes 'within 1'
It is a successor to the venerable 'screen' program, long a staple of many c... | Suggested setup for an ultra-lightweight text-based programming environment in linux |
1,337,145,221,000 |
When working at a normal xterm (not sure about a "real" terminal), when a full-screen program such as man or vim is closed, it disappears, leaving your screen so you can see your prompt, and previous prompts including where you launched the program that closed.
When I am running within GNU Screen, however, when the pr... |
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 d... | Clearing GNU Screen after full-screen application |
1,337,145,221,000 |
Is there any way to make GNU Screen not close if I end all its subprocesses? Ideally, it would create a new window running a shell if I accidentally closed the last window.
|
Assuming you're using bash and accidentally closes the shell with Ctrl-D, you can
export IGNOREEOF=1
This will give you a warning and require you to press Ctrl-D twice, or type exit instead.
| Prevent GNU Screen from closing |
1,337,145,221,000 |
I'm using screen (the problematically named terminal session manager) on a remote system accessed over SSH - to run long running processes and such. I have eventually started using a command to attach directly to the screen session, instead of first logging in through SSH and then start screen:
ssh -t hostname screen ... |
From the man pages of GNU screen:
-s program
sets the default shell to the program specified, instead of the value
in the environment variable $SHELL (or "/bin/sh" if not defined). This
can also be defined through the "shell" .screenrc command.
...
shell command
Set the command to be used to create a new shell. Thi... | Running GNU screen through SSH, the shell is not a login shell? |
1,337,145,221,000 |
I've been searching to find a way to send a command to a detached screen session. So far, so good. This is what I've come up with:
$ screen -S test -p 0 -X stuff 'command\n'
This command works as it should. But, I would like the output from it too, echoed straight in front of my eyes (no need for a .log file or somet... |
Use a first in first out pipe:
mkfifo /tmp/test
Use a redirect operator. Redirect command's output to /tmp/test for example like this:
screen -S test -p 0 -X stuff 'command >/tmp/test\n'
Then in another shell
tail -f /tmp/test.
Note you may also want to redirect error messages using the 2>&1 operator.
Example
As re... | Send command to detached screen and get the output |
1,337,145,221,000 |
My current screen session has 12 open windows on it. It's been running for weeks... I know I executed an ImageMagick convert command in one of these 12 screen windows sometime last week... is there any way I can easily search through the Bash history of all 12 instances, without closing them or running history | grep ... |
You can run history -a; history -c in all windows to save the history. And then history -r to refresh it.
To solve it more permanently add this to your .bashrc:
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
| Can I easily search my history across many screen windows? |
1,337,145,221,000 |
I would like to create a bash script to automatically open a screen window with 4 sessions running predetermined commands. I'd like to open htop and slurm on the top two frames, squidview in the middle large frame and a blank terminal on the bottom large frame. Is this possible to set up with a single bash script?
|
This does something like you desire:
$ cat my_screenrc
screen top
split
focus down
screen vmstat 1
split
focus down
screen
focus bottom
$ screen -c my_screenrc
screen appears to be more directed toward screen flipping than multiple panels and the documentation is pretty arcane.
| Opening multiple split windows with GNU screen with single bash script |
1,337,145,221,000 |
I ssh-connect an ubuntu server from an ubuntu client machine. And resume my screen session by running screen -d -r name. I'm not able to scroll inside the screen session. I created my screen session by running screen -S name. Do I have to pass any extra flag to make the scrolling work?
|
By default Screen will keep a scrollback buffer, but you can't use it the same way as the "conventional" scrollback buffer maintained by your terminal emulator. I.e. you can't use your mouse to scroll up.
You need use screen key bindings to enable copy/scrollback mode.
For me that is with CTRL+a ESC
(screen will not... | How to scroll inside a screen session of an ssh connection? |
1,337,145,221,000 |
Running screen I see this:
How can I start screen directly, without this welcome screen?
|
Add startup_message off to your .screenrc:
startup_message on|off
Select whether you want to see the copyright notice during startup.
Default is `on', as you probably noticed.
Actually, the default is to display the startup message only when screen is not passed any argument.
| Starting screen without welcome screen |
1,337,145,221,000 |
I'd like to configure SSH and screen such that a login will always reattach to a screen session. Ideally, that session would not quit but detach when I press C-d. How can this be achieved? And what other useful settings are there to make my SSH-life easier?
|
I just did the following for all of my servers so that when I connect via SSH I am automatically put into a Screen session.
Add the following to the ~/.bashrc for your user accounts:
# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
# if we're coming from a remote SSH connection, in an interacti... | How to effectively use screen and SSH? |
1,337,145,221,000 |
I am trying to download a file with wget but in background and inside a screen that detaches ...
My initial command was:
wget http://www.example.com/file.zip -O temp/file.zip; mv temp/file.zip downloads/file.zip;
That would nicely move file once downloaded, preventing me from handling downloads/ files while they sti... |
It works if I specify bash -c
screen -dm bash -c 'command1; command2;'
User meuh provided this solution in comments, thanks.
| run two commands in screen detached |
1,337,145,221,000 |
I just learned about screen and it looks wonderful.
Some questions:
How do they actually work?
Why are downloads / process not interrupted in screens even though something bad happened?
|
Very briefly (it's possible to write several pages on the topic): screen works by
setting up a server process that takes over all input/output directly to your terminal,
starting client processes for each window that you create, and
connecting the server and clients as they are started using a pseudo-terminal connect... | How does `screen` actually work? |
1,337,145,221,000 |
I'm using a recent version of GNU Screen, supporting vertical splits.
Once I have split a window in 2, how can I switch so that they are both dividing the whole region in half horizontally versus vertical?
I need to change to horizontal in order to copy some text with mouse from one window without the visual selection... |
GNU screen doesn't come with any layouts predefined, so you need to roll your own. Here is what I've added to my ~/.screenrc :
# define layouts
layout new 'horizontal'
split
layout new 'vertical'
split -v
layout new 'main'
# bind control sequences for new layouts
bind V layout select 'vertical'
bind H layout select... | GNU Screen switch from vertical split to horizontal and back |
1,337,145,221,000 |
Is there a way I can open a new 'screen' session on my RHEL box as a non-root user? When I try to open a new screen using the 'screen' command as a non-root user, it fails and I get the following message:
Cannot open your terminal '/dev/pts/2' - please check.
I researched a little bit and found people suggesting to c... |
This is a known problem, if you ssh as root somewhere and then su to become a normal user:
$ ssh root@server
# su -l anthon
$ screen
Cannot open your terminal '/dev/pts/3' - please check.
It is e.g. described in these posts from 2005
The solution is to directly login as the user you want the screen session to run as... | How can I start a 'screen' session as non-root user |
1,337,145,221,000 |
I have a Python script test.py that only contains: print('hi'). I want to run it in a screen so that the output of the screen is saved by script.
I use the following command to run test.py in a screen, it works fine:
screen -dm bash -c 'python test.py'
However, I haven't managed yet to find a way to use script to sav... |
You should do it the other way round, run script inside screen:
screen -dm bash -c 'script -c "python test.py" output.txt'
| How can I save the output of a detached screen with script? |
1,337,145,221,000 |
When running a bash script, I would like to be able to tell if it is running within a screen. Is this possible?
I want this so that .bashrc can set the colour of the command prompt depending on whether the sessions is started within a screen or not.
Discovered this link once mine was answered: How can I tell whether I... |
Typically, $STY will be set.
So:
if [ -n "$STY" ]; then
echo "I'm most likely running under screen"
fi
$STY is typically what you need to talk to your screen. That is used to construct the path of the Unix domain socket used to control screen (something like /var/run/screen/S-$USER/$STY.
Now, that won't work for in... | How to tell if terminal session is running within screen |
1,337,145,221,000 |
I have had a GNU screen session running for days. I find myself in the situation that I need to save the terminal contents (which I can scroll up to see) into a file. Is this possible? I estimate it to be below 5000 lines.
I found a way to set up screen to log future output to a file. But in this case, I need to also... |
You can use hardcopy -h command to save the contents of the current scroll buffer
to a file. As described in man screen:
hardcopy [-h] [file]
Writes out the currently displayed image to the file file, or,
if no filename is specified, to hardcopy.n in the default
directory, where n is the number of the c... | Save past GNU screen output to a file |
1,337,145,221,000 |
I want to start a program with SSH using PHP, which works fine, but now I want to kill the screen with PHP, but the only thing I know is the name of the screen. How do I find out the screen ID (automatically)?
|
You can use the environment variable $STY to determine whether you're in a screen session and also what the name of the session is that you're inside.
Example
Initially we're sitting in a terminal window, not inside of a screen session.
$ echo $STY
$
Spin up a screen session:
$ screen -ls
There is a screen on:
3... | Find out screen id |
1,337,145,221,000 |
I have to run some scripts in a screen and I used the C-a H command to record the output to a screenlog.0 file when I press the shortcut keys the message is Logfile "screenlog.O" closed. But if I try to find it with locate screenlog.0 it doesn't show up.
Where can I find the screenlog.0 file?
|
You can find the screenlog.0 file in screen's current working directory (cwd). This is either the directory that was the cwd when you started screen, or it's a directory you subsequently changed to using the :chdir screen command.
The easiest way to find out what this directory is is to open a new window with a shell ... | Where can I find the screenlog.0 file? |
1,337,145,221,000 |
I am running an interactive curses program in a screen session on quite weak hardware. Most of the time, the screen is detached. Is there a way for this program to detect this situation, and basically stop painting on the screen?
|
There's an irssi script called screen_away that sets your away status based on whether or not the screen is attached. It works like this:
Every shell running within a screen will have the STY environment variable set to the socket name. You can run screen -ls to get the path where all the sockets are stored:
$ screen ... | Can a program detect it is running in a detached screen? |
1,381,981,716,000 |
I want to know if it is possible to make emacs, when running in a gnu screen or tmux session, use the same colors as when TERM=xterm. In a gnu screen or tmux session, TERM=screen and emacs uses a different set of colors as compared to when TERM=xterm.
For example, when TERM=xterm-256color, the foreground color of fon... |
The definition of font-lock-comment-face includes many variants for cases of varying color support.
The chocolate1 variant is used when there are at least 88 colors available and the “background” is “dark”.
The Firebrick variant is used when there are at least 88 colors available and the “background” is “light”.
The... | emacs colors based on $TERM environment variable |
1,381,981,716,000 |
I use the screen Screen visual consoles.
To detach a screen I need to press Ctrl+A followed by D but some time a session is closed without detaching it.
It appears as (Attached) on screen -list:
eduard@eduard-X:~$ screen -list
There are screens on:
4561.pts-46.eduard-X (30.03.2015 14:48:51) (Attached)
... |
Sure, with
screen -d -r
You can choose which screen to detach and reattach as usual by finding the pid (or complete name) with screen -list.
screen -d -r 12345
| How can I resume a screen that I did not manage to detach? |
1,381,981,716,000 |
When I use screen I can only see the current data on the terminal (commands, messages, etc.).
Is there a way, apart from printing anything I want to a file, to see the previous messages (the same way a normal terminal emulator would)?
|
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 ~/.scree... | Is there a way to show previous messages in screen? |
1,381,981,716,000 |
By default, the title of a screen session is the name of the last command entered, which is fine for me, but in some cases I'd like to change it. I know the command Ctrl-A A, but it only changes the title until the next command, and I'd like it to stay there until I decide otherwise.
EDIT:
Here's the preexec function ... |
Depends how things are set up, but by default, something like this should work.
settitle() {
printf "\033k$1\033\\"
}
Then run:
settitle NEWTITLE.
See screen title docs and GNU screen faq for more details.
Given Ctrl+A A is only changing it until the next command, it's probably being set by $PS1 (all shells), or ... | Force title on GNU screen |
1,381,981,716,000 |
I use GNU screen a lot with zsh as my shell. It would be a nice feature (I think) to be able to display the current directory name (not the full path) as the tab title. I can do that with CTRL+A SHIFT+A but that is manual. I would like it to change whenever I change directory.
Does anyone know of a way to do this?... |
For zsh:
Put this in your ~/.zsh
[centos@centos ~]$ cat .zsh
if [[ ${TERM} == "screen-bce" || ${TERM} == "screen" ]]; then
precmd () { print -Pn "\033k\033\134\033k%m[%1d]\033\134" }
preexec () { print -Pn "\033k\033\134\033k%m[$1]\033\134" }
else
precmd () { print -Pn "\e]0;%n@%m: %~\a" }
preexec () { print -... | Screen status bar to display current directory for zsh/bash shell |
1,381,981,716,000 |
In vim, there's a CtrlV to do block selection.
How can I do it in screen?
|
Assuming you already know how to use Space to do normal selection in screen's copy mode, the only new keys you need are c to set the left margin, and C to set the right margin.
This is described in the screen manual.
| How to do block selection in `screen` |
1,381,981,716,000 |
Using the screen terminal environment, I ofen enter copy mode by using Ctrl-aEsc. However, the scrollable output is often too short for me to view the desired information.
What do I modify to extend the length of this output?
|
It's all there on the screen man page:
You can do it from the command line when you start screen:
-h num
Specifies the history scrollback buffer to be num lines high.
Or from the .screenrc file:
defscrollback num
Same as the scrollback command except that the default setting for
new windows is changed. Initi... | Extend the scrollable content of gnu-screen? |
1,381,981,716,000 |
In a script I am building I'm experimenting with how to automate as much as possible. One of the more interesting challenges is to connect to a byobu screen session and execute a command.
So I started in the obvious place, looking on how many screen sessions there are (game has 3 windows in byobu and lordquackstar has... |
You can directly attach to a previously detached byobu/screen session including the window:
byobu -r -p2
will reattach into window 2 (or a named one).
-X can send any command to a byobu/screen session and also works with the -p switch.
byobu -p2 -X stuff "uname -a $(echo -ne '\r')"
This will send a uname -a to the s... | Connect to byobu screen session and execute command? |
1,381,981,716,000 |
I noticed a difference in 'env' before and after a 'screen' call, is there any additional clarity on what gets called (for setting environment variables)?
I couldn't see any clear explanation from a quick search on 'man screen'
Some googled queries on the topic:
http://alan.lamielle.net/2009/03/09/environment-varia... |
A process inherits the environment variables from the parent, this means the first time you call screen (create a new one) it has a copy of all the environment variables of the parent process. Now screen adjusts/creates some variables like COLUMNS, LINES, TERM, TERMCAP, WINDOW and STY. You can also adjust or delete en... | How does 'screen' impact environment variables? |
1,381,981,716,000 |
For a while now I've been using Byobu to manage screen sessions for me. However I've run into a strange issue: The session keeps locking. By locking I mean that I can't type anything, and only if I wait a few minuites does unlock and do everything I typed in before.
Currently its getting worse. The session keeps lock... |
Try this, it worked for me on putty:
Ctrl+Q - XON
Ctrl+S - XOFF
| Byobu/screen constantly freezes in Putty |
1,381,981,716,000 |
I have a systemctl service that starts a process smd-loop in a screen session. This process requires acces to remote SSH sources (for syncing purposes) and thus needs to be able to access my id_dsa private key.
How can I set up the systemd service so that it will work? The following service starts the process correctl... |
You need to put the identity files containing not encrypted private key into ~/.ssh directory of the user the service is running. Also, you need to set the HOME environment variable for it, for example if it is run as root:
ExecStart=/usr/bin/env HOME=/root /usr/bin/screen -S smd-loop-win -md "smd-loop"
Alternatively... | systemd service that needs .ssh/id_dsa password |
1,381,981,716,000 |
Today I finally decided to reinstall OS on my home server from CentOS 5 to CentOS 7. Along with that, I decided to try tmux instead of screen that I was using for ages.
I was able to reconfigure its look&feel almost perfectly for my needs but there is still one annoying thing.
In screen, when I do some actions (for ex... |
short: in your .tmux.conf
set -g visual-bell on
long:
Some applications check both the bel and flash terminal capabilities, and allow you to choose which will be used. tmux does not. It reads only bel, so you could modify your terminal description to change the bel to a string for flashing the display.
That might w... | Blink tmux instead of sound |
1,381,981,716,000 |
A process listening on port 8113 (Solr) is not responding. I've found its PID via netstat but the server has about two dozen Solr process running in various screen sessions.
3607.foobar-client2 (12/27/14 20:54:02) (Detached)
3797.solr.bo.app (12/25/14 11:51:30) (Detached)
2962.solr (12/25/14 11:47:23... |
Found it!
To find the screen instance in which PID 351 is running, search the PID 351 environment for the string "STY=":
$ grep -z '^STY=' /proc/351/environ
STY=1410.neverFindMe
Or using ps (if screen session names don't contain space characters):
$ ps wwep 351 | grep -o 'STY=\S*'
STY=1410.neverFindMe
| Identify in which screen instance a process is running |
1,381,981,716,000 |
I would like to use screen (from GNOME Terminal, via ssh) like I use GNOME Terminal without screen, or as close as possible to that. Specifically:
In GNOME Terminal, I can scroll back using the mouse wheel, the scrollbar or Shift+PgUp/PgDn.
In screen, I have to go to copy mode (Ctrl+A,[) to be able to scroll back (mo... |
Perhaps you cannot have what you are asking.
From the terminal's standpoint:
screen is a full-screen (no pun) application just like vi or less.
the terminal implements scrolling and an alternate screen.
when the terminal is in alternate-screen mode, it does not add to its scrollback area as it would in normal mode.
i... | Make screen work like a terminal (scrolling + alternate screen) [duplicate] |
1,381,981,716,000 |
I've set up a systemd service to run my Minecraft server. Now, I need it to repeat the start script when the server crashes.
Here's my code so far:
#!/bin/bash
while true; do
cd /home/mcserver/Spigot
echo Starting Spigot...
echo 600 > ./restart-info
java -jar spigot.jar
echo Server has stopped or ... |
I don't want to use screen with -d and -m because it'll run in the background and the script will keep restarting my server.
So use -D instead of -d (note the capital case!)
-D -m This also starts screen in "detached" mode, but doesn't fork a
new process. The command exits if the session terminates.
As screen w... | How to control systemd service using screen? |
1,381,981,716,000 |
Sometimes my script bugs out and multiple screen sessions with the same name get created. Is there a way to kill all of these with this name in one command?
Rx:/scripts# screen -S haydoz-script -X quit
There are several suitable screens on:
13372.haydoz-script (09/10/11 07:44:05) (Detached)
122... |
If there are no other screen sessions running you can use the "hard" way and just kill them with killall screen.
If you want to be nice you can iterate over your list of screen sessions and kill them one after another:
# screen -S foo && screen -S foo
[detached]
[detached]
# screen -ls
There are screens on: ... | Killing multiple GNU screen sessions with the same name |
1,381,981,716,000 |
I'd like to do a one line bash command that automatically does this:
screen -S myserver
python myserver.py # inside the new screen
CTRL A, D (detach)
I think this won't work:
screen -S myserver && python myserver.py
because python myserver.py won't be started inside the screen.
|
You can detach right after starting a program inside of screen:
screen -dmS myserver python myserver.py
From screen's man page
-d -m
Start screen in detached mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
| Create a screen, launch a command in it and detach |
1,381,981,716,000 |
I have a few long running commands that I would like to run together in the same screen (same tab in the terminal app).
My current setup is like this:
tmux new-session -d 'cmd1'
tmux split-window 'cmd2'
tmux split-window 'cmd3'
tmux attach
However, it seems that tmux split-window actually splits the last split, so if... |
Just add the following command before your tmux attach
tmux select-layout even-vertical
| Running several commands in a screen-split |
1,381,981,716,000 |
tmux and screen let you run different processes (e.g. vim, a bash script, mysql, psql, etc) in different virtual windows. But traditional Unix job control (using CTRL-z, fg, bg, and jobs) seem to give you some of the same functionality.
Are there any advantages of multitasking using traditional job control over the ne... |
Suppose you've just started a program outside screen. Suddenly you realize you wanted to do something else in that terminal. Ctrl+Z.
Screen and tmux introduce a layer of isolation between the application and the terminal. This isn't always a good thing. For example, I find their scrollback a lot less convenient than x... | What are the virtues of multitasking with traditional job control vs Tmux/Screen? |
1,381,981,716,000 |
I'm trying to figure out how to make a script that will be able to send commands to a screen that will execute within whatever the screen is doing. Is this possible, and if so, how is it done? I've already tried screen -X etc, and it is not executing the commands.
|
Well it depends on the commands you need to execute:
If you need to execute commands in an existing screen session, you need to re-attach and execute the commands using this command line:
screen -r -S "<screenName>" "command/or/script/to/execute"
If want to execute the commands inside of a new screen session, you can... | Linux - Sending a command to a screen through a shell script? [duplicate] |
1,381,981,716,000 |
Why does tmux report
$TERM=screen-256color
Normally kitty reports
$TERM=xterm-kitty
Which should I use if I run tmux inside kitty? Obviously kitty provides advanced functionality and that makes sense that it reports xterm-kitty. Why does screen report that it's screen-256 are there programs that need to be aware tha... |
Which should I use if I run tmux inside kitty?
When running tmux then you must use TERM=screen, TERM=tmux, or one of the derivatives e.g. TERM=screen-256color or TERM=tmux-256color.
man tmux(1) states ...
The TERM environment variable must be set to “screen” for all programs running inside tmux. New windows will a... | Screen and kitty what should $TERM be? |
1,381,981,716,000 |
I need to determine if a file contains a certain regex at a certain line and to return true (exit 0) if found, and otherwise false. Maybe I'm overthinking this, but my attempts proved a tad unwieldy. I have a solution, but I'm looking for maybe others that I hadn't thought of. I could use perl, but I'm hoping to keep ... |
With GNU sed:
sed -n '132 {/^#termcapinfo[[:space:]]*xterm Z0=/q}; $q1'
How it works
132 {/^#termcapinfo[[:space:]]*xterm Z0=/q}
On line 132, check for the regex ^#termcapinfo[[:space:]]*xterm Z0=. If found quit, q, with the default exit code of 0. The rest of the file is skipped.
$q1
If we reach the last line, $... | awk or sed command to match regex at specific line, exit true if success, false otherwise |
1,381,981,716,000 |
A former coworker configured screen for me and I just found out I could change this, but I don't know what the setting is supposed to be and the man page is a little vague.
I've got this in my .screenrc
# no annoying audible bell, please
vbell on
I don't have a vbell msg defined, but the man page says the default vb... |
You can do what you want in a terminal-independent way using just your .screenrc:
vbell on
vbell_msg ''
termcapinfo * vb=:
The settings are:
first line (you already did this)
second line cancels the Wuff, Wuff!
third line sets the flash to an empty string
Note that the trailing colon (:) is needed for the termcap ... | Preventing bell flash with screen in putty |
1,381,981,716,000 |
I saw many place introduce screen to run background job stably even log out. They use
screen -dmS name
According to screen -h, this option means
-dmS name Start as daemon: Screen session in detached mode.
What is daemon? I don't understand.
I found that if I simply type screen, I can enter automatically into a ... |
You would only use -dm if you want to run a command in a screen session and not enter it interactively
-S is just to give the session a usable name so you can reconnect to it again easily later
If you want to use it interactively and don't want to give it a human readable name, you can omit all of those arguments safe... | Do I really need -dmS option in screen to run background job stably even log out? |
1,381,981,716,000 |
My goal is to remote to a server through ssh, start a screen, start a script, let the script run, and exit the ssh session while keeping the screen running its own python script. This is what I have:
ssh -t myuser@hostname screen python somepath.py -s 'potato'
The problem with this is, after I run it, I have to manua... |
You can use -d -m to your screen session to do it like:
ssh myuser@hostname screen -d -m "python somepath.py -s 'potato'"
That will create a new screen session, run your command in it and automatically detach you from it.
That option is documented as
-d -m
Start screen in detached mode. This creates a new sessi... | Remotely starting a screen session through ssh and closing the ssh session immediately |
1,381,981,716,000 |
I'm looking at http://taint.org/wk/RemoteLoginAutoScreen to setup my server so it autostarts a screen session when I login via SSH.
I have added the following to my .bashrc:
# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
# if we're coming from a remote SSH connection, in an interactive sessio... |
Change it to:
if [ -z "$STARTED_SCREEN" ] && [ -n "$SSH_TTY" ]
then
case $- in
(*i*)
STARTED_SCREEN=1; export STARTED_SCREEN
mkdir -p -- "$HOME/lib/screen-logs"
screen -RR -S main ||
echo >&2 "Screen failed! continuing with normal bash startup"
esac
fi
That is attach (or create) the... | Problems with automatically starting screen on SSH login |
1,381,981,716,000 |
I've been trying to set up an automated backup system for a minecraft server, and I'm having trouble with screen, specifically when using 'screen -r sessionname -X "/var/minecraft/somebatchfile"', nothing happens.
My process flow is somewhat like this at the moment:
screen -m -d -S minecraft /var/minecraft/bin/server_... |
You have to give the parameter -X a screen command, I think you want to "stuff" a minecraft-server command to the screen session.
screen -r minecraft -p 0 -X stuff "stop $(printf '\r')"
The printf send a carriage return, so the command "stop" gets executed. -p 0 makes sure the characters are sent to the initial Scree... | Why is screen seemingly doing nothing with commands passed with -X? |
1,381,981,716,000 |
When in a screen session via ssh, if I attempt to connect to another host via scp or ssh and the auth fails, any subsequent text I type in the terminal will not be displayed, however it is being entered and can be executed.
[user@host Oracle]$ scp user2@host2:/path/to/files .
user2@host2's password:
Permission de... |
stty sane, or more specifically stty echo, should turn echo back on. (stty sane will fix other terminal input or output oddities such as newlines not going back to the left margin.)
Ssh (and most other programs) turn echo off for the password prompt, i.e., the characters you type are not displayed (echoed) to the scre... | Screen, remote login failure, and disappearing text |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.