32.rsync服务同步,Linux系统日志,screen工具

八周三次课(1月31日)

10.32/10.33 rsync通过服务同步

10.34 linux系统日志

10.35 screen工具

一、rsync通过后台服务的方式

这种方式可以理解为:在远程主机上建立一个rsync服务器,在服务器上配置好rsync的各种应用,然后将本机作为rsync的一个客户端连接远程rsync服务器,下面是步骤说明:

  • 首先配置rsync的配置文件/etc/rsync.conf
[root@localhost ~]# vim /etc/rsyncd.conf
log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.72.132
[test]
path=/root/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
auth users=test
secrets file=/etc/rsyncd.passwd
hosts allow=192.168.72.133
  • 用rsync --daemon启动服务,用ps查看其启动是否
  • ps aux |grep resync
    [root@localhost ~]# rsync --daemon
    [root@localhost ~]# ps aux |grep rsync
    root       4708  0.0  0.0 114656   524 ?        Ss   10:59   0:00 rsync --daemon
    root       4710  0.0  0.0 112676   972 pts/0    S+   10:59   0:00 grep --color=auto rsync
  • 查看端口是否启动,netstat -lntp,刚才在/etc/rsyncd.conf中指定了端口,下图所示:
    mark

  • 为了方便测试把rsyncd.conf文件内容重新编辑为
    path=/tmp/rsync,新建该临时目录并赋予权限

[root@localhost ~]# vi /etc/rsyncd.conf
[root@localhost ~]# mkdir /tmp/rsync
[root@localhost ~]# chmod 777 /tmp/rsync

在需要后台服务的另外一台机上输入如下命令:

[root@xavi-002 tmp]# rsync -avP /tmp/xavi.txt 192.168.72.133::test/xavi-02.txt
rsync: failed to connect to 192.168.72.133 (192.168.72.133): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(122) [sender=3.0.9]

现在发现这里有错误,无法执行同步命令,查看下是否存在ip不通的情况,ping ip地址,然后用telnet查看其网络情况,如果没有telnet,请用yum安装一下

[root@xavi-002 ~]# ping 192.168.72.130
PING 192.168.72.130 (192.168.72.130) 56(84) bytes of data.
64 bytes from 192.168.72.130: icmp_seq=1 ttl=64 time=2.44 ms
64 bytes from 192.168.72.130: icmp_seq=2 ttl=64 time=0.592 ms
  • telnet IP 端口号,检查该端口是否通的命令
    [root@xavi-002 ~]# telnet 192.168.72.130 873
    Trying 192.168.72.130...
    Connected to 192.168.72.130.
    Escape character is '^]'.
    @RSYNCD: 30.0

    再次看下iptables是否有问题

[root@xavi-002 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:53
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:53
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:67
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:67
 8964   14M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
  256 16892 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
 6416  553K INPUT_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
 6416  553K INPUT_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
 6416  553K INPUT_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate INVALID
 6393  552K REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)

这里说明我们要关闭的是firewalld.?????

[root@xavi-002 ~]# systemctl stop firewalld
[root@xavi-002 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination       

同时把主机的firewalld服务也关闭

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -nvL
Chain INPUT (policy ACCEPT 21405 packets, 15M bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:53
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:53
    0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            udp dpt:67
    0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            tcp dpt:67

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      virbr0  0.0.0.0/0            192.168.122.0/24     ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  virbr0 *       192.168.122.0/24     0.0.0.0/0           
    0     0 ACCEPT     all  --  virbr0 virbr0  0.0.0.0/0            0.0.0.0/0           
    0     0 REJECT     all  --  *      virbr0  0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable
    0     0 REJECT     all  --  virbr0 *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT 10672 packets, 784K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     udp  --  *      virbr0  0.0.0.0/0            0.0.0.0/0            udp dpt:68

把两台机器的firewalld服务关闭后,在来看下telnet命令下端口情况

[root@xavi-002 ~]# telnet 192.168.72.130 873
Trying 192.168.72.130...
Connected to 192.168.72.130.
Escape character is '^]'.
@RSYNCD: 30.0

这里表示已经成功连接,退出并关闭,输入“ctrl+]”,然后输入quit

[root@xavi-002 ~]# telnet 192.168.72.130 873
Trying 192.168.72.130...
Connected to 192.168.72.130.
Escape character is '^]'.
@RSYNCD: 30.0
^]
telnet> quit
Connection closed.

