ubuntu 16.04 LTS - screen 命令

ubuntu 16.04 LTS - screen 命令

screen 是一款由 GNU 计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。GNU Screen 可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。

1. 会话恢复

只要 screen 本身没有终止,在其内部运行的会话都可以恢复。这一点对于远程登录的用户特别有用 - 即使网络连接中断,用户也不会失去对已经打开的命令行会话的控制。只要再次登录到主机上执行 screen -r 就可以恢复会话的运行。同样在暂时离开的时候,也可以执行分离命令 detach,在保证里面的程序正常运行的情况下让 screen 挂起 (切换到后台)。

2. 多窗口

在 screen 环境下,所有的会话都独立的运行,并拥有各自的编号、输入、输出和窗口缓存。用户可以通过快捷键在不同的窗口下切换,并可以自由的重定向各个窗口的输入和输出。screen 实现了基本的文本操作,如复制,粘贴等;还提供了类似滚动条的功能,可以查看窗口状况的历史记录。窗口还可以被分区和命名,还可以监视后台窗口的活动。会话共享 screen 可以让一个或多个用户从不同终端多次登录一个会话,并共享会话的所有特性 (比如可以看到完全相同的输出)。它同时提供了窗口访问权限的机制,可以对窗口进行密码保护。

3. 常用 screen 参数

screen -S yourname --> 新建一个叫 yourname 的 session.
screen -ls --> 列出当前所有的 session.
screen -r yourname --> 回到 yourname 这个 session.
screen -d yourname --> 远程 detach 某个 session.

4. 安装 screen

strong@foreverstrong:~$ screen -ls
The program 'screen' is currently not installed. You can install it by typing:
sudo apt install screen

strong@foreverstrong:~$ sudo apt install screen
[sudo] password for strong: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libllvm4.0 linux-headers-4.10.0-40 linux-headers-4.10.0-40-generic
  linux-headers-4.10.0-42 linux-headers-4.10.0-42-generic
  linux-headers-4.13.0-26 linux-headers-4.13.0-26-generic
  linux-headers-4.13.0-31 linux-headers-4.13.0-31-generic
  linux-headers-4.13.0-32 linux-headers-4.13.0-32-generic
  linux-image-4.10.0-40-generic linux-image-4.10.0-42-generic
  linux-image-4.13.0-26-generic linux-image-4.13.0-31-generic
  linux-image-4.13.0-32-generic linux-image-extra-4.10.0-40-generic
  linux-image-extra-4.10.0-42-generic linux-image-extra-4.13.0-26-generic
  linux-image-extra-4.13.0-31-generic linux-image-extra-4.13.0-32-generic
  linux-signed-image-4.10.0-40-generic linux-signed-image-4.10.0-42-generic
  linux-signed-image-4.13.0-26-generic linux-signed-image-4.13.0-31-generic
  linux-signed-image-4.13.0-32-generic
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  iselect | screenie | byobu ncurses-term
The following NEW packages will be installed:
  screen
0 upgraded, 1 newly installed, 0 to remove and 50 not upgraded.
Need to get 560 kB of archives.
After this operation, 972 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 screen amd64 4.3.1-2build1 [560 kB]
Fetched 560 kB in 4s (135 kB/s) 
Selecting previously unselected package screen.
(Reading database ... 446078 files and directories currently installed.)
Preparing to unpack .../screen_4.3.1-2build1_amd64.deb ...
Unpacking screen (4.3.1-2build1) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up screen (4.3.1-2build1) ...#######################.........................................] 
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
strong@foreverstrong:~$ 

References

http://www.gnu.org/software/screen/

发布了467 篇原创文章 · 获赞 1744 · 访问量 103万+

猜你喜欢

转载自blog.csdn.net/chengyq116/article/details/104470288