# 日期和时间设置–timedatectl
该命令修改时间和日期、时区等信息,对于时间的修改,避免使用date修改日期后,还得要是用hwclock去修改BIOS记录的时间
[root@wangsf ~]# timedatectl status Local time: Tue 2021-11-09 11:14:01 CST Universal time: Tue 2021-11-09 03:14:01 UTC RTC time: Tue 2021-11-09 11:14:00 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: n/a [root@wangsf ~]# timedatectl list-timezones |grep -i new America/New_York America/North_Dakota/New_Salem [root@wangsf ~]# timedatectl set-timezone "America/New_York" --修改时区 [root@wangsf ~]# timedatectl status Local time: Mon 2021-11-08 22:15:14 EST Universal time: Tue 2021-11-09 03:15:14 UTC RTC time: Tue 2021-11-09 11:15:13 Time zone: America/New_York (EST, -0500) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2021-11-07 01:59:59 EDT Sun 2021-11-07 01:00:00 EST Next DST change: DST begins (the clock jumps one hour forward) at Sun 2022-03-13 01:59:59 EST Sun 2022-03-13 03:00:00 EDT [root@wangsf ~]# timedatectl set-timezone "Asia/Shanghai" You have new mail in /var/spool/mail/root [root@wangsf ~]# timedatectl status Local time: Tue 2021-11-09 11:15:42 CST Universal time: Tue 2021-11-09 03:15:42 UTC RTC time: Tue 2021-11-09 11:15:41 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: n/a [root@wangsf ~]# [root@wangsf ~]# timedatectl set-time "2015-05-21 13:00:00" --修改时间 [root@wangsf ~]# date Thu May 21 13:00:01 CST 2015 [root@wangsf ~]#
复制
主机名设置–hostnamectl
该命令修改就是/etc/hostname文件
[root@wangsf ~]# hostnamectl Static hostname: wangsf Icon name: computer-vm Chassis: vm Machine ID: 9f1363d1edc741d3880b1e671c478738 Boot ID: c70995c8f7b74b2dbd18b6a276988b4f Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-514.el7.x86_64 Architecture: x86-64 [root@wangsf ~]# hostnamectl set-hostname www.wangsf [root@wangsf ~]# hostname www.wangsf [root@wangsf ~]#
复制
网卡设置
--启动网卡服务及查看网卡状态信息 systemctl start NetworkManager systemctl status NetworkManager --查看帮助信息 [root@wangsf network-scripts]# nmcli --help Usage: nmcli [OPTIONS] OBJECT { COMMAND | help } OPTIONS -t[erse] terse output -p[retty] pretty output -m[ode] tabular|multiline output mode -c[olors] auto|yes|no whether to use colors in output -f[ields] <field1,field2,...>|all|common specify fields to output -e[scape] yes|no escape columns separators in values -a[sk] ask for missing parameters -s[how-secrets] allow displaying passwords -w[ait] <seconds> set timeout waiting for finishing operations -v[ersion] show program version -h[elp] print this help OBJECT g[eneral] NetworkManager's general status and operations n[etworking] overall networking control r[adio] NetworkManager radio switches c[onnection] NetworkManager's connections d[evice] devices managed by NetworkManager a[gent] NetworkManager secret agent or polkit agent m[onitor] monitor NetworkManager changes --修改网关信息 [root@wangsf network-scripts]# nmcli c modify ens33 \ ----注意"\"必须有 > ipv4.dns 192.168.181.250 \ ----注意"\"必须有 修改后生效,还需要重启网卡服务 nmcli connection up ens33 --启动网卡 nmcli connection show --查看网卡 [root@wangsf network-scripts]# nmcli c show ens33 | grep ipv4.dns --查询修改后的结果 ipv4.dns: 192.168.181.250 ipv4.dns-search: ipv4.dns-options: (default) ipv4.dns-priority: 0 [root@wangsf network-scripts]# nmcli --help
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
TA的专栏
PostgreSQL17新功能
收录17篇内容