Linux(CentOS)常用命令及问题解决方案整理

阿里云开源镜像

CentOS 7设置网络开机自动连接

修改/etc/sysconfig/network-scripts/ifcfg-en***文件,
将最后一行的ONBOOT= 后边的no改为yes,保存即可。

ifconfig

如果ifconfig命令无效,通过安装net-tools进行解决,如下:
yum -y install net-tools

防火墙

	## CentOS7版本后防火墙默认使用firewalld,因此在CentOS7中关闭防火墙使用以下命令,
    ## 临时关闭
    [root@localhost /]# systemctl stop firewalld
    ## 禁止开机启动
    [root@localhost /]# systemctl disable firewalld

	## 如果安装了iptables-service,也可以使用下面的命令
	#先检查是否安装了iptables
	[root@localhost /]# service iptables status
	#安装iptables
	[root@localhost /]# yum install -y iptables
	#升级iptables
	[root@localhost /]# yum update iptables
	#安装iptables-services
	[root@localhost /]# yum install iptables-services
	#关闭防火墙
	[root@localhost /]# service iptables stop

	## 通过设置Linux的防火墙,开启3306端口
	[root@localhost /]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
	## 重新刷新防火墙
	[root@localhost /]# /etc/rc.d/init.d/iptables save
	## 或者关闭防火墙
	[root@localhost /]# service iptables close

yum install的时候提示:Loaded plugins: fastestmirror

	#fastestmirror是yum的一个加速插件,这里是插件提示信息是插件不能用了。
	#不能用就先别用呗,禁用掉,先yum了再说。
	#修改插件的配置文件
	[root@localhost /]# vi  /etc/yum/pluginconf.d/fastestmirror.conf  
	enabled = 1 # 由1改为0,禁用该插件
	# 修改yum的配置文件
	[root@localhost /]# vi /etc/yum.conf
    plugins=1 # 改为0,不使用插件

进程

    ## 查看进程
    ps -ef | grep redis
    ## 删除进程
    kill -9 pid

查找程序相关位置

	[root@localhost /]# whereis mysql

解压缩命令

	# tar打包: 
	tar czvf fileName.tar dirName
	# tar解压:  
	tar zxvf fileName.tar
	# ZIP压缩命令:
	zip -r xxx.zip ./*
	# ZIP解压命令:
	unzip filename.zip

端口查看

  • lsof -i:端口号 用于查看某一端口的占用情况,比如查看8000端口使用情况,lsof -i:8000
  • netstat -tunlp | grep 端口号,用于查看指定的端口号的进程情况,如查看8000端口的情况,netstat -tunlp
    |grep 8000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值