1. Introduction to screen command
Screen is a full-screen window manager that allows multiple processes (usually interactive shells) to be multiplexed between physical terminals. Each virtual terminal has DEC VT100 terminal and ANSI X3 control functions. ISO 6429 (64) and ISO 2022 standards (e.g. insertion/deletion of lines and support for multiple character sets). Users can take advantage of each virtual terminal's scrollback history buffer and copy-paste mechanism to move text areas between windows. When screen is called, it creates a window containing the shell (or the specified command) and then gets out of your way so that you can use the program normally. You can then at any time create new (full-screen) windows containing other programs (including more shells), close the current window, view the list of active windows, turn the output log on and off, copy text between windows, view the scroll history, Switch between windows, etc. All windows run their programs completely independently. Programs continue to run when the window is not currently visible, and even when the entire screen session is detached from the user's terminal.
2. Usage examples
1. Install screen command
[root@s145]~# yum install -y screen
Installed:
screen.x86_64 0:4.1.0-0.27.20120314git3c2946.el7_9
Complete!
2. List all current sessions
[root@s145] ~# screen -ls
No Sockets found in /var/run/screen/S-root.
3. Create a new window
[root @s145]~# screen -S test
…
[root@s145]~# screen -ls
There is a screen on:
2877.test (Attached)
1 Socket in /var/run/screen/S-root.
[root@s145]~
#4. Exit the current window
You can use ctrl a , and then enter d to exit the current window. You can also use screen -d to exit the current window. If you want to end only the window use exit.
5. Reconnect the window
Use screen -r id or name to reconnect the session, The session status is required to be Detached before reconnecting the session.
6. Clear the dead status window
When the session window is ended After that, the process status becomes dead and unable to connect. At this time, you can use the command "screen -wipe" to clear the session window.
7. Session locking and unlocking
Enter ctl a s to lock the session. After locking, the screen will not respond to any input. After entering ctl a q, it will unlock. Although When the screen is locked, it will not respond but will accept the commands entered. After unlocking, all commands will be executed. Do not enter dangerous commands, so it is recommended to use ctl a x to lock.
Enter ctl a x to lock the session. You need to enter the user password before you can unlock it.
8. Session sharing
9. Send commands to the screen window
[root@s145]~# date && screen -S test -X screen ls > /tmp/1.txt
Tue Jan 11 17:12:24 CST 2022
[root@ s145]~# screen -S test -X screen sh /root/test.sh
10. Screen split screen
It’s normal to use shortcut keys to split the screen, but you can’t enter commands when the screen is split. If you know, you can leave a message and tell me the reason. Please give me some advice. Thank you!
11. Practical example
Write a script that continuously outputs
[root@s145]~# cat test.sh #!/bin/bash \ while true do echo "输出`date +%F-%T`" sleep 10 done
Create a screen window
[root@s145]~# screen -S echotest
Execute the test.sh script
Make the echotest window offline in other sessions
[root@s145]~# screen -d echotest
[3405.echotest detached.]
Usage: screen [-opts] [cmd [args]]2. Parameter descriptionor :screen -r [host.tty]
Parameter description | |
---|---|
Resolve hostnames to IPv4 addresses only. | |
Resolve hostnames to IPv6 addresses only. | |
Forces all features into per-window termcap. | |
r] | |
Read configuration file Rather than’. screenrc’. | |
Detach a screen running elsewhere (and reattach here). | |
Started as daemon: screen session in detached mode. | |
Detach and log off the remote (and reconnect here). | |
Do whatever is needed to get a screen session. | |
Change the command characters. | |
Flow control on, -fn=off, -fa=auto. | |
Sets the size of the rollback history buffer. | |
When flow control is on, interrupt output is faster. | |
Login mode is turned on (update /var/run/utmp), -ln=off. | |
Does nothing, just lists our SockDir [about possible matches], same as -list | |
Does nothing, just lists our SockDir [about possible matches]. | |
Turn on output logging. | |
Ignore the $STY variable and create a new screen session. | |
Choose the best output instead of an exact vt100 simulation. | |
Preselects the named window if it exists. | |
Quiet startup. If unsuccessful, exit with a non-zero return code. The | |
command will send a response to the standard output of the query process. | |
Reconnect to the detached screen process. | |
Reconnect if possible, otherwise start a new session. | |
The shell to execute, not $shell. | |
Name this session. sockname instead of |
|
Set the title. (window name). | |
Use term as $term for windows, not "screen". | |
tells the screen to use UTF-8 encoding. | |
prints "Screen version 4.01.00devel (GNU) May 2, 2006". | |
Does nothing, just clears SockDir[possible matches]. | |
Connect to an undetached screen. (Multiple display mode). | |
Executed as a screen command in the specified session. |
- Ctrl a c: Create window
- Ctrl a w :Window list
- Ctrl a n :Next window
- ##Ctrl a p :Previous window
- Ctrl a 0-9: Switch between the 0th window and the 9th window
- Ctrl a K (uppercase): Close the current window, and Switch to the next window (when exiting the last window, the terminal automatically terminates and returns to the original shell state)
- exit: Close the current window and switch to the next window ( When exiting the last window, the terminal automatically terminates and returns to the original shell state)
- Ctrl a d: Exit the current terminal and return to the shell command state before loading the screen
The above is the detailed content of How to use Linux screen command. For more information, please follow other related articles on the PHP Chinese website!

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

When choosing a Hadoop version suitable for Debian system, the following key factors need to be considered: 1. Stability and long-term support: For users who pursue stability and security, it is recommended to choose a Debian stable version, such as Debian11 (Bullseye). This version has been fully tested and has a support cycle of up to five years, which can ensure the stable operation of the system. 2. Package update speed: If you need to use the latest Hadoop features and features, you can consider Debian's unstable version (Sid). However, it should be noted that unstable versions may have compatibility issues and stability risks. 3. Community support and resources: Debian has huge community support, which can provide rich documentation and

This article describes how to use TigerVNC to share files on Debian systems. You need to install the TigerVNC server first and then configure it. 1. Install the TigerVNC server and open the terminal. Update the software package list: sudoaptupdate to install TigerVNC server: sudoaptinstalltigervnc-standalone-servertigervnc-common 2. Configure TigerVNC server to set VNC server password: vncpasswd Start VNC server: vncserver:1-localhostno

Configuring a Debian mail server's firewall is an important step in ensuring server security. The following are several commonly used firewall configuration methods, including the use of iptables and firewalld. Use iptables to configure firewall to install iptables (if not already installed): sudoapt-getupdatesudoapt-getinstalliptablesView current iptables rules: sudoiptables-L configuration


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!