linux练习加笔记
作者:互联网
生成测试数据
for i in {1..40};do echo $(expr $RANDOM / 1000 ) ;done> t1.txt
[rootlocalhost ~~10:44:22]#for i in {1..40};do echo $(expr $RANDOM / 1000 ) ;done> t1.txt
[rootlocalhost ~~10:48:32]#ll
total 45088
-rw-r--r--. 1 root root 0 Mar 14 16:58 1.log
-rw-r--r--. 1 root root 20 Mar 19 15:03 1.tar
drw--w---x. 2 root root 6 Mar 17 18:05 333
-rw-r--r--. 1 root root 3650 Oct 19 07:55 404.html
drwxr-xr-x. 2 root root 6 Mar 17 18:05 555
-rw-r--r--. 1 root root 1991 Mar 17 15:08 all_nginx.tgz
-rw-------. 1 root root 1265 Mar 2 15:41 anaconda-ks.cfg
-rw-r--r--. 1 root root 760975 Mar 19 14:57 -C
-rw-r--r--. 1 root root 2523 Dec 26 2020 Centos-7.repo
-rw-r--r--. 1 root root 173 Mar 14 12:10 chaoge666.txt
-rw-r--r--. 1 root root 90 Mar 12 20:51 chaoge666.txt.1
-rw-r--r--. 1 root root 52 Mar 19 21:34 chaoge.gz
-rw-r--r--. 1 root root 121 Mar 19 21:41 chaoge.tar
-rw-r--r--. 1 root root 1113 Mar 19 18:55 chaoge,tar.gz
-rw-r--r--. 1 root root 42490252 Mar 19 14:56 chaoge.tar.gz
-rwxr--r--. 1 root root 18 Mar 19 14:01 first.py
-rw-r--r--. 1 root root 27 Mar 19 14:11 my_first.py
-rw-r--r--. 1 root root 368 Oct 19 07:55 nginx-logo.png
-rw-r--r--. 1 root root 105 Mar 21 10:48 t1.txt
drwxrwxr-x. 13 root root 4096 Mar 29 2021 tengine-2.3.3
-rw-r--r--. 1 root root 2848144 Mar 29 2021 yuchao_data.tar.gz
-rw-r--r--. 1 root root 166 Mar 17 15:09 鸡汤.txt
[rootlocalhost ~~10:48:44]#临时
-bash: 临时: command not found
[rootlocalhost ~~10:48:57]#ls
1.log 333 555 anaconda-ks.cfg Centos-7.repo chaoge666.txt.1 chaoge.tar chaoge.tar.gz my_first.py t1.txt yuchao_data.tar.gz
1.tar 404.html all_nginx.tgz -C chaoge666.txt chaoge.gz chaoge,tar.gz first.py nginx-logo.png tengine-2.3.3 鸡汤.txt
读取文件内容且倒叙排序
[rootlocalhost ~~10:48:59]#cat t1.txt | sort -rn
31
30
30
29
29
28
27
26
25
25
23
21
19
19
19
18
17
16
14
13
13
13
12
10
10
9
9
9
8
8
8
6
5
5
3
3
2
1
1
0
读取文件内容,排序,再统计重复行的次数
[rootlocalhost ~~10:50:07]#cat t1.txt | sort -rn | uniq -c
1 31
2 30
2 29
1 28
1 27
1 26
2 25
1 23
1 21
3 19
1 18
1 17
1 16
1 14
3 13
1 12
2 10
3 9
3 8
1 6
2 5
2 3
1 2
2 1
1 0
统计文件一共有多少行
[rootlocalhost ~~10:50:57]#cat t1.txt | wc -l
40
指定dns服务器地址为 223.5.5.5 ,进行域名解析,找出 4399.com的ip地址是多少
[rootlocalhost ~~11:02:20]#ping 223.5.5.5 4399.com
PING 4399.com (129.211.129.109) 56(124) bytes of data.
scp练习
练习1
把机器1的 /var/log/messages ,远程拷贝到机器2的/opt/下
[rootlocalhost ~~10:52:05]#spc /var/log/messages root@192.168.0.162:/opt/
-bash: spc: command not found
[rootlocalhost ~~10:52:48]#scp /var/log/messages root@192.168.0.162:/opt/
The authenticity of host '192.168.0.162 (192.168.0.162)' can't be established.
ECDSA key fingerprint is SHA256:hh3rWZidWEDPOxoVsnTnVLoY/mbnJbnEeugh1AxccNc.
ECDSA key fingerprint is MD5:8e:97:61:ba:b2:d0:18:ca:6e:4a:a6:47:98:7e:4a:96.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.162' (ECDSA) to the list of known hosts.
root@192.168.0.162's password:
messages 100% 144KB 11.2MB/s 00:00
把机器1的 /var/log/,远程拷贝到机器2的/opt/下
[rootlocalhost ~~10:53:46]#scp -r /var/log/ root@192.168.0.162:/opt/
root@192.168.0.162's password:
tallylog 100% 0 0.0KB/s 00:00
grubby_prune_debug 100% 193 80.3KB/s 00:00
lastlog 100% 572KB 17.4MB/s 00:00
btmp 100% 5376 2.3MB/s 00:00
wtmp 100% 65KB 12.3MB/s 00:00
tuned.log 100% 21KB 5.1MB/s 00:00
audit.log 100% 1848KB 31.0MB/s 00:00
anaconda.log 100% 46KB 7.1MB/s 00:00
syslog 100% 274KB 22.1MB/s 00:00
X.log 100% 20KB 7.3MB/s 00:00
program.log 100% 32KB 6.6MB/s 00:00
packaging.log 100% 199KB 19.8MB/s 00:00
storage.log 100% 106KB 19.2MB/s 00:00
ifcfg.log 100% 3398 1.3MB/s 00:00
ks-script-7RbHrr.log 100% 0 0.0KB/s 00:00
ks-script-bPGnrQ.log 100% 0 0.0KB/s 00:00
journal.log 100% 1570KB 48.0MB/s 00:00
boot.log 100% 9225 3.6MB/s 00:00
vmware-vgauthsvc.log.0 100% 22KB 8.5MB/s 00:00
vmware-vmsvc.log 100% 27KB 9.4MB/s 00:00
firewalld 100% 0 0.0KB/s 00:00
dmesg.old 100% 123KB 20.2MB/s 00:00
yum.log 100% 8869 2.1MB/s 00:00
boot.log-20220315 100% 27KB 10.8MB/s 00:00
boot.log-20220316 100% 18KB 9.0MB/s 00:00
boot.log-20220317 100% 9113 3.8MB/s 00:00
boot.log-20220318 100% 9225 4.3MB/s 00:00
boot.log-20220319 100% 27KB 9.2MB/s 00:00
boot.log-20220320 100% 54KB 22.3MB/s 00:00
cron-20220320 100% 20KB 9.8MB/s 00:00
cron 100% 1115 1.1MB/s 00:00
maillog-20220320 100% 3168 2.1MB/s 00:00
maillog 100% 198 202.2KB/s 00:00
messages-20220320 100% 2688KB 66.9MB/s 00:00
messages 100% 144KB 13.6MB/s 00:00
secure-20220320 100% 52KB 9.5MB/s 00:00
secure 100% 1368 829.1KB/s 00:00
spooler-20220320 100% 0 0.0KB/s 00:00
spooler 100% 0 0.0KB/s 00:00
dmesg 100% 123KB 37.3MB/s 00:00
[rootlocalhost ~~10:55:04]#
把机器2的 /home文件夹,全部拷贝到机器1 的 /tmp目录下。
[rootlocalhost ~~10:56:11]#scp -r /home/ root@192.168.0.162:/tmp/
root@192.168.0.162's password:
.bash_logout 100% 18 5.5KB/s 00:00
.bash_profile 100% 193 64.7KB/s 00:00
.bashrc 100% 231 16.8KB/s 00:00
.bash_logout 100% 18 9.4KB/s 00:00
.bash_profile 100% 193 87.6KB/s 00:00
.bashrc 100% 231 145.7KB/s 00:00
.bash_logout 100% 18 9.7KB/s 00:00
.bash_profile 100% 193 100.0KB/s 00:00
.bashrc 100% 231 158.3KB/s 00:00
.bash_history 100% 28 12.4KB/s 00:00
.bash_logout 100% 18 6.4KB/s 00:00
.bash_profile 100% 193 106.1KB/s 00:00
.bashrc 100% 231 141.8KB/s 00:00
.bash_logout 100% 18 9.8KB/s 00:00
.bash_profile 100% 193 96.5KB/s 00:00
.bashrc 100% 231 135.9KB/s 00:00
.bash_logout 100% 18 10.4KB/s 00:00
.bash_profile 100% 193 136.3KB/s 00:00
.bashrc 100% 231 120.2KB/s 00:00
.bash_logout 100% 18 12.0KB/s 00:00
.bash_profile 100% 193 130.6KB/s 00:00
.bashrc 100% 231 123.7KB/s 00:00
.bash_logout 100% 18 10.3KB/s 00:00
.bash_profile 100% 193 109.2KB/s 00:00
.bashrc 100% 231 218.8KB/s 00:00
.bash_logout 100% 18 9.2KB/s 00:00
.bash_profile 100% 193 107.4KB/s 00:00
.bashrc 100% 231 133.2KB/s 00:00
.bash_history 100% 924 427.3KB/s 00:00
.bash_logout 100% 18 8.5KB/s 00:00
.bash_profile 100% 193 108.8KB/s 00:00
.bashrc 100% 231 116.3KB/s 00:00
chaoge01.txt 100% 0 0.0KB/s 00:00
.bash_history 100% 143 70.3KB/s 00:00
.bash_logout 100% 18 9.8KB/s 00:00
.bash_profile 100% 193 109.0KB/s 00:00
.bashrc 100% 231 76.2KB/s 00:00
.bash_history 100% 17 9.7KB/s 00:00
.bash_logout 100% 18 9.3KB/s 00:00
.bashrc 100% 231 137.5KB/s 00:00
.bash_profile 100% 215 69.6KB/s 00:00
.viminfo 100% 649 330.9KB/s 00:00
.bash_history 100% 339 184.9KB/s 00:00
suid_cs 100% 4 2.0KB/s 00:00
12.txt 100% 4 2.4KB/s 00:00
.bash_logout 100% 18 10.0KB/s 00:00
.bash_profile 100% 193 71.8KB/s 00:00
.bashrc 100% 231 150.5KB/s 00:00
.bash_logout 100% 18 9.8KB/s 00:00
.bash_profile 100% 193 122.4KB/s 00:00
.bashrc 100% 231 116.8KB/s 00:00
lili.txt 100% 4 2.3KB/s 00:00
.bash_history 100% 131 77.2KB/s 00:00
hellolinux.txt 100% 0 0.0KB/s 00:00
.bash_logout 100% 18 12.4KB/s 00:00
.bash_profile 100% 193 124.2KB/s 00:00
.bashrc 100% 231 138.9KB/s 00:00
.bash_history 100% 32 18.9KB/s 00:00
my_first.py 100% 41 19.5KB/s 00:00
[rootlocalhost ~~10:57:00]#
阿里云和linux虚拟机文件传输练习
1.将你本地的/opt下所有数据,发到阿里云的/opt目录下
[rootlocalhost ~~11:01:19]#scp -r /opt/ root@39.107.249.90:/opt/
The authenticity of host '39.107.249.90 (39.107.249.90)' can't be established.
ECDSA key fingerprint is SHA256:boGUR0bP+h0vqQ16Hj9c88tPgc1MVCboYW+WbHlGqWs.
ECDSA key fingerprint is MD5:90:89:97:80:79:48:49:50:fa:b4:d0:95:a0:2e:5c:45.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '39.107.249.90' (ECDSA) to the list of known hosts.
root@39.107.249.90's password:
messages 100% 30KB 2.3MB/s 00:00
tallylog 100% 0 0.0KB/s 00:00
grubby_prune_debug 100% 193 35.1KB/s 00:00
lastlog 100% 572KB 963.9KB/s 00:00
wtmp 100% 120KB 833.9KB/s 00:00
btmp 100% 19KB 869.0KB/s 00:00
tuned.log 100% 20KB 600.5KB/s 00:00
audit.log 100% 2652KB 294.0KB/s 00:09
syslog 100% 235KB 483.0KB/s 00:00
boot.log 100% 2399 387.9KB/s 00:00
vmware-vgauthsvc.log.0 100% 22KB 901.2KB/s 00:00
vmware-vmsvc.log 100% 37KB 134.7KB/s 00:00
firewalld 100% 2126 326.9KB/s 00:00
dmesg.old 100% 120KB 380.6KB/s 00:00
yum.log 100% 8884 206.8KB/s 00:00
cron-20220306 100% 5539 459.9KB/s 00:00
maillog-20220306 100% 972 161.1KB/s 00:00
messages-20220306 100% 746KB 743.5KB/s 00:01
secure-20220306 100% 10KB 825.8KB/s 00:00
spooler-20220306 100% 0 0.0KB/s 00:00
boot.log-20220308 100% 8545 458.9KB/s 00:00
boot.log-20220309 100% 8428 241.6KB/s 00:00
error.log-20220311 100% 29KB 618.6KB/s 00:00
error.log 100% 0 0.0KB/s 00:00
access.log-20220311.gz 100% 920 159.4KB/s 00:00
access.log-20220320 100% 14 2.4KB/s 00:00
access.log 100% 0 0.0KB/s 00:00
boot.log-20220310 100% 8488 130.0KB/s 00:00
test.log 100% 0 0.0KB/s 00:00
boot.log-20220313 100% 8835 474.1KB/s 00:00
cron-20220313 100% 18KB 327.7KB/s 00:00
maillog-20220313 100% 984 160.7KB/s 00:00
messages-20220313 100% 1056KB 527.8KB/s 00:02
secure-20220313 100% 77KB 875.4KB/s 00:00
spooler-20220313 100% 0 0.0KB/s 00:00
1.txt 100% 0 0.0KB/s 00:00
2.txt 100% 0 0.0KB/s 00:00
10.txt 100% 0 0.0KB/s 00:00
3.txt 100% 0 0.0KB/s 00:00
4.txt 100% 0 0.0KB/s 00:00
5.txt 100% 0 0.0KB/s 00:00
6.txt 100% 0 0.0KB/s 00:00
7.txt 100% 0 0.0KB/s 00:00
8.txt 100% 0 0.0KB/s 00:00
9.txt 100% 0 0.0KB/s 00:00
access.txt 100% 0 0.0KB/s 00:00
audit.txt 100% 1698KB 564.9KB/s 00:03
boot.txt 100% 0 0.0KB/s 00:00
error.txt 100% 0 0.0KB/s 00:00
test.txt 100% 0 0.0KB/s 00:00
tuned.txt 100% 12KB 712.3KB/s 00:00
vmware-vmsvc.txt 100% 21KB 980.0KB/s 00:00
yum.txt 100% 843 135.5KB/s 00:00
boot.log-20220316 100% 8503 526.2KB/s 00:00
boot.log-20220319 100% 34KB 978.6KB/s 00:00
dmesg 100% 120KB 653.8KB/s 00:00
boot.log-20220320 100% 15KB 22.1KB/s 00:00
cron-20220320 100% 12KB 17.8KB/s 00:00
cron 100% 2738 109.2KB/s 00:00
maillog-20220320 100% 1010 162.4KB/s 00:00
maillog 100% 0 0.0KB/s 00:00
messages-20220320 100% 1044KB 260.5KB/s 00:04
messages 100% 30KB 56.5KB/s 00:00
secure-20220320 100% 46KB 138.2KB/s 00:00
secure 100% 12KB 612.9KB/s 00:00
spooler-20220320 100% 0 0.0KB/s 00:00
spooler 100% 0 0.0KB/s 00:00
[rootlocalhost ~~11:02:20]#
ntp时间服务部署
- 先理解时间对服务器的重要性
- 全世界的服务器,时间统一标准,可以以这个为准,cn.ntp.org.cn
- 学习linux的各种命令,对时间来修改,以及同步
timedaectl
可以修改linux的日期,时间
查看系统中有哪些时区文件
[rootlocalhost ~~16:41:01]#ls /usr/share/zoneinfo/
Africa Chile GB Indian Mexico posixrules Universal
America CST6CDT GB-Eire Iran MST PRC US
Antarctica Cuba GMT iso3166.tab MST7MDT PST8PDT UTC
Arctic EET GMT0 Israel Navajo right WET
Asia Egypt GMT-0 Jamaica NZ ROC W-SU
Atlantic Eire GMT+0 Japan NZ-CHAT ROK zone1970.tab
Australia EST Greenwich Kwajalein Pacific Singapore zone.tab
Brazil EST5EDT Hongkong leapseconds Poland Turkey Zulu
Canada Etc HST Libya Portugal tzdata.zi
CET Europe Iceland MET posix UCT
[rootlocalhost ~~16:44:38]#ll /usr/share/zoneinfo/Asia/Shanghai
-rw-r--r--. 5 root root 388 Jan 30 2018 /usr/share/zoneinfo/Asia/Shanghai
[rootlocalhost ~~16:45:07]#
timedatectl
date 改时间日期(软件时间,你的系统运行了,程序计算的时间)
hwclock 改硬件时间(计算的主板上,有一个BISO系统,以及纽扣电池,提供电量)
查看当前时间
[rootlocalhost ~~16:45:07]#timedatectl
Local time: Mon 2022-03-21 16:47:06 CST
Universal time: Mon 2022-03-21 08:47:06 UTC
RTC time: Mon 2022-03-21 08:47:06
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[rootlocalhost ~~16:47:06]#
[rootlocalhost ~~16:47:06]#timedatectl status
Local time: Mon 2022-03-21 16:48:08 CST
Universal time: Mon 2022-03-21 08:48:08 UTC
RTC time: Mon 2022-03-21 08:48:08
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[rootlocalhost ~~16:48:08]#
修改时间、修改时区
查看系统支持多少个时区
[rootlocalhost ~~16:48:08]#timedatectl list-timezones | wc -l
425
[rootlocalhost ~~16:49:15]#
找出关于上海的时区,具体名字
[rootlocalhost ~~16:49:15]#timedatectl list-timezones | grep -i 'shanghai'
Asia/Shanghai
[rootlocalhost ~~16:50:13]#
ntp时间同步
强制性更新整个系统的时间,ntpdate,不友好的强制同步时间
搭建ntp服务,自动的,友好的更新,校准系统时间
强制性ntpdate命令
[rootlocalhost ~~16:51:16]#ntpdate -u ntp.aliyun.com
21 Mar 16:53:53 ntpdate[2237]: step time server 203.107.6.88 offset 0.626542 sec
[rootlocalhost ~~16:53:53]#
搭建ntpd服务
查看ntp软件信息
[rootlocalhost ~~16:53:53]#ls /usr/lib/systemd/system/ |grep ntp
ntpdate.service
ntpd.service
[rootlocalhost ~~16:55:10]#
找到ntp软件的配置文件
[rootlocalhost ~~16:55:10]#rpm -ql ntp |grep conf
/etc/ntp.conf
/etc/sysconfig/ntpd
/usr/share/man/man5/ntp.conf.5.gz
[rootlocalhost ~~16:55:51]#
修改ntp配置文件
[rootlocalhost ~~16:59:31]#vim /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp.aliyun.com iburst prefer
server cn.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
修改机器的时间为错误时间
[rootlocalhost ~~17:03:35]#timedatectl set-time '1998-3-5 11:20:00'
[rootlocalhost ~~11:20:00]#timedatectl
Local time: Thu 1998-03-05 11:20:08 CST
Universal time: Thu 1998-03-05 03:20:08 UTC
RTC time: Thu 1998-03-05 03:20:08
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[rootlocalhost ~~11:20:08]#
启动ntpd服务,等待时间是否同步
关于ntpd的服务脚本文件/usr/lib/systemd/system/ntpd.service
[rootlocalhost ~~11:20:08]#systemctl start ntpd
[rootlocalhost ~~11:20:48]#
[rootlocalhost ~~11:20:50]#systemctl status ntpd
● ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 1998-03-05 11:20:48 CST; 24 years 0 months ago
Process: 2298 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2299 (ntpd)
CGroup: /system.slice/ntpd.service
└─2299 /usr/sbin/ntpd -u ntp:ntp -g
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: Listen normally on 3 ens33 ...
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: Listen normally on 4 lo ::1...
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: Listen normally on 5 ens33 ...
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: Listening on routing socket...
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: 0.0.0.0 c016 06 restart
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: 0.0.0.0 c012 02 freq_set ke...
Mar 05 11:20:48 localhost.localdomain ntpd[2299]: 0.0.0.0 c011 01 freq_not_set
Mar 05 11:20:55 localhost.localdomain ntpd[2299]: 0.0.0.0 c61c 0c clock_step ...
Mar 21 17:05:09 localhost.localdomain ntpd[2299]: 0.0.0.0 c614 04 freq_mode
Mar 21 17:05:10 localhost.localdomain ntpd[2299]: 0.0.0.0 c618 08 no_sys_peer
Hint: Some lines were ellipsized, use -l to show in full.
[rootlocalhost ~~17:05:57]#
查看ntp是否和上游服务器同步
[rootlocalhost ~~17:05:57]#ntpstat
unsynchronised
polling server every 64 s
[rootlocalhost ~~17:06:40]#
查看时间同步的状态
[rootlocalhost ~~17:08:27]#ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*203.107.6.88 100.107.25.114 2 u 62 64 3 16.075 -2.578 2.010
+time.cloudflare 10.28.12.207 3 u 57 64 7 269.856 -19.501 11.061
[rootlocalhost ~~17:08:59]#
date命令和hwclock命令
可以直接用timedatectl替代了
timedatectl直接修改硬件+软件时间了。
让软件时间和硬件时间同步
hwclock 可以将硬件和软件时间做同步
-s, --hctosys 从硬件时钟设置系统时间
-w, --systohc 从当前系统时间设置硬件时钟
ntpdate
ntpdate -u ntp.aliyun.com 阿里云的服务器时间
主动更新linux到的时间,要求这个时间服务器是正确在运行中的
设置linux的时间为2008年8月8日,下午3:45,用2个命令
[rootlocalhost ~~19:10:06]#timedatectl set-time "2008-8-8 15:45:00"
[rootlocalhost ~~15:45:16]#timedatectl
Local time: Fri 2008-08-08 15:45:22 CST
Universal time: Fri 2008-08-08 07:45:22 UTC
RTC time: Fri 2008-08-08 07:45:23
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[rootlocalhost ~~15:45:22]#
[rootlocalhost ~~19:14:42]#date -s "2008-8-8 15:45:00"
Fri Aug 8 15:45:00 CST 2008
[rootlocalhost ~~15:45:00]#timedatectl
Local time: Fri 2008-08-08 15:45:20 CST
Universal time: Fri 2008-08-08 07:45:20 UTC
RTC time: Fri 2008-08-08 07:49:38
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[rootlocalhost ~~15:45:20]#
要求记录ntp运行日志,以及ntp进程pid文件
标签:KB,00,log,100%,练习,rootlocalhost,笔记,linux,root 来源: https://www.cnblogs.com/yujiejie/p/16036861.html