• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
2022
博客园    首页    新随笔    联系   管理    订阅  订阅

系统基本优化

修改主机名

# 方式一:

[root@local-work ~]# hostnamectl set-hostname local-work

# 需要重新登录或者执行一个解析器(bash)
# 方式二:cat /etc/hostname (重启生效)

查看系统IP

###### # 方式一: ip a
# 方式二: ifconfig(安装软件net-tools)

# 查看某一个网卡的信息
[root@string ~]# ifconfig eth0

系统时间
[root@string ~]# date
Fri Mar 5 09:50:27 CST 2021
[root@string ~]# date +%Y-%m-%d
2021-03-05

# 格式化时间

[root@string ~]# # 09:58:30
[root@string ~]# date +%H:%M:%S
10:01:44
[root@string ~]# date +%Y-%m-%d_%H:%M:%S
2021-03-05_10:02:05

# 设置时间

[root@string ~]# date -s "2029-03-05 10:02:44"
Mon Mar 5 10:02:44 CST 2029
[root@string ~]# date +%Y-%m-%d_%H:%M:%S
2029-03-05_10:03:03

# 同步互联网时间

[root@string ~]# yum install -y ntpdate
[root@string ~]# ntpdate ntp.aliyun.com

# 系统硬件时钟

[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:10:40 AM CST -0.271305 seconds

# 系统软件时钟

[root@string ~]# date
Mon Mar 5 10:03:30 CST 2029

# 获取硬件时间

[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:13:19 AM CST -0.473926 seconds

# 将硬件时间同步到系统时间

[root@string ~]# hwclock -r
Fri 05 Mar 2021 10:13:19 AM CST -0.473926 seconds
[root@string ~]# date
Mon Mar 5 10:06:20 CST 2029
[root@string ~]# hwclock -s
[root@string ~]# date
Fri Mar 5 10:14:19 CST 2021

# 查看时区状态

[root@string ~]# timedatectl status

# 设置时区

[root@string ~]# timedatectl set-timezone Asia/Shanghai
关机
[root@string ~]# init 6
[root@string ~]# shutdown -h 0
[root@string ~]# halt

# 重启

reboot
shutdown -r 0

#注销

1.exit
2.logout
3.Ctrl + d

修改系统下载源

https://developer.aliyun.com/mirror/

# 第一步:备份原来源

mkdir /etc/yum.repos.d/baskup/
mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/baskup/

# 第二步:下载新的源

[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 235 0 0:00:10 0:00:10 --:--:-- 601
[root@localhost yum.repos.d]# ls -l
total 4
drwxr-xr-x. 2 root root 187 Mar 3 16:14 backup
-rw-r--r--. 1 root root 2523 Mar 3 16:16 CentOS-Base.repo

# 第三步:生成新的源的缓存

[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
# 第四步:更新系统

[root@localhost yum.repos.d]# yum update -y

# 第五步:安装常用的计算机软件

[root@localhost yum.repos.d]# yum install vim lrzsz net-tools tree wget -y

# 第六步:关闭防火墙和Selinux

[root@localhost ~]# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

# 第七步:拍摄快照
posted @ 2021-03-12 18:04  博客之记  阅读(45)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3