Linux课后学习(配置与初始化) | 青训营笔记

95 阅读2分钟

正所谓,预先善其事必先利其器,学习linux命令之前我们要用VMware Workstation Pro来搭建centos系统,并使用一个美观的Tabby Terminal来代替Xshell连接linux系统(当然也可以使用Xshell,个人习惯)。

这里我已经把centos搭建在VMware中,网上也有很多教程,就不一一罗列了,附上我觉得可以的一个链接

1、配置静态ip

修改etc/sysconfig/network-scripts/ifcfg-ens33配置文件,将类型设为静态static,设置自动重启,配置ip、子网掩码、网关、DNS。 如图:

afd25d3f065dddfe859075907f8da85e.png

DNS2可要可不要 vm菜单,选择(编辑 -> 虚拟网络编辑器),页面如下:

配置ip

image.png

前几个需要相同,最后一位可自定义。

配置网关

image.png

将网关配置

DNS1填上第一个图中DNS1即可

2、连接

新建一个SSH连接

image.png

配置centos的ip地址、用户名、密码

image.png

3、重启网卡 service network restart

image.png

查看ip

image.png

现在我们的ip就配置好了

4、关闭防火墙进行远程连接

image.png

罗列几个情况给大家参考

查看防火墙状态

systemctl status firewalld

service iptables status

暂时关闭防火墙

systemctl stop firewalld

service iptables stop

永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

重启防火墙

systemctl enable firewalld

service iptables restart

永久关闭并启动

chkconfig iptables on

5、连接成功

image.png

6、踩坑经历

Loading mirror speeds from cached hostfile

There are no enabled repos.

Run "yum repolist all" to see the repos you have.

To enable Red Hat Subscription Management repositories:

    subscription-manager repos --enable

To enable custom repositories:

    yum-config-manager --enable

解决方案:

解决方法:在终端运行curl -o /etc/yum.repos.d/CentOS-Base.repo mirrors.aliyun.com/repo/Centos…

再运行安装命令:yum -y install wget即可

参考地址:

www.jianshu.com/p/ab0aea07e…

记得配置成功后存一个镜像,有什么问题也可以在下面讨论,一起学习。

最后附上工具链接:

Tabby Terminal:gitcode.net/mirrors/Eug…