赞
踩
链接: https://pan.baidu.com/s/17TF3Ah3fXqf8SZshVJMvFg 提取码: 0d8v
CentOS使用halt关机出现system halting卡死
使用如下命令解决方法:
使用 halt -p 正常关机不会出现 system halting
使用 shutdown -h now 正常关机不会出现 system halting
使用 systemctl poweroff 正常关机不会出现 system halting
安装环境:2021款M1MacBookPro,macOS Monterey 12系统 Apple M1芯片
安装时间:2021年12月02日
选择安装
第一次输入r
,刷新配置,可以看到有几个带感叹号⚠️的警告,接下来就一一设置
磁盘选择设置
,先选数字5
再按提示c c c
,完成磁盘的选择,如下图:
设置root密码,先选数字8
再按提示6688...
,完成密码设置,如下图:
输入b
后可以看到已经开始安装了,等着就好…
安装完成!
若出现license information(license not accepted),即说明需要同意许可信息,
输入1-回车-2-回车-c-回车-c回车,即可解决。
上面选择
q
退出,yes
确认后进入登录界面,输入用户:root、密码:6688…(密码是在安装过程已经设置好的)
cd /etc/sysconfig/network-scripts/
ls
ifcfg-
开头的就是我们要编辑的配置文件,每个人的文件名可能不同ONBOOT=yes
#开机自启TYPE=Ethernet #网卡类型
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp #动态获取
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s5
UUID=cd9c7deb-5cf8-4474-abf2-b06cf1bafc07
DEVICE=enp0s5 #设备名
ONBOOT=yes
shutdown -h now
:systemctl restart network.service
ip addr
,可以看到我们已经成功了curl www.baidu.com
, 测试通过!选择共享网络–再点开配置–网络–高级设置–打开网络首选项
vi /etc/sysconfig/network-scripts/ifcfg-enp0s5
ifcfg-
开头的文件可能名字不同# 修改为静态IP dhcp为动态ip none为无
BOOTPROTO=static
# IP地址
IPADDR=10.211.55.3
# 网关
GATEWAY=10.211.55.1
# 子网掩码
NETMASK=255.255.255.0
# 从no改成yes。系统将在启动时自动开启该接口
ONBOOT=yes
# DNS服务器1、2
DNS1=10.211.55.1
DNS2=8.8.8.8
systemctl restart network
或 service network restart
OK
表示成功,如果重启失败,如下图报错,可以尝试重启虚拟机 reboot
再尝试ping一下电脑ipFailed to restart network.service: Unit network.service not found
network
, 新版的叫:NetworkManager
systemctl restart NetworkManager
systemctl status NetworkManager
● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-12-01 10:24:49 EST; 30s ago Docs: man:NetworkManager(8) Main PID: 1585 (NetworkManager) Tasks: 3 (limit: 8530) Memory: 3.0M CGroup: /system.slice/NetworkManager.service └─1585 /usr/sbin/NetworkManager --no-daemon Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0732] device (enp0s5): state change: config -> ip-config (reason 'none', sys-iface-state: 'assume') Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0735] device (enp0s5): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'assume') Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0754] device (enp0s5): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'assume') Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0755] device (enp0s5): state change: secondaries -> activated (reason 'none', sys-iface-state: 'assume') Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0756] manager: NetworkManager state is now CONNECTED_LOCAL Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0758] manager: NetworkManager state is now CONNECTED_SITE Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0759] policy: set 'enp0s5' (enp0s5) as default for IPv4 routing and DNS Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0774] device (enp0s5): Activation: successful, device activated. Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0776] manager: NetworkManager state is now CONNECTED_GLOBAL Dec 01 10:24:49 localdomain NetworkManager[1585]: <info> [1638372289.0777] manager: startup complete
ping 10.211.55.3
ssh root@10.211.55.3
查看防火墙状态:firewall-cmd --state
或systemctl status firewalld.service
关闭:systemctl stop firewalld.service
永久关闭: systemctl disable firewalld.service
永久关闭效果图
Parallels Tools
Parallels Tools
安装文件[root@localdomain ~]# mount /dev/cdrom /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localdomain ~]# df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/sr0 60M 60M 0 100% /mnt
[root@localdomain ~]# cp -ra /mnt /opt/
[root@localdomain ~]# umount /mnt
[root@localdomain ~]#
修改源文件
一般我都是保留必须的,其它的先弄其它地方放着
[root@localdomain ~]# mv /etc/yum.repos.d/CentOS-* /opt/
[root@localdomain ~]# mv /opt/CentOS-Linux-Media.repo /etc/yum.repos.d/
[root@localdomain ~]# mkdir /media/CentOS/ -p
[root@localdomain ~]# mount /dev/cdrom /media/CentOS/
mount: /media/CentOS: WARNING: device write-protected, mounted read-only.
[root@localdomain ~]# df -h|grep /media/CentOS
/dev/sr0 6.8G 6.8G 0 100% /media/CentOS
上面的注意检查下,是这个6.8G
的,之前的那个tool的要umount掉,然后再操作上面的iso加载,不行就多操作或者重启机器了
修改vim /etc/yum.repos.d/CentOS-Linux-Media.repo
文件如下,centos7的是一个,注意这里centos8已经拆分成两个了
CentOS-Linux-Media.repo
原始文件如下
# CentOS-Linux-Media.repo # # You can use this repo to install items directly off the installation media. # Verify your mount point matches one of the below file:// paths. [media-baseos] name=CentOS Linux $releasever - Media - BaseOS baseurl=file:///media/CentOS/BaseOS file:///media/cdrom/BaseOS file:///media/cdrecorder/BaseOS gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [media-appstream] name=CentOS Linux $releasever - Media - AppStream baseurl=file:///media/CentOS/AppStream file:///media/cdrom/AppStream file:///media/cdrecorder/AppStream gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
修改后整个文件/etc/yum.repos.d/CentOS-Media.repo内容如下:
# CentOS-Linux-Media.repo # # You can use this repo to install items directly off the installation media. # Verify your mount point matches one of the below file:// paths. [media-baseos] name=CentOS Linux $releasever - Media - BaseOS baseurl=file:///media/CentOS/BaseOS # file:///media/cdrom/BaseOS # file:///media/cdrecorder/BaseOS gpgcheck=0 enabled=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [media-appstream] name=CentOS Linux $releasever - Media - AppStream baseurl=file:///media/CentOS/AppStream # file:///media/cdrom/AppStream # file:///media/cdrecorder/AppStream gpgcheck=0 enabled=1 # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [epel] name=epel baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/aarch64/ gpgcheck=0 enabled=1
yum makecache
[root@localdomain ~]# yum makecache
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - Media - BaseOS 317 MB/s | 1.5 MB 00:00
CentOS Linux 8 - Media - AppStream 561 MB/s | 6.0 MB 00:00
epel 7.2 MB/s | 11 MB 00:01
Metadata cache created.
Parallels Tools
[root@localdomain ~]# cd /opt/mnt/
[root@localdomain mnt]# ll
total 536
-r-xr-xr-x. 1 root root 1043 Nov 24 14:24 install
-r-xr-xr-x. 1 root root 533104 Nov 24 14:25 install-gui
dr-xr-xr-x. 3 root root 4096 Nov 24 14:25 installer
dr-xr-xr-x. 2 root root 28 Nov 24 14:24 kmods
dr-xr-xr-x. 4 root root 185 Nov 24 14:25 tools
-r--r--r--. 1 root root 13 Nov 24 14:25 version
[root@localdomain mnt]# ./install
说明一下,我这里是用iTerm连接的虚拟机,所以安装界面没有颜色
因为我上面IP
已经配置为静态,命令:ssh root@10.211.55.3
一路下一步,直到弹出成功的提示,然后重启机器!
检查是否真的安装好了,安装好了有共享文件夹功能,可以在linux里面直接访问Mac的文件
添加共享文件夹
[root@localdomain ~]# ls /media/psf/Downloads/
yum install net-tools
yum install wget
repo文件下载地址:
网易:http://mirrors.163.com/.help/…
阿里:http://mirrors.aliyun.com/
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
yum clean all
yum makecache
yum update -y
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum 源配置完成
相关链接:阿里云CentOS 镜像
yum makecache
出现报错Errors during downloading metadata for repository 'media-baseos':
…[root@localdomain ~]# yum makecache
Failed to set locale, defaulting to C.UTF-8
CentOS-8 - Base - mirrors.aliyun.com 3.9 MB/s | 2.9 MB 00:00
CentOS-8 - Extras - mirrors.aliyun.com 38 kB/s | 10 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.com 1.2 MB/s | 6.9 MB 00:05
CentOS Linux 8 - Media - BaseOS 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'media-baseos':
- Curl error (37): Couldn't read a file:// file for file:///media/CentOS/BaseOS/repodata/repomd.xml [Couldn't open file /media/CentOS/BaseOS/repodata/repomd.xml]
Error: Failed to download metadata for repo 'media-baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
[root@localdomain ~]#
mount /dev/sr0 /media/CentOS/
yum makecache
[root@localdomain yum.repos.d]# mount /dev/sr0 /media/CentOS/ mount: /media/CentOS: WARNING: device write-protected, mounted read-only. [root@localdomain yum.repos.d]# yum clean all Failed to set locale, defaulting to C.UTF-8 Repository extras is listed more than once in the configuration 33 files removed [root@localdomain yum.repos.d]# yum makecache Failed to set locale, defaulting to C.UTF-8 Repository extras is listed more than once in the configuration CentOS-8 - Base - mirrors.aliyun.com 4.7 MB/s | 2.9 MB 00:00 CentOS-8 - Extras - mirrors.aliyun.com 33 kB/s | 10 kB 00:00 CentOS-8 - AppStream - mirrors.aliyun.com 7.6 MB/s | 6.9 MB 00:00 CentOS Linux 8 - AppStream 4.6 MB/s | 6.9 MB 00:01 CentOS Linux 8 - BaseOS 2.5 MB/s | 2.9 MB 00:01 CentOS Linux 8 - Media - BaseOS 279 MB/s | 1.5 MB 00:00 CentOS Linux 8 - Media - AppStream 487 MB/s | 6.0 MB 00:00 epel 7.5 MB/s | 11 MB 00:01 Metadata cache created. [root@localdomain yum.repos.d]#
用普通账号进行登录可以避免 root 用户进行错误操作,而且用普通用户登录就像给服务器建立了两道墙,必须先用普通用户登录再设置能用 root 账号登录,所以后面还要配置禁止 root 用户通过 SSH 登录。
[root@localdomain ~]# useradd -d /usr/able -m able
# 新增用户,其中 -d 和 -m 是为用户 able 产生一个主目录 /usr/able
[root@localdomain ~]# passwd able # 为新增用户修改密码
Changing password for user able.
New password: # 输入密码
BAD PASSWORD: The password fails the dictionary check - it does not contain enough DIFFERENT characters
Retype new password: # 确认密码
passwd: all authentication tokens updated successfully.
[root@localdomain ~]#
这个普通用户有时也需要使用 root 权限,所以讲他加入到sudoers 用户组,
允许其使用sudo临时调用 root 权限
[root@localdomain etc]# echo 'able ALL=(ALL) ALL'>> /etc/sudoers
[root@localdomain etc]# tail -1 /etc/sudoers
able ALL=(ALL) ALL
[root@localdomain etc]#
进入配置文件:
/etc/ssh/sshd_config
找到如下语句进行修改
PermitRootLogin yes
把它改成
PermitRootLogin no
重启 sshd
systemctl restart sshd.service
这样别人就要必须要获取普通用户账号密码,然后才能破解 root
最后喜欢的小伙伴,记得关注收藏哦!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。