Use screen to solve the problem of re-connection after TTY disconnection

Source: Internet
Author: User
Use screen to solve the problem of TTY reconnection after disconnection-Linux Enterprise Application-Linux server application information. The following is a detailed description. A: When secureCRT is connected to the linux server, the network is disconnected, but the tty on the server has not exited. Can I re-connect it to the original tty?

B: Yes. You can install a Screen to enjoy the convenience it brings.

A: How to create A virtual shell environment?

B: screen-S MyScr ("MyScr" Is your name for this virtual shell environment, which can be customized)
After you press enter, you can work in this virtual shell environment, and your work content will be retained. Try it. Run several commands in it and run several programs.

A: How do I exit the work environment?

B: What if I want to exit? Press Ctrl + A and then press d to exit the created Virtual shell environment (named MyScr)
After a few minutes, you want to continue your work. Just repeat:
Screen-r MyScr
You can see the interface just now. Well, it's easy to use.

A: Can I not name him?

B: Of course, it's okay if you don't name this virtual shell environment. If there is only one virtual environment, you can also use it like this.
Screen (Press ENTER)
Work ...... Exit ......
Screen-r
Continue to work
By default, the system uses the PID code table to identify the screen Virtual shell environment.
For example, I directly created a virtual environment using the screen command. After exiting, I want to view the status of the virtual environment:

A: How can I check the current Screen working environment?

B: screen-list
The output should be similar to the following:
There is a screen on:
25202. pts-1.firewallX (Detached)
1 Socket in/tmp/screens/S-root.
Where:
"25202" is the PID of the virtual environment. If you don't believe it, you can check it in ps ~
"Pts-1" means that the system port number for your ssh client login is the pts-1
"FirewallX" is the name of my host.
If you have created many virtual environments without naming them, you can only use PID to identify them. (Remember that this PID Number is too annoying. It's still a good name !)
For example, I have two virtual environments created by screen. I enter:
Screen-list
Output:
There are screens on:
25202. pts-1.firewallX (Detached)
25403. pts-1.firewallX (Detached)
2 Sockets in/tmp/screens/S-root.
So what command can I use if I want to enter the second virtual environment? The answer is as follows:
Screen-r 25403

A: How to create A new screen?

B: If I log in and press ctrl-a c: to create a new Virtual Shell environment, this environment is the sub-virtual environment in the virtual environment with PID 25403.

A: How can I completely exit A screen working environment?

B: Ctrl-D

A: How can I automatically run screen when entering the work environment?
B: You can ~ /. Add a screen statement in the bottom line of bash_profiler.

Note: Before closing secureCRT, use Ctrl-D to exit screen.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.