Linux相关命令学习增加篇

Linux相关命令学习增加篇

一、网络不通,无法连接外网

1.网关ip配置路径:

cd /etc/sysconfig/network-scripts/

2、跟踪路由,查看路由器从网关发出的ip包

traceroute 114.114.114.114

3、查询DNS的信息

nslookup www.baidu.com 

4、查看路由信息

route

5、重启网络

service network restart

6、在路由中增加网关

route add default gw 192.168.61.2  //ip是自己的默认网关

7、查看路由

netstat -rn

8、查看是否有命令并下载

yum search ifconfig
yum install net-tools.x86_64
yum update  //更新yum源

9、更新yum源

摘抄:

https://blog.csdn.net/WillDic/article/details/115052286?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522161659184616780357233041%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=161659184616780357233041&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_v2~rank_v29-1-115052286.pc_search_result_no_baidu_js&utm_term=Centos7%E6%9B%B4%E6%8D%A2yum%E6%BA%90
阿里巴巴开源镜像站 https://developer.aliyun.com/mirror/

根据官网的说明,分别有 CentOS 6、CentOS 7、CentOS 8等配置操作步骤。

(1)、备份,将 CentOS-Base.repo 为CentOS-Base.repo.backup
	mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
(2)、下载新的 http://mirrors.aliyun.com/repo/Centos-7.repo,并命名为CentOS-Base.repo

	wget -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
	curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

(3)、清除缓存

yum clean all     # 清除系统所有的yum缓存
yum makecache     # 生成yum缓存

10、防火墙相关

yum install iptables-service
systemctl enable iptables  //设置为开机自启动
systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables
service iptables save

11、sed命令

Sed 可依照脚本的指令来处理、编辑文本文件。Sed 主要用来自动编辑一个或多个文件、简化对文件的反复操作、编写转换程序等。
在这里插入图片描述
在这里插入图片描述

12、关闭selinux

sed -i 's/enforcing/disabled/'  /etc/selinux/config  //永久关闭
seetenforce 0  //临时关闭

13、关闭swapoff

swapoff -a //临时关闭

14、修改主机名字

hostnamectl set-hostname  名字
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值