【linux笔记】刚创建的linux为方便后期使用的准备工作

1、关闭防火墙和selinux

[root@localhost~]# systemctl stop firewalld

[root@localhost~]# setenforce 0

2、永久关闭防火墙和selinux

(1)永久关闭防火墙

[root@localhost~]# systemctl disable firewalld  

(2)永久关闭selinux,修改配置文件/etc/selinux/config

 [root@localhost~]# vim /etc/selinux/config  

(3)将文件内SELINUX=XX这行改为 SELINUX=disabled,然后保存退出,重启生效

 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

(4)查看selinux状态

[root@localhost~]# getenforce 
Disabled

3、设置静态ip

设置静态ip,我们就需要修改 /etc/sysconfig/network-scripts/ifcfg-ens33 配置文件。

[root@localhost~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

(1) 将 BOOTPROTO = dhcp 改成 BOOTPROTO = static
也就是将动态ip,改成静态ip
(2) 新增4行地址:

# ip输入自己要设置的ip,192.168.10不动
IPADDR=192.168.10.102
NETMASK=255.255.255.0         # 子网掩码
GATEWAY=192.168.10.2		  #  网关地址
DNS1=192.168.10.2			  #  DNS服务器

(3)重启机器或网络

reboot
systemctl restart network

4、更换网络yum源–aliyun

https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11WaK1yM --阿里yum源地址

[root@linux-server ~]# cd /etc/yum.repos.d
[root@linux-server yum.repos.d]# mkdir back
[root@linux-server yum.repos.d]# mv *.repo back
[root@linux-server yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo  #下载aliyun的yum源
	最小化安装没有wget命令,使用curl -o代替
参数解释
curl -o  指定存放路径
或者
wget -O 
安装扩展源--epel.repo
[root@linux-server ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@linux-server ~]# cd /etc/yum.repos.d/
[root@linux-server yum.repos.d]# ls
CentOS-Base.repo  epel.repo

查看当前源:
[root@linux-server ~]# yum repolist

5、自动补全

一般情况下按tab会自动补全内容,但是如果启动服务或者一些常见的场景,tab补全不了内容,这时就需要下载一个加强版的tab了

# yum install bash-completion* -y

// 注意在centos7.5的版本补全功能并不尽人意,7.9版本好用
// 这是一个插件,不需要启动就能提供服务

6、centos7版本升级(升级到centos7.9)

一般下载的centos7的光驱的centos版本为7.5版本,但是个人认为7.5版本没有7.9版本好用,比如上面提到的补全功能,7.5和7.9拿着同样的插件却展现出不同的功能。
下面是升级的步骤

1.备份重要数据:在进行任何系统升级之前,请确保备份了重要的数据和配置文件,以防意外情况发生。
2.更新当前系统:运行以下命令确保当前系统已更新到最新版本:

# yum update
这会更新 CentOS 7.5 上所有已安装的软件包。

3.安装 CentOS 7.9 的软件包:运行以下命令以安装 CentOS 7.9 的软件包:

# yum install centos-release

4.运行系统升级:最后,运行以下命令来执行系统升级:

# yum update

5.重启系统:完成升级后,建议重新启动系统以应用所有更改:

# reboot

7.在shell中tab宽度设置

在shell中默认按tab宽度并不是4格,有编程习惯后用不了tab太难受了,所以要经常编写shell脚本的话应当更改到合适的tab宽度

# vim /etc/vimrc

在文件最后添加

set tabstop=4

这样就能在shell中快乐的编程了。

8.CentOSmini中man不完整问题

解决方案:安装man-pages软件包

[root@aliyun ~]# yum -y install man-pages

9.同步时间

# 通过ntpdate进行时间同步
[root@aliyun ~]# yum -y install ntpdate

# 同步阿里云时间(易记)
[root@aliyun ~]# ntpdate ntp.aliyun.com
30 Aug 09:41:12 ntpdate[12724]: adjust time server 203.107.6.88 offset 0.000194 sec

10.最小化下载一些用的上的组件

[root@aliyun ~]# yum -y install vim  wget  net-tools  lsof
							   #编辑  下载   netstat命令
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值