linux基础

linux基础

grep小技巧 #grep -A20 "Memory Device$" #匹配Memory Device$开始的行,共20行
-A2,-B2,-C2
-A NUM, --after-context=NUM #后num行
-B NUM, --before-context=NUM #前num行
-C NUM, --context=NUM #前后各num行

关闭防火墙:systemctl enable firewalld /systemctl stop firewalld
关闭selinux: vi /etc/selinux/config 修改SELINUX=disabled 再setenforce 0临时关闭selinux

本地yum源文件
[localyum]
name=localyum
baseurl=file:///install
gpgcheck=0
enabled=1

4、修改系统时间
查看: date
修改: date --set "12/13/2019 11:30" 修改为2019年12月13日11:30
写入BIOS: hwclock -w

#dmidecode命令 可以让你在Linux系统下获取有关硬件方面的信息。
dmidecode的作用是将DMI数据库中的信息解码,以可读的文本方式显示。
由于DMI信息可以人为修改,因此里面的信息不一定是系统准确的信息。
dmidecode遵循SMBIOS/DMI标准,其输出的信息包括BIOS、系统、主板、处理器、内存、缓存等等。

查看服务器型号、序列号
#dmidecode|grep "System Information" -A9|egrep "Manufacturer|Product|Serial"
Manufacturer: VMware, Inc.
Product Name: VMware7,1
Serial Number: VMware-56 4d c6 52 c3 2c 54 49-d5 43 6f 04 d7 0d 72 e8
查看主板型号
#dmidecode |grep -A16 "System Information$"
System Information
Manufacturer: VMware, Inc.
Product Name: VMware7,1
Version: None
Serial Number: VMware-56 4d c6 52 c3 2c 54 49-d5 43 6f 04 d7 0d 72 e8
UUID: 52C64D56-2CC3-4954-D543-6F04D70D72E8
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: Intel Corporation
Product Name: 440BX Desktop Reference Platform
Version: None
Serial Number: None
Asset Tag: Not Specified
查看BIOS信息
#dmidecode -t bios
查看内存信息
#dmidecode -t memory
查看最大支持多少内存
#dmidecode|grep -P 'Maximums+Capacity'
查看内存的插槽数,已经使用多少插槽,每条内存多大
#dmidecode |grep -A5 "Memory Device" |grep Size|grep -v Range|
查看内存频率
#dmidecode|grep -A16 "Memory Device"|grep 'Speed'

#lsblk #查看硬盘和分区分布
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 18.8G 0 part
├─rhel-root 253:0 0 16.8G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 4.3G 0 rom /install


查看系统信息
#cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
查看内存
# free -m
total used free shared buff/cache available
Mem: 1820 119 1294 9 407 1516
Swap: 2047 0 2047

查看硬盘使用空间
#df -h

看负载
[root@redhat7 ~]# w
22:49:36 up 35 min, 2 users, load average: 0.00, 0.02, 0.05
###这三个数字分别代表1min5min15min的平均负载---0.00说明cpu比较空闲,1表示cpu危险
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 22:14 ? 0.00s 0.00s -bash
root pts/0 192.168.1.104 22:20 0.00s 0.10s 0.04s w

分析查看cpu信息
[root@redhat7 ~]# cat /proc/cpuinfo
processor : 0 #系统中逻辑处理核的编号。对于单核处理器,则课认为是其CPU编号,对于多核处理器则可以是物理核、或者使用超线程技术虚拟的逻辑核
vendor_id : GenuineIntel #CPU制造商
cpu family : 6 #CPU产品系列代号
model : 69 #CPU属于其系列中的哪一代的代号
model name : Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
stepping : 1 #CPU属于制作更新版本
microcode : 0x25
cpu MHz : 2600.027 #CPU的实际使用主频
cache size : 3072 KB #CPU二级缓存大小
physical id : 0 #单个CPU的标号
siblings : 1 #单个CPU逻辑物理核数
core id : 0 #当前物理核在其所处CPU中的编号,这个编号不一定连续
cpu cores : 1 #该逻辑核所处CPU的物理核数
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid xsaveopt ibpb ibrs stibp arat spec_ctrl intel_stibp
bogomips : 5200.05
clflush size : 64 #每次刷新缓存的大小单位
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual #可访问地址空间位数
power management:

# 查看物理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
1 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz

蓦然回首,那人却在,灯火阑珊处。
原文地址:https://www.cnblogs.com/linux-186/p/13594467.html