Linux常用命令集锦

查看系统版本

lsb

yum install lsb
lsb_release -a
[root@MiWiFi-R3-srv ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 8.0.1905 (Core)
Release:        8.0.1905
Codename:       Core

内核版本

[root@VM_0_9_centos k8s]# cat /proc/version
Linux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16:44:24 UTC 2018

发行版本

[root@MiWiFi-R3-srv ~]# cat /etc/issue
\S
Kernel \r on an \m

注解

这种版本信息有什么作用?

查看CPU信息

# 查看物理CPU个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq
# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l
# 查看CPU信息(型号)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

设置python3为默认python

在`~/.bash_profile`中加入

PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/bin
alias python="/usr/local/bin/python3"
alias pip="/usr/local/bin/pip3"

export PATH

注解

使用了alias

执行

source ~/.bash_profile

vim

替换字符串

#
:s/elseif/elif/
:s/elseif/elif/g
# 全文替换;将elseif替换为elif
:%s/elseif/elif/g

查看日志

systemctl

systemctl status kube-controller-manager

journalctl

journalctl -u kube-controller-manager