0
点赞
收藏
分享

微信扫一扫

基本系统优化


修改主机名

方式一: hostnamectl set-hostname mm (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 ~]# 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

# 第七步:拍摄快照


举报

相关推荐

0 条评论