歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux下Screen的常用命令

向您推薦以下文章,已經將鏈接貼出來啦。Linux 技巧:使用 screen 管理你的遠程會話 http://www.linuxidc.com/Linux/2011-02/32178.htm

詳細資料參考以上鏈接,最下面是本人的一些實際操作,僅供參考:

已經將個人示例的系統版本和YUM庫的配置列出來了

1、新建screen會話:直接輸入screen命令或者screen -S [會話名稱]

2、退出會話:按下組合鍵Ctrl+a並松開,此時screen窗口等待命令,然後按下d並松開,退出screen窗口。

3、查看當前系統所有screen會話:screen -ls

4、進入某個screen會話:screen -r [會話的PID]

5、在進入某個screen會話後,殺死screen會話:按下組合鍵Ctrl+a並松開,此時screen窗口等待命令,然後按下大寫的K(即組合鍵:Shift+k)並松開,(系統提示是否要殺死)按下y確認殺死screen會話。

總結:當系統中只有一個screen會話時,輸入:screen -r 即可進入這個會話,

當系統中有多個screen會話時,此時輸入同樣的命令,系統會列出當前所有screen回話,相當於命令:screen -ls

更多的關於screen的參數,可以參考手冊:man screen

同時還要多多實際操作,會得到更多的切身體會,希望本文能夠對感興趣的讀者有所幫助,歡迎轉載,很願意分享分享,共同成長,謝謝!

[root@localhost ~]# cat /etc/issue
CentOS release 5.4 (Final)
Kernel \r on an \m
[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/5.5/os/i386/
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@localhost ~]# screen
-bash: screen: command not found
[root@localhost ~]# yum -y install screen
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: data.nicehosting.co.kr
 * base: mirror01.idc.hinet.net
 * extras: data.nicehosting.co.kr
 * updates: data.nicehosting.co.kr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-1.el5_4.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================
 Package                             Arch                                Version                                      Repository                         Size
==============================================================================================================================================================
Installing:
 screen                              x86_64                              4.0.3-1.el5_4.1                              base                              571 k
Transaction Summary
==============================================================================================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        
Total download size: 571 k
Downloading Packages:
screen-4.0.3-1.el5_4.1.x86_64.rpm                                                                                                      | 571 kB     00:01    
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
base/gpgkey                                                                                                                            | 1.5 kB     00:00    
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) [email protected]>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : screen                                                                                                                                 1/1
Installed:
  screen.x86_64 0:4.0.3-1.el5_4.1                                                                                                                            
Complete!
[root@localhost ~]# screen
[root@localhost ~]# dateSun Apr  3 21:02:22 EDT 2011
[root@localhost ~]#
 
[detached]
[root@localhost ~]# screen -S 20110403
[root@localhost ~]# dateSun Apr  3 21:05:45 EDT 2011
 [root@localhost ~]#
 
[detached]
[root@localhost ~]# screen -ls
There are screens on:
        31550.pts-2.localhost   (Detached)
        31577.20110403  (Detached)
2 Sockets in /var/run/screen/S-root.
 
[root@localhost ~]# screen -r 31577
[root@localhost ~]# date
Sun Apr  3 21:05:45 EDT 2011
[root@localhost ~]#
 
[detached]
[root@localhost ~]# screen -r 31550
[root@localhost ~]# date
Sun Apr  3 21:02:22 EDT 2011
[root@localhost ~]#
 
[screen is terminating]
[root@localhost ~]# man screen
SCREEN(1)                                                            SCREEN(1)
NAME
       screen - screen manager with VT100/ANSI terminal emulation
SYNOPSIS
       screen [ -options ] [ cmd [ args ] ]
       screen -r [[pid.]tty[.host]]
       screen -r sessionowner/[[pid.]tty[.host]]

Copyright © Linux教程網 All Rights Reserved