Linux常用命令库
apachectl
grep
openssl
mdadm
groupmems
grub2-mkconfig
grub2-set-default
accept
groupadd
passwd
apk
gpm
paste
7z
grpconv
patch
ag
groupmod
pathchk
ack
grub
perl
arp
groupdel
objdump
atrm
gunzip
pfctl
atq
grpck
pgrep
axel
grpunconv
parted
ab
groups
partprobe
badblocks
halt
php
apt-key
gzip
od
apt-get
head
pigz
apt-sortpkgs
gzexe
pico
apropos
history
pidof
atop
help
pidstat
break
lastlog
ping
aptitude
hexdump
pkill
bg
ldconfig
ntsysv
arch
host
pmap
arpd
hostid
rpm2cpio
arpwatch
htop
ppp-off
as
hostnamectl
poweroff
arptables
hping3
rsync
ar
lilo
pr
arping
ifcfg
script
bzip2recover
htdigest
pssh
cal
hostname
printf
cancel
id
reject
arj
htpasswd
protoize
cd
hwclock
popd
chcon
lpr
pstree
base64
lsblk
pv
batch
iconv
sftp
chgrp
indent
ps
basename
ifconfig
slocate
chmod
ifstat
pstack
bc
ifup
pushd
chown
hdparm
pvscan
blockdev
mkdir
pwd
at
mkinitrd
pwck
builtin
info
pvck
chpasswd
ifdown
pvchange
chroot
iptables
pwconv
bind
mpstat
pvs
bmodinfo
iostat
pvdisplay
cksum
iftop
pvcreate
bye
inotifywait
sshd
bzgrep
ip6tables-restore
pwunconv
chsh
ip
quotacheck
bzcmp
insmod
rcconf
bzcat
ip6tables-save
quota
bzdiff
iotop
rcp
col
init
repquota
clockdiff
install
pvremove
bzip2
ip6tables
restorecon
command
iptables-save
read
comm
ncftp
quotaoff
bzless
ipcrm
return
cmp
ipcs
rev
consoletype
iptstate
quotaon
bunzip2
ipcalc
rename
cat
iperf
resize
bzmore
netstat
readonly
cdrecord
iptables-restore
rmdir
blkid
nice
rexec
cp
jed
restore
cpio
ispell
reboot
chage
jobs
rm
chattr
joe
rlogin
cu
jq
rmmod
chkconfig
kexec
tee
cupsenable
join
rpmbuild
date
iptraf
runlevel
cupsdisable
kernelversion
rpmdb
clear
kill
rsh
clock
jwhois
rpm
chfn
journalctl
scp
dd
lastb
sar
declare
last
route
compress
ld
times
depmod
ln
tftp
alias
let
rpmverify
dc
killall
service
continue
ldd
rpmsign
df
lha
screen
convertquota
lftp
sesearch
dhclient
locate
semanage
dhcpd
less
seinfo
dhcrelay
lftpget
scriptreplay
diff
logger
seq
diffstat
local
setfacl
dig
logsave
readelf
diff3
lp
sed
csplit
logout
sendmail
crontab
logname
rpmquery
dirname
login
set
dirs
lsattr
sftp-server
cut
lvremove
renice
domainname
losetup
setpci
dos2unix
lpadmin
setsid
dpkg-deb
lpc
sysctl
colrm
lnstat
shift
dpkg-preconfigure
look
shutdown
dnsdomainname
logwatch
sh
dpkg-query
lynx
shuf
dpkg-reconfigure
lpq
updatedb
dpkg
lscpu
skill
dpkg-divert
logrotate
shopt
dpkg-statoverride
lpstat
setsebool
dpkg-trigger
lvresize
showmount
dmidecode
gpasswd
tcpreplay
dstat
lprm
slabtop
e2fsck
lvdisplay
squid
du
mail
sort
dircolors
lspci
speedtest-cli
disown
lsof
smbclient
e2label
mesg
vgscan
dump
mailq
split
egrep
ltrace
vdfuse
eject
lsusb
sleep
echo
make
ss
ed
lsmod
ssh-agent
elm
lvcreate
sudo
emacs
mkbootdisk
strings
edquota
lvreduce
spell
ex
lvscan
tmux
exec
mkfs
znew
enable
lsb_release
xrandr
ethtool
nethogs
unarj
elinks
nologin
swapoff
dmesg
neofetch
tar
dris
mke2fs
touch
expand
nslookup
zcat
dpkg-split
md5sum
ssh
export
man
ssh-add
exit
mknod
syslog
dnf
mii-tool
userdel
false
mysqladmin
ssh-copy-id
fdisk
mailstat
ssh-keyscan
find
modprobe
squidclient
fgrep
mkswap
smbpasswd
expr
mtools
source
finger
mkisofs
suspend
env
mapfile
ssh-keygen
fishshell
mktemp
startx
fmt
mysql
swapon
firewall-cmd
more
stty
fping
mv
tail
ftp
nc
talk
file
mount
systemctl
fold
named-checkzone
stat
fc
lvextend
supervisord
gcc
mysqlimport
systool
findfs
mysqldump
sync
fsck
nano
tailf
fg
nl
tac
exportfs
ngrep
su
get_module
newusers
tcpdump
gcov
mysqlshow
test
getsebool
nmcli
zipsplit
gdb
nisdomainname
telinit
free
nmap
tracepath
curl
ntpdate
sum
ftpcount
nm
timedatectl
getenforce
nproc
trap
ftpshut
nfsstat
unlink
ftpwho
nohup
unrar
git
ls
unprotoize
ftptop
type
awk
watch
fuser
ulimit
telnet
whatis
yum
xlsatoms
uucico
xz
tty
wget
uptime
xinit
whoami
xhost
xauth
uname
who
usernetctl
tree
vgreduce
vi
xclip
which
xset
zfore
tempfile
zipinfo
strace
tput
umask
time
umount
unalias
uncompress
whereis
usermod
unset
unexpand
users
uupick
ypdomainname
write
yes
xargs
useradd
uuto
true
unzip
vgdisplay
vgconvert
vgchange
vgremove
vgcreate
vgextend
vgrename
xlsfonts
zip
uniq
tload
xlsclients
traceroute
tr
volname
wall
vmstat
wait
top
w
wc
私有云知识库
-
+
首页
timedatectl
timedatectl === 用于在 Linux 中设置或查询系统时间、日期和时区等配置。 ## 补充说明 在 Linux 运维中,通常使用此命令来设置或更改当前的日期、时间和时区,或启用自动系统时钟与远程 NTP 服务器同步,以确保 Linux 系统始终保持正确的时间。 ## 概要 ```shell timedatectl [OPTIONS...] COMMAND ... ``` ## 主要用途 - 转换时间到选定的格式,默认为当前。 - 设置系统时间。 ## 参数 ```shell Query or change system time and date settings. -h --help 显示帮助信息。 --version 显示软件包版本。 --no-pager 不用将输出通过管道传输到寻呼机(pager)。 --no-ask-password 不提示输入密码。 -H --host=[USER@]HOST 在远程主机上操作 -M --machine=CONTAINER 在本地容器上操作。 --adjust-system-clock 更改本地 RTC 模式时调整系统时钟。 Commands: status 显示当前的时间设置。 set-time TIME 设置系统时间。 set-timezone ZONE 设置系统时区。 list-timezones 显示已知时区。 set-local-rtc BOOL 控制 RTC 是否在当地时间。(BOOL 的值可以是 1 / true 或 0 / false) set-ntp BOOL 启用或禁用网络时间同步。(BOOL 的值可以是 1 / true 或 0 / false) timesync-status 显示 systemd-timesyncd 的状态。 show-timesync 显示 systemd-timesyncd 的属性。 ``` ## 例子 显示系统当前时间和日期 ```shell $ timedatectl status Local time: 五 2022-04-08 17:06:40 CST Universal time: 五 2022-04-08 09:06:40 UTC RTC time: 五 2022-04-08 17:04:02 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: n/a NTP synchronized: no RTC in local TZ: yes DST active: n/a ``` 显示系统所有可用的时区 ```shell $ timedatectl show Unknown operation show $ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa ``` 将本地时区从上海(Asia/Shanghai)设置为阿姆斯特丹(Europe/Amsterdam) ```shell $ timedatectl set-timezone "Europe/Amsterdam" ``` 将本地时区设置为协调世界时(UTC) ```shell $ timedatectl set-timezone UTC ``` 设置系统时间(格式:HH:MM:SS) ```shell $ timedatectl set-time "07:25:46" ``` 设置系统日期(格式:YYYY-MM-DD) ```shell $ timedatectl set-time "2021-12-12" ``` 如果只设置日期,那么时间将默认设置为 “00:00:00″(建议同时设置日期和时间) ```shell $ timedatectl set-time "2021-12-12 07:25:46" ``` 将硬件时钟(RTC)设置为本地时区(不建议,RTC 时钟统一使用 UTC 更恰当,避免在时区更改和夏令时调整方面产生各种问题) ```shell $ timedatectl set-local-rtc 1 ``` 将硬件时钟(RTC)设置为协调世界时间(UTC) ```shell $ timedatectl set-local-rtc 0 ``` 启用 NTP 自动时间同步 ```shell $ timedatectl set-ntp true ``` 禁用 NTP 自动时间同步 ```shell $ timedatectl set-ntp false ``` 查看 systemd-timesyncd 服务的状态 ```shell $ timedatectl timesync-status Server: 91.189.94.4 (ntp.ubuntu.com) Poll interval: 17min 4s (min: 32s; max 34min 8s) Leap: normal Version: 4 Stratum: 2 Reference: 91EECB0E Precision: 1us (-23) Root distance: 29.922ms (max: 5s) Offset: +2.497ms Delay: 199.540ms Jitter: 5.834ms Packet count: 6 Frequency: +13.039ppm ``` `systemd-timedated` 可能默认配置了谷歌的 NTP 服务器(如 time1.google.com),为了顺利完成网络时间同步,您可以编辑 `/etc/systemd/timesyncd.conf` 文件添加自己的 NTP 服务器地址。
admin
2022年10月23日 09:30
63
0 条评论
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码