[toc]
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中指定了端口,下圖所示:
-
爲了方便測試把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:
再次在從機上運行後臺服務命令,從遠程機器上傳輸到主機上該文件
[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 [email protected]::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
在回到從機133上,再次同步
[root@xavi-002 ~]# rsync -avL [email protected]::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
- rsync -avLP --port 8730 //此處未能成功
- [ ] max connections :指定最大的連接數,默認是0,即沒有限制。
- [ ] read only ture|false :如果爲true,則不能上傳到該模塊指定的路徑下。
- [ ] list :表示當用戶查詢該服務器上的可用模塊時,該模塊是否被列出,設定爲true則列出,false則隱藏。
==未能實現??????????==
- [ ] uid/gid :指定傳輸文件時以哪個用戶/組身份傳輸。
- [ ] auth users 指定傳輸時要使用的用戶名。
- [ ] secrets file :指定密碼文件,該參數連同上面的參數如果不指定,則不使用密碼驗證。注意該密碼文件的權限一定要是600。用戶名:密碼
這裏我們看到密碼配置文件在/etc/rsyncd.passwd,編輯它
[root@localhost rsync]# vim /etc/rsyncd.passwd
同時開放它的權限
[root@localhost rsync]# vim /etc/rsyncd.passwd
[root@localhost rsync]# chmod 600 !$
- 新建一個文件用於存儲密碼xavi
[root@xavi-002 ~]# vim /etc/rsync_pass.txt
這樣在寫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系統日誌
日誌記錄了系統每天發生的各種各樣的事情,比如監測系統狀況、排查系統故障等,你可以通過他來檢查錯誤發生的原因,或者受到攻擊時攻擊者留下的痕跡。日誌的主要功能是審計和監測,還可以實時的監測系統狀態,監測和追蹤侵入者等等。
- 常查看的日誌文件爲/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
}
- logrotate 的用法 更多關於logrotate的使用詳解,可以參考文章 https://my.oschina.net/u/2000675/blog/908189
- 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 ([email protected]) (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 ([email protected]) (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。
- 首先安裝screen包
[root@localhost ~]# yum install -y screen
已加載插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
- 運行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.