Linux备忘
打印时间
date +"%F %T 周%u"
2023-04-15 18:50:47 周6
剔除在线用户
#查看有那些用户
$ users
root root root
#查看终端
$ who
#本地登录
root tty1 2023-05-06 08:55
#下面两个都是远程登录
root pts/0 2023-05-06 08:54 (192.168.1.101)
root pts/1 2023-05-06 09:00 (192.168.1.101)
#踢掉第三个终端
$ fuser -k /dev/pts/1
/dev/pts/1: 3562
#踢掉本地登录用户
$ fuser -k /dev/tty1
/dev/tty1: 1023 3437
时间同步部分
#查看时间状态
$ timedatectl status
Local time: Wed 2023-05-10 14:36:10 CST
Universal time: Wed 2023-05-10 06:36:10 UTC
RTC time: Wed 2023-05-10 06:36:10
Time zone: Asia/Shanghai (CST, +0800)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
#上面是已经设置好的结果
#设置时区
$ timedatectl set-timezone Asia/Shanghai
#安装服务
#ubuntu
$ apt -y install chrony
#centos
$ yum -y install chrony
#修改配置
#ubuntu
配置文件为 /etc/chrony/chrony.conf
#centos
配置文件为 /etc/chrony/chrony.conf
#将原有的pool注释掉
然后添加国内的pool
server ntp.aliyun.com iburst
server ntp.tuna.tsinghua.edu.cn iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
#启动或重启服务
#ubuntu
$ systemctl start chrony
$ systemctl enable chrony
$ systemctl restart chrony
$ systemctl status chrony
#centos
$ systemctl start chronyd
$ systemctl enable chronyd
$ systemctl restart chronyd
$ systemctl status chronyd
#手动强制同步一次时间
$ chronyc -a makestep
#查看源状态
chronyc sourcestats
chronyc sources
#开启ntp
timedatectl set-ntp true
curl命令
curl命令中如何获取响应头
curl -s -I www.baidu.com
-I 是获取响应头
但是如果只有-I,在脚本中会有进度条部分,很影响查看,所以需要加-s
-s选项用于隐藏curl的输出,--progress-bar选项用于隐藏进度条的显示,--silent选项用于隐藏所有进度信息
本文来自博客园,作者:厚礼蝎,转载请注明原文链接:https://www.cnblogs.com/guangdelw/p/17321661.html

浙公网安备 33010602011771号