Linux之 linux无法上网排查、更改yum源 、linux下面如何使用光盘、关闭配置、关闭selinux和防火墙 、、定时任务 、系统优化、 安装软件方法 、
linux下面安装软件
------>通过yum安装软件 需要你联网
1、安装常用软件 (下面其实是安装了4个软件)
yum install -y tree bash-completion wget vim
PS:
如何卸载rpm软件包
使用命令 rpm -e 包名,包名可以包含版本号等信息,但是不可以有后缀.rpm 比如卸载软件包proftpd-1.2.8-1,可以使用下列格式: rpm -e proftpd-1.2.8-1 rpm -e proftpd-1.2.8 rpm -e proftpd- rpm -e proftpd
更改系统的yum源
------>改为阿里云 #https://opsx.alibaba.com/mirror 来源

输入下面两条命令:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ##备份操作
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #更改源
下面用图解释:

选择下面这个,选择具体使用哪一个之前,先试一下wget或者curl

经过以上操作,即可完成修改yum源
ps:更改yum源有以下几种方法
1.更改系统的yum源
#阿里云 mirrors.aliyun.com
https://opsx.alibaba.com/mirror
#清华
https://mirrors.tuna.tsinghua.edu.cn/help/centos/
#网易
http://mirrors.163.com/.help/centos.html
———————————————————————
补充,增加epel源
首先下载这个epel

到这个网址,选择帮助

———————————————————————
Linux无法上网排查过程
Linux无法上网排查过程 1. 查看是否能上网 [root@bigdata ~]# ping baidu.com connect: 网络不可达 2. 验证是否DNS 域名解析 域名---->ip地址 [root@bigdata ~]# ping 223.5.5.5 connect: 网络不可达 3. 网关-验证你的网络配置(网卡 虚拟机vmwarexxx)是否有问题 ip r ##这是查看网关,为什么网关是 10.0.0.2,是用ip r来查看的 [root@bigdata ~]# ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=0.206 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=128 time=0.170 ms ^C --- 10.0.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.170/0.188/0.206/0.018 ms
linux下面如何使用光盘、
若连不上网的,可以用下面的命令rpm -ivh来进行手动安装,后面的是需要安装的文件

ps:
rpm相当于是win系统中的exe文件,可执行文件,记住以rpm结尾的,就是可执行文件

注意,要想不联网就安装,则需要执行上面mount挂载这些
对上面操作简单总结:
Linux下面安装软件: yum 通过光盘安装 yum yum install rpm -ivh 编译安装------>下面一一对应 三部曲: 备菜切菜 做菜 上菜 nginx ./configure make make install
———————————————————————
PS:
小插曲、补充一个命令

#rpm -qa vim-enhanced tree wget 这里是查看已经安装好了的这三个软件

———————————————————————
关闭配置操作(关闭SElinux )
1#永久 修改配置文件 重启服务器之后生效
# enforcing - 已开启 正在运行
# permissive - selinux关闭 警告提示
# disabled - 彻底关闭
SELINUX=enforcing
|
↓
SELINUX=disabled
#先备份操作
cp /etc/selinux/config /etc/selinux/config.bak
#快捷键:esc + .(点) 使用上一个命令的最后一个东西(参数)
#修改数据操作,这一行不加-i,不是真正修改
sed 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
#加 -i这一行才是真正修改操作
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
[root@oldboyedu-s8 ~]# cat /etc/selinux/config
# 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 two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
2#临时 重启服务器之后失效
[root@oldboyedu-s8 ~]# getenforce
Enforcing
[root@oldboyedu-s8 ~]# #显示当前selinux
[root@oldboyedu-s8 ~]# #显示当前selinux的运行状态
[root@oldboyedu-s8 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ] #这是让其选择
[root@oldboyedu-s8 ~]# setenforce 0
[root@oldboyedu-s8 ~]# getenforce
Permissive
对上面操作的ps:
下面操作是查看是否装了自动补全工具;若装了之后需要重启xshell

esc +小数点

sed
注意格式,一对单引号,sg开头和结尾,中间是三个井号,‘s###g’
———————————————————————
关闭防火墙操作
防火墙------>自己搭建的网站,防火墙需要关掉,否则会给自己带来麻烦
#查询防火墙状态 systemctl status firewalld.service #关闭当前正在运行的防火墙 --- 临时关闭 systemctl stop firewalld.service #让防火墙不会开机自启动 --- 永久关闭 systemctl disable firewalld.service 查看是否关闭,查看是否开机自动启动 #systemctl is-active firewalld.service #is-active 是否正在运行 是否健在 #systemctl is-enabled firewalld.service #is-enabled 是否开机自启动
修改完毕之后,输入下面的命令即可查看,箭头指向是执行结果

附属全图------> 这就表示全部关闭了

ps:测试,查看network的状态
跟上面查看防火墙的状态操作是一致的,但是要注意不要关掉

———————————————————————
定时任务
------>注意查看状态用cronie,并不是crond;这个东西是默认安装的,不需要自己额外安装

[root@oldboys8-0425 ~]# crontab -e
#sync time #定是任务名称
*/2 * * * * /usr/sbin/ntpdate ntp1.aliyun.com #定时任务, /usr/sbin是这个根目录,ntpdate用这个来进行更新,后面的是用阿里的来同步时间,看代码下面的图片解释
~
~
~
~
~
~
~
~
~
~
~
~
~
Type :quit<Enter> to exit Vim
####最后记得保存退出
让系统自动同步时间------>用ntpdate
用crontab-e表示进行设置定时任务 (ps:这个能有检查功能,只能检查格式对不对)
修改时间操作,可用这个,这里是做测试,暂时修改成20190101,过2分钟输入date查看时间是否同步回来

———————————————————————
ps:
———————————————————————
浙公网安备 33010602011771号