yum clean all
yum makecache //将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
yum update
openssh(貌似只有客户端没有服务端):mls-software.com
适用于CentOS7系统,其他系统有些命令不支持
新建多级目录,当abcd目录不存在时mkdir会报错,添加-p属性
mkdir -p /opt/abcd/lgb
安装netstat命令(经常使用,经常危机)
yum install -y net-tools
yum 删除包,查询后删除
rpm -qa | grep ***
******
yum remove -y ****
docker pull *** 报错让你登录“docker login ”
通常是你的镜像名打错了,docker pull nginx 试试,成功的话用docker search **** 查询正确的镜像名。后来发现镜像名是centos而不是linux。
[root@ansible-14 ~]# docker pull linux
Using default tag: latest
Error response from daemon: pull access denied for linux, repository does not exist or may require 'docker login'
wget: unable to resolve host address ‘mirrors.aliyun.com’
vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
source /etc/resolv.conf
无法识别阿里云域名,但ping mirrors.aliyun.com 没问题
yum install epel-release 失败
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
!!!!!!如果上面那个源不行,用这个!!!!!!大坑,明明都是阿里的
wget http://mirrors.aliyun.com/repo/Centos-7.repo
vi/vim检索关键字
命令模式
:/****
"n"可以跳转到下一个关键字位置
cat 查看配置文件不显示空行以及注释行(!!!非常实用)
cat 文件 | grep -Ev '^$|#'
cat /etc/zabbix/zabbix_agentd.conf | grep -Ev '^$|#'
vi/vim删除所有注释行,对于常用的配置文件非常有用,又臭又长的注释很烦人,有时还会有括号问题,命令实际就是删除带#号的行和空行。
:g/#/d
:g/^$/d
wget不检查证书
wget URL --no-check-certificate
wget https://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img --no-check-certificate
虚拟机设置静态IP
vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.136.136.10
NETMASK=255.255.255.255
GATEWAY=192.168.136.2
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux,要重启
vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
时间同步ntp服务
yum install ntpdate -y
timedatectl set-timezone Asia/Shanghai
ntpdate ntp1.aliyun.com
systemctl enable ntpdate
不关机更改主机名,不会立即展现,需稍等片刻
hostnamectl set-hostname datbase
安装Linux GUI
yum -y groupinstall "X Window System"
yum -y groupinstall "GNOME Desktop"
yum -y install virt-manager
init 5 ###临时进入图形化系统,重启后失效
设置开机启动级别,重启后生效,永久生效。
systemctl get-default ###查看当前运行级别
systemctl set-default multi-user.target ###3级
systemctl set-default graphical.target ###5级