断开连接时保持SSH会话运行

Screen is like a window manager for your console. It will allow you to keep multiple terminal sessions running and easily switch between them. It also protects you from disconnection, because the screen session doesn’t end when you get disconnected.

屏幕就像控制台的窗口管理器。 它可以让您保持多个终端会话的运行,并在它们之间轻松切换。 它还可以保护您免于断开连接,因为断开连接后屏幕会话不会结束。

You’ll need to make sure that screen is installed on the server you are connecting to. If that server is Ubuntu or Debian, just use this command:

您需要确保要连接的服务器上已安装该屏幕。 如果该服务器是Ubuntu或Debian,只需使用以下命令:

sudo apt-get install screen

sudo apt-get安装屏幕

Now you can start a new screen session by just typing screen at the command line. You’ll be shown some information about screen. Hit enter, and you’ll be at a normal prompt.

现在,您只需在命令行中输入screen即可开始新的屏幕会话。 您将看到一些有关屏幕的信息。 按Enter键,您将在正常提示下。

To disconnect (but leave the session running)

断开连接(但保持会话运行)

Hit Ctrl + A and then Ctrl + D in immediate succession. You will see the message [detached]

依次按Ctrl + A,然后按Ctrl +D。 您将看到消息[分离]

To reconnect to an already running session

重新连接到已经运行的会话

screen -r

屏幕-r

To reconnect to an existing session, or create a new one if none exists

重新连接到现有会话,或者如果不存在则创建一个新会话

screen -D -r

屏幕-D -r

To create a new window inside of a running screen session

在正在运行的屏幕会话中创建新窗口

Hit Ctrl + A and then C in immediate succession. You will see a new prompt.

依次按Ctrl + A,然后按C。 您将看到一个新提示。

To switch from one screen window to another

从一个屏幕窗口切换到另一个

Hit Ctrl + A and then Ctrl + A in immediate succession.

依次按Ctrl + A,然后按Ctrl +A。

To list open screen windows

列出打开的窗口

Hit Ctrl + A and then W in immediate succession

依次按Ctrl + A,然后依次按W

There’s lots of other commands, but those are the ones I use the most.

还有很多其他命令,但是这些是我使用最多的命令。

翻译自: https://www.howtogeek.com/howto/ubuntu/keep-your-ssh-session-running-when-you-disconnect/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值