再次运行命令,提示要输入密码,这是我们可以在主机上把/etc/rsyncd.conf配置文件再修改一下,把secret和auth users行加#号注释掉.

[root@xavi-002 ~]# rsync -avP /tmp/xavi.txt 192.168.72.130::test/xavi-02.txt
Password: 

mark

再次在从机上运行后台服务命令,从远程机器上传输到主机上该文件

[root@xavi-002 ~]# rsync -avP /tmp/xavi.txt 192.168.72.130::test/xavi-02.txt
sending incremental file list
xavi.txt
        2391 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/1)

sent 2463 bytes  received 27 bytes  711.43 bytes/sec
total size is 2391  speedup is 0.96

在主机上查看到了xavi-02文件

[root@localhost ~]# ls /tmp/rsync
xavi-02.txt

当然我们也可以在从机上把主机的文件拉到从机上

[root@xavi-002 ~]# rsync -avP 192.168.72.130::test/xavi-02.txt /tmp/123.txt
receiving incremental file list
xavi-02.txt
        2391 100%    2.28MB/s    0:00:00 (xfer#1, to-check=0/1)

sent 45 bytes  received 2497 bytes  221.04 bytes/sec
total size is 2391  speedup is 0.94

现在我们在来回归一下刚才编辑/etc/rsyncd.conf的配置内容解析:

log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.72.132
[test]  //模块名
path=/root/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
auth users=test
secrets file=/etc/rsyncd.passwd
hosts allow=192.168.72.133
  • [ ] port :指定在哪个端口启动rsyncd服务,默认是873端口。
  • [ ] log file :指定日志文件。
  • [ ] pid file :指定pid文件,这个文件的作用涉及服务的启动、停止等进程管理操作。
  • [ ] address :指定启动rsyncd服务的IP。假如你的机器有多个IP,就可以指定由其中一个启动rsyncd服务,如果不指定该参数,默认是在全部IP上启动。
  • [ ] [] :指定模块名,里面内容自定义。
  • [ ] path : 指定数据存放的路径。
  • [ ] use chroot true|false : 表示在传输文件前首先chroot到PATH参数所指定的目录下。这样做的原因是实现额外的安全防护,但缺点是需要以roots权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true,如果你的数据当中有软连接文件,建议设置成false。
  • [ ] max connections :指定最大的连接数,默认是0,即没有限制。
  • [ ] read only ture|false :如果为true,则不能上传到该模块指定的路径下。
  • [ ] list :表示当用户查询该服务器上的可用模块时,该模块是否被列出,设定为true则列出,false则隐藏。
  • [ ] uid/gid :指定传输文件时以哪个用户/组身份传输。
  • [ ] auth users 指定传输时要使用的用户名。
  • [ ] secrets file :指定密码文件,该参数连同上面的参数如果不指定,则不使用密码验证。注意该密码文件的权限一定要是600。用户名:密码
  • [ ] hosts allow :表示被允许连接该模块的主机,可以是IP或者网段,如果是多个,中间用空格隔开。

  • 刚才提到了选项use chroot,默认为ture,首先在主机的130的/root/rsync/test1/目录下创建软链接文件:
[root@localhost rsync]# ln -s /etc/passwd /tmp/rsync/test.txt

[root@localhost rsync]# ls -l /tmp/rsync/test.txt
lrwxrwxrwx 1 root root 11 2月   3 18:10 /tmp/rsync/test.txt -> /etc/passwd

然后再到从机133上执行同步,

[root@xavi-002 ~]# rsync -avL test@192.168.72.130::test/ /tmp/test1/
receiving incremental file list
symlink has no referent: "/test.txt" (in test)
created directory /tmp/test1
./
xavi-02.txt

sent 48 bytes  received 2567 bytes  5230.00 bytes/sec
total size is 2391  speedup is 0.91
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1518) [generator=3.0.9]

