title: Centos 基本命令
date: 2018-07-01 16:01:33
categories:
- Linux
- centos
tags: [linux,centos]
常用命令:
搜索软件yum search package安装软件yum install package安装某个版本的软件包yum install package=version卸载某个软件包yum remove package升级某个软件包yum update package
源:
-- 查看源
yum repolist
-- 全部源(包含禁用的)
yum repolist all
-- 禁用原来无效的源
yum --disable repoid
-- 查询是否安装了 某个yum源
rpm -qa |grep repo-name
-- 删除该yum源
rpm -e repo-name
yum remove repo-name
--1 首先备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
--2 阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2 华为云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
--3 添加好以后需要先刷新:
yum clean all
yum makecache
SSH:
$ vim /etc/ssh/sshd_config
-- 做如下修改:
PermitRootLogin yes //权限root登录
PasswordAuthentication yes //密码验证
防火墙端口:
$ vim /etc/sysconfig/SuSEfirewall2
-- 做如下修改
FW_SERVICES_EXT_UDP="22"
FW_SERVICES_EXT_TCP="22"
--SSH自启动:
$ systemctl enable sshd.service
--SSH状态/重启
$ systemctl status/restart sshd.service
防火墙:
--启动防火墙
systemctl start firewalld
systemctl stop firewalld
--自启
systemctl enable firewalld
sytemctl disable firewalld
自启动:
1 vim /etc/init.d/after.local
--添加如下
/usr/local/run.sh
2 新建脚本 vim /usr/local/run.sh
--添加如下
echo "this is " > /usr/local/1.txt
3 脚本赋值 权限
chmod +x run.sh
4 重启看/usr/local/1.txt
reboot
只下载不安装
- downloadonly
#下载 yum install --downloadonly --downloaddir=/httpd/ httpd #安装 yum install *.rpm rpm -Uvh --nodeps --force *.rpm
证书过期
- 配置
vi /etc/yum.conf#关闭验证 sslverify=false
- 清理
yum clean all yum makecache
