Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия | |||
— | screen [2025/07/06 12:39] (текущий) – внешнее изменение 127.0.0.1 | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | ====== Использование Screen оконного менеджера для терминала ====== | ||
+ | |||
+ | {{htmlmetatags> | ||
+ | metatag-description=(Screen — свободная консольная утилита-мультиплексор, | ||
+ | }} | ||
+ | |||
+ | |||
+ | **Screen** - терминальный [[мультиплексор|мультиплексор]], | ||
+ | |||
+ | Возможно, | ||
+ | сессию до разрыва SSH-соединения, | ||
+ | |||
+ | ===== Начало работы в screen ===== | ||
+ | |||
+ | Все, что необходимо для запуска процесса под управлением программы screen, - это поместить команду screen перед командой запуска долгоживущего процесса, | ||
+ | |||
+ | Первый запуск Screen с заданием понятного имени, например darkfire | ||
+ | < | ||
+ | screen -S darkfire | ||
+ | |||
+ | # Проверяем | ||
+ | screen -ls | ||
+ | |||
+ | There is a screen on: | ||
+ | 21598.darkfire | ||
+ | 1 Socket in / | ||
+ | |||
+ | </ | ||
+ | |||
+ | Подключение к запущенному | ||
+ | < | ||
+ | screen -rda name | ||
+ | </ | ||
+ | |||
+ | если сессия одна, достаточно просто команды: | ||
+ | < | ||
+ | $ screen –x | ||
+ | </ | ||
+ | если сессий несколько, | ||
+ | < | ||
+ | $ screen -ls | ||
+ | There are screens on: | ||
+ | 2762.pts-0.debian | ||
+ | 2743.pts-0.debian | ||
+ | 2 Sockets in / | ||
+ | </ | ||
+ | Выбираем нужный нам screen, и присоединяемся к нему: | ||
+ | |||
+ | < | ||
+ | screen -x 2762.pts-0.debian | ||
+ | </ | ||
+ | ===== Сочетания клавиш screen и список основных команд ===== | ||
+ | * screen — запуск новой сессии; | ||
+ | * screen -ls — просмотр всех сессий; | ||
+ | * screen -r < | ||
+ | |||
+ | В самом screen, почти все сочетания клавиш работают через комбинацию [ Ctrl+a ], то есть сначала нажимаете ее, а уже затем управляющую комбинацию, | ||
+ | |||
+ | * Для переключения между окнами - Ctrl+a a - между последним активным. | ||
+ | * Ctrl+a < | ||
+ | * Ctrl+a (p|n) - циклическое перемещение между окнами. p - prev, n - next. | ||
+ | * Ctrl+a " - список окон для переключения. | ||
+ | |||
+ | * Ctrl + A + D — свернуть сессию. Отсоединить screen от экрана, | ||
+ | * Ctrl + A + K — завершить сессию. Убить окно текущее окно терминала (попросит подтверждения). | ||
+ | * Ctrl+a, Ctrl+C или с Запустить еще один терминал. Создание нового окна. | ||
+ | * Ctrl+a, \ Закрыть screen, все виртуальные терминалы будут при это убиты (попросит подтверждения). | ||
+ | |||
+ | * F11 - Переключение между виртуальными терминалами, | ||
+ | * F12 - Переключение между виртуальными терминалами, | ||
+ | * Ctrl+a, A Изменить название окна. | ||
+ | * [ctrl]+[a] [Shift S] разделяет экран на 2 горизонтальные полосы (верхняя и нижняя). | ||
+ | * [ctrl]+[a] [TAB] переключаться между ними. Очень полезно для ввода команд в одном " | ||
+ | * [ctrl]+[a] [x] Блокировка всего screen. Для разблокировки нужно ввести свой пароль. | ||
+ | ====== Конфигурация screen файл .screenrc ====== | ||
+ | После установки в каталоге /etc (/ | ||
+ | < | ||
+ | $ nano ~/.screenrc | ||
+ | |||
+ | # default windows | ||
+ | # | ||
+ | |||
+ | # screen -t local 0 | ||
+ | # screen -t mail 1 mutt | ||
+ | # screen -t 40 2 rlogin server | ||
+ | |||
+ | # caption always "%3n %t%? @%u%?%? [%h]%? | ||
+ | # hardstatus alwaysignore | ||
+ | |||
+ | hardstatus alwayslastline "%Lw %c" # резервирует последнюю строку экрана под строку статуса | ||
+ | |||
+ | screen -t mc # создает пустое окно с именем указанным после ключа -t | ||
+ | exec /usr/bin/mc # запукает программу в этом окне | ||
+ | |||
+ | screen -t top | ||
+ | exec / | ||
+ | |||
+ | |||
+ | select 0 # указывает номер окна, которое будет активным при запуске | ||
+ | </ | ||
+ | |||
+ | * Типовой конфиг для screen (~/ | ||
+ | <file bash> | ||
+ | # Отключаем приветствие | ||
+ | startup_message off | ||
+ | # Включаем utf8 | ||
+ | defutf8 on | ||
+ | # Использовать визуальный сигнал (мигание экрана) вместо писка динамика | ||
+ | vbell on | ||
+ | # Размер буфера прокрутки | ||
+ | defscrollback 1000 | ||
+ | # Производить отключение сессии при разрыве связи с терминалом | ||
+ | autodetach on | ||
+ | # Открывать Login-шелл | ||
+ | shell -$SHELL | ||
+ | # Активировать возможность прокрутки в xterm (и других эмуляторах терминала) | ||
+ | termcapinfo xterm* ti@:te@ | ||
+ | # Волшебная строка | ||
+ | shelltitle '$ |sh' | ||
+ | # Строка состояния | ||
+ | hardstatus alwayslastline "%{+b wk} %c $LOGNAME@%H %=[ %w ] " | ||
+ | </ | ||
+ | |||
+ | |||
+ | * Рабочий конфиг screenrc | ||
+ | <file bash> | ||
+ | # Отключить вывод лицензионной информации при старте Screen | ||
+ | startup_message off | ||
+ | defscrollback 5000 | ||
+ | termcapinfo xterm ti@:te@ | ||
+ | termcapinfo xterm-color ti@:te@ | ||
+ | hardstatus alwayslastline | ||
+ | hardstatus string ' | ||
+ | vbell off | ||
+ | shell -$SHELL | ||
+ | logtstamp on | ||
+ | logtstamp after 1 | ||
+ | deflogin on | ||
+ | vbell off | ||
+ | vbell_msg " | ||
+ | |||
+ | termcap | ||
+ | terminfo sun ' | ||
+ | |||
+ | termcap | ||
+ | terminfo hp700 ' | ||
+ | |||
+ | termcap wy75-42 nx: | ||
+ | terminfo wy75-42 nx: | ||
+ | |||
+ | termcapinfo xterm-256color ti@:te@ | ||
+ | hardstatus string '%{= kG}[ %{G}%H %{g}][ %{= kw}%? | ||
+ | hardstatus string '%{+b rk}%H%{gk} |%c %{yk}%d.%m.%Y | %{wk} %? | ||
+ | </ | ||
+ | ====== Пример: | ||
+ | Например, | ||
+ | - Посмотрим список уже запущенных процессов через screen.< | ||
+ | # screen -ls | ||
+ | No Sockets found in / | ||
+ | </ | ||
+ | - Запускаем утилиту top:< | ||
+ | # screen top | ||
+ | </ | ||
+ | # screen -ls | ||
+ | There are screens on: | ||
+ | 14178.ttyp0.mail2 | ||
+ | 1 Sockets in / | ||
+ | </ | ||
+ | - Запускаем [[Midnight Commander]]< | ||
+ | # screen mc | ||
+ | </ | ||
+ | # screen -ls | ||
+ | There are screens on: | ||
+ | 14178.ttyp0.mail2 | ||
+ | 14185.ttyp0.mail2 | ||
+ | 2 Sockets in / | ||
+ | </ | ||
+ | # screen -r 14178 | ||
+ | </ | ||
+ | < | ||
+ | ===== Примеры использования Screen ===== | ||
+ | - [[rtorrent]] пример запуска в консоли Linux при помощи Screen | ||
+ | - [[https:// | ||
+ | |||
+ | ===== Полный .screenrc ===== | ||
+ | |||
+ | Оригинал [[https:// | ||
+ | < | ||
+ | # Copyright 1999-2011 Gentoo Foundation | ||
+ | # Distributed under the terms of the GNU General Public License v2 | ||
+ | # | ||
+ | # / | ||
+ | # | ||
+ | # This is the system wide screenrc. | ||
+ | # | ||
+ | # You can use this file to change the default behavior of screen system wide | ||
+ | # or copy it to ~/.screenrc and use it as a starting point for your own | ||
+ | # settings. | ||
+ | # | ||
+ | # Commands in this file are used to set options, bind screen functions to | ||
+ | # keys, redefine terminal capabilities, | ||
+ | # more windows at the beginning of your screen session. | ||
+ | # | ||
+ | # This is not a comprehensive list of options, look at the screen manual for | ||
+ | # details on everything that you can put in this file. | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # ============================================================================== | ||
+ | # SCREEN SETTINGS | ||
+ | # ============================================================================== | ||
+ | |||
+ | # ESCAPE - the COMMAND CHARACTER | ||
+ | # =============================================================== | ||
+ | # escape ^aa # default | ||
+ | # escape ^^^^ # suggested binding (Control-^) for Emacs users | ||
+ | |||
+ | |||
+ | # PASSWORD | ||
+ | # =============================================================== | ||
+ | # This commands sets the *internal* password for the screen session. | ||
+ | # WARNING!! If this is set then a " | ||
+ | # session after you enter the user's account password and then *also* | ||
+ | # the internal password for that session. This gives additional safety but, | ||
+ | # if you forget the internal password then you cannot resume your session. | ||
+ | # Use :password to generate a password | ||
+ | # password ODSJQf.4IJN7E | ||
+ | |||
+ | |||
+ | # VARIABLES | ||
+ | # =============================================================== | ||
+ | # No annoying audible bell, using " | ||
+ | # vbell on # default: off | ||
+ | # vbell_msg " | ||
+ | |||
+ | # Automatically detach on hangup. | ||
+ | autodetach on # default: on | ||
+ | |||
+ | # Don't display the copyright page | ||
+ | startup_message off # default: on | ||
+ | |||
+ | # Uses nethack-style messages | ||
+ | # nethack on # default: off | ||
+ | |||
+ | # Affects the copying of text regions | ||
+ | crlf off # default: off | ||
+ | |||
+ | # Enable/ | ||
+ | # In multiuser mode the commands acladd, aclchg, aclgrp and acldel can be used | ||
+ | # to enable (and disable) other user accessing this screen session. | ||
+ | # Requires suid-root. | ||
+ | multiuser off | ||
+ | |||
+ | # Change default scrollback value for new windows | ||
+ | defscrollback 10000 # default: 100 | ||
+ | |||
+ | # Define the time that all windows monitored for silence should | ||
+ | # wait before displaying a message. Default 30 seconds. | ||
+ | silencewait 15 # default: 30 | ||
+ | |||
+ | # bufferfile: | ||
+ | # " | ||
+ | bufferfile | ||
+ | # | ||
+ | # hardcopydir: | ||
+ | # hardcopydir | ||
+ | # hardcopydir | ||
+ | # | ||
+ | # shell: | ||
+ | # Makes it possible to use a different shell inside screen | ||
+ | # than is set as the default login shell. | ||
+ | # If begins with a ' | ||
+ | # shell zsh | ||
+ | # shell bash | ||
+ | # shell ksh | ||
+ | shell -$SHELL | ||
+ | |||
+ | # shellaka '> |tcsh' | ||
+ | # shelltitle '$ |bash' | ||
+ | |||
+ | # emulate .logout message | ||
+ | pow_detach_msg " | ||
+ | |||
+ | # caption always " %w --- %c:%s" | ||
+ | # caption always "%3n %t%? @%u%?%? [%h]%? | ||
+ | |||
+ | # advertise hardstatus support to $TERMCAP | ||
+ | termcapinfo | ||
+ | termcapinfo xterm* ti@:te@ | ||
+ | |||
+ | # set every new windows hardstatus line to somenthing descriptive | ||
+ | # defhstatus " | ||
+ | |||
+ | # don't kill window after the process died | ||
+ | # zombie " | ||
+ | |||
+ | # ignore displays that block on output | ||
+ | defnonblock on | ||
+ | |||
+ | # XTERM TWEAKS | ||
+ | # =============================================================== | ||
+ | |||
+ | # xterm understands both im/ic and doesn' | ||
+ | # Note: Do not specify im and ic in the real termcap/ | ||
+ | # some programs (e.g. vi) will not work anymore. | ||
+ | termcap | ||
+ | terminfo xterm hs@: | ||
+ | |||
+ | # 80/132 column switching must be enabled for ^AW to work | ||
+ | # change init sequence to not switch width | ||
+ | termcapinfo | ||
+ | |||
+ | # Make the output buffer large for (fast) xterms. | ||
+ | # termcapinfo xterm* OL=10000 | ||
+ | termcapinfo xterm* OL=100 | ||
+ | |||
+ | # tell screen that xterm can switch to dark background and has function | ||
+ | # keys. | ||
+ | termcapinfo xterm ' | ||
+ | termcapinfo xterm ' | ||
+ | termcapinfo xterm ' | ||
+ | |||
+ | # special xterm hardstatus: use the window title. | ||
+ | termcapinfo xterm ' | ||
+ | |||
+ | #terminfo xterm ' | ||
+ | termcapinfo xterm ' | ||
+ | |||
+ | # emulate part of the ' | ||
+ | termcapinfo xterm ' | ||
+ | |||
+ | # xterm-52 tweaks: | ||
+ | # - uses background color for delete operations | ||
+ | termcapinfo xterm* be | ||
+ | termcapinfo xterm* ti@:te@ | ||
+ | |||
+ | # Do not use xterm' | ||
+ | termcapinfo xterm|xterms|xs ti@: | ||
+ | |||
+ | # WYSE TERMINALS | ||
+ | # =============================================================== | ||
+ | |||
+ | #wyse-75-42 must have flow control (xo = " | ||
+ | #essential to have it here, as this is a slow terminal. | ||
+ | termcapinfo wy75-42 xo:hs@ | ||
+ | |||
+ | # New termcap sequences for cursor application mode. | ||
+ | termcapinfo wy* CS=\E[? | ||
+ | |||
+ | |||
+ | # OTHER TERMINALS | ||
+ | # =============================================================== | ||
+ | |||
+ | # make hp700 termcap/ | ||
+ | termcapinfo | ||
+ | |||
+ | # Extend the vt100 desciption by some sequences. | ||
+ | termcap | ||
+ | terminfo vt100* ms: | ||
+ | termcapinfo linux C8 | ||
+ | # old rxvt versions also need this | ||
+ | # termcapinfo rxvt C8 | ||
+ | |||
+ | |||
+ | # KEYBINDINGS | ||
+ | # ============================================================== | ||
+ | # The " | ||
+ | # SCREEN checks all the keys you type; you type the key | ||
+ | # which is known as the " | ||
+ | # eats this key, too, and checks whether this key is | ||
+ | # " | ||
+ | # | ||
+ | # The command " | ||
+ | # will be assigned to the commands. | ||
+ | # | ||
+ | # Some commands are bound to several keys - | ||
+ | # usually to both some letter and its corresponding | ||
+ | # control key combination, | ||
+ | # " | ||
+ | # | ||
+ | # The following list shows the default bindings: | ||
+ | # | ||
+ | # break ^B b | ||
+ | # clear C | ||
+ | # colon : | ||
+ | # copy ^[ [ | ||
+ | # detach | ||
+ | # digraph | ||
+ | # displays | ||
+ | # dumptermcap . | ||
+ | # fit F | ||
+ | # flow ^F f | ||
+ | # focus ^I | ||
+ | # hardcopy | ||
+ | # help ? | ||
+ | # history | ||
+ | # info i | ||
+ | # kill K k | ||
+ | # lastmsg | ||
+ | # license | ||
+ | # log H | ||
+ | # login L | ||
+ | # meta x | ||
+ | # monitor | ||
+ | # next ^@ ^N sp n | ||
+ | # number | ||
+ | # only Q | ||
+ | # other ^X | ||
+ | # pow_break | ||
+ | # pow_detach | ||
+ | # prev ^H ^P p ^? | ||
+ | # quit \ | ||
+ | # readbuf | ||
+ | # redisplay | ||
+ | # remove | ||
+ | # removebuf | ||
+ | # reset Z | ||
+ | # screen | ||
+ | # select | ||
+ | # silence | ||
+ | # split S | ||
+ | # suspend | ||
+ | # time ^T t | ||
+ | # title A | ||
+ | # vbell ^G | ||
+ | # version | ||
+ | # width W | ||
+ | # windows | ||
+ | # wrap ^R r | ||
+ | # writebuf | ||
+ | # xoff ^S s | ||
+ | # xon ^Q q | ||
+ | # ^] paste . | ||
+ | # - | ||
+ | # 0 | ||
+ | # 1 | ||
+ | # 2 | ||
+ | # 3 | ||
+ | # 4 | ||
+ | # 5 | ||
+ | # 6 | ||
+ | # 7 | ||
+ | # 8 | ||
+ | # 9 | ||
+ | # I login on | ||
+ | # O login off | ||
+ | # ] paste . | ||
+ | # | ||
+ | |||
+ | # And here are the default bind commands if you need them: | ||
+ | # | ||
+ | # bind A title | ||
+ | # bind C clear | ||
+ | # bind D pow_detach | ||
+ | # bind F fit | ||
+ | # bind H log | ||
+ | # bind I login on | ||
+ | # bind K kill | ||
+ | # bind L login | ||
+ | # bind M monitor | ||
+ | # bind N number | ||
+ | # bind O login off | ||
+ | # bind Q only | ||
+ | # bind S split | ||
+ | # bind W width | ||
+ | # bind X remove | ||
+ | # bind Z reset | ||
+ | |||
+ | # Let's remove some dangerous key bindings ... | ||
+ | bind k | ||
+ | bind ^k | ||
+ | # bind . dumptermcap # default | ||
+ | bind . | ||
+ | # bind ^\ quit # default | ||
+ | bind ^\ | ||
+ | # bind \\ quit # default | ||
+ | bind \\ | ||
+ | # bind ^h ??? # default | ||
+ | bind ^h | ||
+ | # bind h hardcopy | ||
+ | bind h | ||
+ | |||
+ | bindkey " | ||
+ | bindkey " | ||
+ | bindkey " | ||
+ | |||
+ | # ... and make them better. | ||
+ | bind ' | ||
+ | bind ' | ||
+ | bind ' | ||
+ | bind ' | ||
+ | |||
+ | # Yet another hack: | ||
+ | # Prepend/ | ||
+ | # This lets me have autoindent mode in vi. | ||
+ | register [ " | ||
+ | register ] " | ||
+ | bind ^] paste [.] | ||
+ | |||
+ | |||
+ | # hardstatus alwaysignore | ||
+ | # hardstatus alwayslastline " | ||
+ | |||
+ | # Resize the current region. The space will be removed from or added to | ||
+ | # the region below or if there' | ||
+ | bind = resize = | ||
+ | bind + resize +3 | ||
+ | bind - resize -3 | ||
+ | # bind _ resize max | ||
+ | # | ||
+ | # attrcolor u "-u b" | ||
+ | # attrcolor b " | ||
+ | |||
+ | # STARTUP SCREENS | ||
+ | # =============================================================== | ||
+ | # Defines the time screen delays a new message when one message | ||
+ | # is currently displayed. The default is 1 second. | ||
+ | # msgminwait 2 | ||
+ | |||
+ | # Time a message is displayed if screen is not disturbed by | ||
+ | # other activity. The dafault is 5 seconds: | ||
+ | # msgwait 2 | ||
+ | |||
+ | # Briefly show the version number of this starting | ||
+ | # screen session - but only for *one* second: | ||
+ | # msgwait 1 | ||
+ | # version | ||
+ | |||
+ | # Welcome the user: | ||
+ | # echo " | ||
+ | # echo "I love you today." | ||
+ | |||
+ | # Uncomment one/some following lines to automatically let | ||
+ | # SCREEN start some programs in the given window numbers: | ||
+ | # screen -t MAIL 0 mutt | ||
+ | # screen -t EDIT 1 vim | ||
+ | # screen -t GOOGLE | ||
+ | # screen -t NEWS 3 slrn | ||
+ | # screen -t WWW 4 links http:// | ||
+ | # screen 5 | ||
+ | # screen 6 | ||
+ | |||
+ | # Set the environment variable var to value string. If only var is specified, | ||
+ | # you'll be prompted to enter a value. If no parameters are specified, | ||
+ | # you'll be prompted for both variable and value. The environment is | ||
+ | # inherited by all subsequently forked shells. | ||
+ | # setenv PROMPT_COMMAND 'echo -n -e " | ||
+ | |||
+ | # Don't you want to start programs which need a DISPLAY ? | ||
+ | # setenv DISPLAY '' | ||
+ | |||
+ | hardstatus alwayslastline | ||
+ | hardstatus string ' | ||
+ | |||
+ | </ | ||
📌 Удобный подбор VPS по параметрам доступен на DIEGfinder.com - официальном инструменте проекта DIEG. Это часть единой экосистемы, созданной для того, чтобы помочь быстро найти подходящий VPS/VDS сервер для любых задач хостинга.
📌 Для тестирования скриптов, установщиков VPN и Python-ботов рекомендуем использовать надежные VPS на короткий срок. Подробнее о быстрой аренде VPS для экспериментов - читайте здесь.
💥 Подпишись в Телеграм 💥 и задай вопрос по сайтам и хостингам бесплатно!7 Самых Популярных Статей
- Как запустить скрипты и веб-приложения на Python
- Что такое страны TIER 1,2,3
- 7 способов сравнения файлов по содержимому в Windows или Linux
- Установка и тестирование веб-панели HestiaCP
- Nginx простые примеры конфигурации
- top, htop, atop определение загрузки ОС (Load average, LA)
- Использование rsync в примерах
7 Самых Популярных Обзоров
- Хостинг для Python-скриптов и приложений
- ТОП 4 лучших антидетект браузеров (Бесплатные & Платные)
- Подборка купонов (промокоды) на хостинг, антидетект браузеры
- Обзор THE.Hosting (PQ Hosting): надежный хостинг с профессиональной поддержкой
- Хостинг в России
- Хостинг в Европе
- Обзор браузера Dolphin {anty} для мультиаккаунтинга