上例中看出,如果设置use chroot为ture,则同步软链接文件会有问题,下面把主机的rsync配置文件修改一下,把ture改为false
mark

在回到从机133上,再次同步

[root@xavi-002 ~]# rsync -avL test@192.168.72.130::test/ /tmp/test1/
receiving incremental file list
test.txt

sent 45 bytes  received 2528 bytes  5146.00 bytes/sec
total size is 4782  speedup is 1.86

没有报错,问题解决,另外修改玩rsycnd.conf配置文件后不需要重启rsyncd服务,这是rsync的一个特定机制,配置文件是即时生效的.

[root@xavi-002 ~]# ls -l /tmp/test1/
总用量 8
-rw-r--r-- 1 root root 2391 1月   7 15:53 test.txt
-rw-r--r-- 1 root root 2391 2月   3 11:33 xavi-02.txt
  • kill关掉所有和rsync相关的程序

    [root@localhost rsync]# killall rsync
    [root@localhost rsync]# !ps
    ps aux |grep vmstat
    root       8382  0.0  0.0 112676   968 pts/1    R+   20:02   0:00 grep --color=auto vmstat

    mark

  • rsync -avLP --port 8730 //此处未能成功

mark

  • [ ] max connections :指定最大的连接数,默认是0,即没有限制。
  • [ ] read only ture|false :如果为true,则不能上传到该模块指定的路径下。
  • [ ] list :表示当用户查询该服务器上的可用模块时,该模块是否被列出,设定为true则列出,false则隐藏。

mark
==未能实现??????????==
mark

  • [ ] uid/gid :指定传输文件时以哪个用户/组身份传输。

mark

  • [ ] auth users 指定传输时要使用的用户名。
  • [ ] secrets file :指定密码文件,该参数连同上面的参数如果不指定,则不使用密码验证。注意该密码文件的权限一定要是600。用户名:密码

mark

这里我们看到密码配置文件在/etc/rsyncd.passwd,编辑它

[root@localhost rsync]# vim /etc/rsyncd.passwd

mark

同时开放它的权限

[root@localhost rsync]# vim /etc/rsyncd.passwd
[root@localhost rsync]# chmod 600 !$

mark

  • 新建一个文件用于存储密码xavi
[root@xavi-002 ~]# vim /etc/rsync_pass.txt

mark

mark

这样在写shell脚本的时候就可以不用输入密码了

  • [ ] hosts allow :表示被允许连接该模块的主机,可以是IP或者网段,如果是多个,中间用空格隔开。
    hosts allow=192.168.133.132 1.1.1.1 2.2.2.2 192.168.133.0/24 //最后这个表示IP段

二、Linux系统日志

日志记录了系统每天发生的各种各样的事情,比如监测系统状况、排查系统故障等,你可以通过他来检查错误发生的原因,或者受到***时***者留下的痕迹。日志的主要功能是审计和监测,还可以实时的监测系统状态,监测和追踪侵入者等等。

  1. 常查看的日志文件为/var/log/message, 它是核心系统日志文件,包含了系统启动时的引导消息,以及系统运行时的其他状态消息。IO错误、网络错误和其他系统错误都会记录到这个文件中。另外其他信息,比如某个人的身份切换为root以及用户自定义安装的软件(apache)的日志也会在这里列出。
[root@localhost ~]# ls /var/log/messages
/var/log/messages
[root@localhost ~]# less !$

查看其大小

[root@localhost ~]# du -sh !$
du -sh /var/log/messages
900K    /var/log/messages

通常,/var/log/messages是在做故障诊断时首先要查看的文件。

系统有一个日志轮询的机制,每星期切换一个日志,切换后的日志名字类似于messages-20180123.会存放在/var/log/目录下面,连同messages一共有5个这样的日志文件,这里的20180123就是日期,表示日子切割的年月日.

