centos 7.0版本以上,修改日期和时间及网卡配置

centos 7.0版本以上,修改日期和时间及网卡配置

# 日期和时间设置–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
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

墨竹~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值