今天老唐整理一下 Linux 上的一个比较好用的软件 Screen 的使用教程。Screen 和 nohup 是 Linux 上两个用的最多的后台运行程序的方法(Linux 后台运行程序的两种方法:screen 和 nohup 的安装和使用),当然,相比来说,screen 应该更好用一些,所以本文整理一下 screen 的安装、新建 screen 窗口、退出 screen 窗口、返回 screen 窗口等操作。

文章目录

隐藏

一、Screen 安装

二、Screen 使用

一、Screen 安装

Ubuntu / Debian:

sudo apt-get install -y screen

CentOS / Fedora:

sudo yum -y install screen

安装完之后可以使用 screen --version 查看版本,能正确输出就是安装成功了。

二、Screen 使用

1、新建 screen:

screen -S test

把 test 改成你想要的名字即可。

2、退出(不关闭):

Ctrl + a d

也就是先按下 Ctrl + a,然后再按下 d,即可退出。此时这个 screen 窗口仍在后台运行。

3、返回:

screen -r test

4、查看所有 screen 窗口:

screen -ls

5、更多操作:

Ctrl+a c Create a new window (with shell)

Ctrl+a " List all window

Ctrl+a 0 Switch to window 0 (by number )

Ctrl+a A Rename the current window

Ctrl+a S Split current region horizontally into two regions

Ctrl+a | Split current region vertically into two regions

Ctrl+a tab Switch the input focus to the next region

Ctrl+a Ctrl+a Toggle between the current and previous region

Ctrl+a Q Close all regions but the current one

Ctrl+a X Close the current region

参考:https://linuxize.com/post/how-to-use-linux-screen/