[root@localhost ~]# ls /var/log/messages*
/var/log/messages           /var/log/messages-20180123  /var/log/messages-20180204
/var/log/messages-20180115  /var/log/messages-20180128

这是通过logrotate工具的控制来实现的,它的配置文件是/etc/logrotate.conf,(如果没有特殊需求请不要修改这个配置文件)。

[root@localhost ~]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4  //保留4个文件

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

上述logrotate.conf配置文件的内容可以参考英文注释去理解,/var/log/messages是由rsyslogd这个守护进程产生的,如果停止这个服务则系统不会产生/var/log/messages,所以这个服务不要停止。

[root@localhost ~]# ls /etc/logrotate.d
chrony  glusterfs    libvirtd       numad  psacct  sssd    wpa_supplicant
cups    iscsiuiolog  libvirtd.qemu  ppp    samba   syslog  yum

[root@localhost ~]# cat /etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    missingok
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
  1. dmesg
    用于查看系统硬件的日志,存储在内存中,显示系统的启动信息,如果你的某个硬件有问题(比如说网卡)用这个命令也是可以看到的。
[root@localhost ~]# dmesg |head
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-514.el7.x86_64 root=UUID=12ac0c7f-ed4e-49b8-b862-68d478ecc7e4 ro crashkernel=auto rhgb quiet LANG=zh_CN.UTF-8
[    0.000000] Disabled fast string operations
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ebff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009ec00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000dc000-0x00000000000fffff] reserved
  • 这里还有介绍/var/log/dmesg
    它和dmesg没有关联,这里表示的是系统启动日志
[root@localhost ~]# ls /var/log/dmesg
/var/log/dmesg
[root@localhost ~]# less /var/log/dmesg
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-514.el7.x86_64 root=UUID=12ac0c7f-ed4e-49b8-b862-68d478ecc7e4 ro crashkernel=auto rhgb quiet LANG=zh_CN.UTF-8
[    0.000000] Disabled fast string operations
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ebff] usable
3. 安全日志

3.11 last 命令查看Linux的历史信息,用法如下:

[root@localhost ~]# less /var/log/dmesg
[root@localhost ~]# last
root     pts/0        192.168.72.1     Mon Feb  5 19:15   still logged in   
reboot   system boot  3.10.0-514.el7.x Mon Feb  5 18:51 - 20:37  (01:45)    
root     pts/0        192.168.72.1     Sun Feb  4 16:02 - crash (1+02:49)   
reboot   system boot  3.10.0-514.el7.x Sun Feb  4 15:29 - 20:37 (1+05:07)   
root     pts/1        192.168.72.1     Sat Feb  3 15:21 - crash (1+00:07)   
root     pts/0        192.168.72.1     Sat Feb  3 10:30 - 17:09  (06:38)    
root     pts/0        192.168.72.1     Thu Feb  1 19:59 - 22:44  (02:44)    
reboot   system boot  3.10.0-514.el7.x Thu Feb  1 19:54 - 20:37 (4+00:42)   

上例中,从左至右依次为账户名称、登录终端、登录客户端ip、登录日期及时长。last命令输出的信息实际上是读取了二进制日志文件/var/log/wtmp, 只是这个文件不能直接使用cat, vim, head, tail等工具查看。

  • lastb命令查看登录失败的用户,对应的文件时/var/log/btmp
[root@localhost ~]# lastb

btmp begins Thu Feb  1 20:35:01 2018

另外一个和登陆信息有关的安全日志文件为/var/log/secure, 该日志文件记录验证和授权等方面的信息,比如ssh登陆系统成功或者失败,都会把相关信息记录在这个日志里

[root@localhost ~]# ls /var/log/secure
/var/log/secure
[root@localhost ~]# less /var/log/secure

Feb  4 17:59:53 localhost polkitd[580]: Registered Authentication Agent for unix-process:3970:905339 (system bus name :1.63 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8)
Feb  5 18:51:55 localhost polkitd[536]: Loading rules from directory /etc/polkit-1/rules.d
Feb  5 18:51:55 localhost polkitd[536]: Loading rules from directory /usr/share/polkit-1/rules.d
Feb  5 18:51:55 localhost polkitd[536]: Finished loading, compiling and executing 6 rules
Feb  5 18:51:55 localhost polkitd[536]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Feb  5 18:52:03 localhost sshd[865]: Server listening on 0.0.0.0 port 22.
Feb  5 18:52:03 localhost sshd[865]: Server listening on :: port 22.
Feb  5 19:15:30 localhost sshd[2474]: Accepted password for root from 192.168.72.1 port 51786 ssh2
/var/log/secure...skipping...
Feb  4 17:59:53 localhost polkitd[580]: Registered Authentication Agent for unix-process:3970:905339 (system bus name :1.63 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8)
Feb  5 18:51:55 localhost polkitd[536]: Loading rules from directory /etc/polkit-1/rules.d
Feb  5 18:51:55 localhost polkitd[536]: Loading rules from directory /usr/share/polkit-1/rules.d
Feb  5 18:51:55 localhost polkitd[536]: Finished loading, compiling and executing 6 rules

三、screen工具介绍

有时候我们需要执行一个命令或脚本,需要几小时甚至几天,在这个过程中,如果中途断网或者出现有其他意外情况怎么办,当然也可以吧命令或者脚本放到后台运行,不过不保险,无法在屏幕上随时查看,这就要用到虚拟终端screen。

  1. 首先安装screen包
[root@localhost ~]# yum install -y screen
已加载插件:fastestmirror, langpacks
base                                                                        | 3.6 kB  00:00:00   
  1. 运行screen,用w查看,但是无法看出,使用的是screen-ls查看已打开的screen会话
[root@localhost ~]# screen

[root@localhost ~]# w
 20:54:48 up  2:03,  1 user,  load average: 0.04, 0.03, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/1    192.168.72.1:S.0 20:54    0.00s  0.03s  0.00s w
[root@localhost ~]# screen -ls
There is a screen on:
        3451.pts-0.localhost    (Attached)
1 Socket in /var/run/screen/S-root.
  • ctrl+a,再按d
[root@localhost ~]# screen
[detached from 3451.pts-0.localhost]
  • 退出后,如果想再次登入某个screen会话,可以使用的是screen -r [编号]
[root@localhost ~]# screen -r 3451

 1  0      0 1330772    932 378496    0    0    23     2   21   31  0  0 100  0  0
 0  0      0 1330756    932 378528    0    0     0     0   43   55  0  0 100  0  0
 0  0      0 1330756    932 378528    0    0     0     0   24   36  0  0 100  0  0
 0  0      0 1330756    932 378528    0    0     0     0   38   50  0  0 99  0  0
 0  0      0 1330756    932 378528    0    0     0     0   30   46  0  0 100  0  0
  • 退出screen,输入exit,然后查看就没有screen了
[root@localhost ~]# screen -ls
No Sockets found in /var/run/screen/S-root.
  • 连续打开多个screen,screen回车,ctrl+a,在按d,最后查看
[root@localhost ~]# screen
[detached from 3670.pts-0.localhost]
[root@localhost ~]# screen
[detached from 3704.pts-0.localhost]
[root@localhost ~]# screen
[detached from 3733.pts-0.localhost]
[root@localhost ~]# sreen -ls
bash: sreen: 未找到命令...
[root@localhost ~]# screen -ls
There are screens on:
    3733.pts-0.localhost    (Detached)
    3704.pts-0.localhost    (Detached)
    3670.pts-0.localhost    (Detached)
3 Sockets in /var/run/screen/S-root.
  • 如果screen太多,却不知道其功能作用
    需要命令和定义
[root@localhost ~]# screen -S "test_screen"

[root@localhost ~]# sleep 100
[root@localhost ~]# screen -ls
There are screens on:
        3806.test_screen        (Attached)
        3733.pts-0.localhost    (Detached)
        3704.pts-0.localhost    (Detached)
        3670.pts-0.localhost    (Detached)
4 Sockets in /var/run/screen/S-root.

转载于:https://blog.51cto.com/12995218/2068797

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值