作者:lizhonglin
github: https://github.com/Leezhonglin/
blog: https://leezhonglin.github.io
查看当前系统版本
centos
cat /etc/redhat-release
more /etc/redhat-release
查看内核版本
centos
uname -r
unmae -a
查看主机名称
hostname
修改主机名,编辑/etc/hostname
,保存退出重启系统生效.
vim /etc/hostname
查看CPU信息
查看CPU信息信息
cat /proc/cpuinfo
查看cpu型号
cat /proc/cpuinfo |grep "name" |cut -f2 -d: |uniq -c
查看物理CPU个数
cat /proc/cpuinfo | grep "physical"| sort |uniq -c
查看CPU运行在多少位模式下面
getconf LONG_BIT
查看内存信息
查看内存详细信息
cat /proc/meminfo
查看内存
free -m
-b 以Byte为单位显示内存使用情况。
-k 以KB为单位显示内存使用情况。
-m 以MB为单位显示内存使用情况。
-h 以合适的单位显示内存使用情况,最大为三位数,自动计算对应的单位值。
查看服务器型号和序列号
sudo dmidecode | grep "System Information" -A9 | egrep "Manufacturer|Product|Serial"
查看内存槽及内存条
sudo dmidecode -t memory
查看内存插槽,已经使用多少插槽,每条内存大小
sudo dmidecode -t memory | grep Size
查看硬盘信息
查看分区和硬盘
lsblk
查看空间使用情况
df -h
统计当前目录各文件夹大小
du -sh ./*
zip命令
压缩当前test目录,为test.zip
zip -r test.zip ./test
压缩当前test目录和文件demo.txt 为demo.zip
zip -r demo.zip test/ demo.txt
压缩当前文件夹的多个文件为一个demo.zip
zip demo.zip test1.txt demo.txt
unzip命令
查看zip文件信息
unzip -v demo.zip
查看解压文件是否完整
unzip -t demo.zip
解压demo.zip到当前目录
unzip demo.zip
解压demo.zip到指定的目录,如果文件夹不存在会创建文件夹,
unzip demo.zip -d /home/shell_learing_demo/test
批量解压demo1.zip,demo2.zip文件到指定目录
unzip demo\*.zip -d ./test2
wget命令
wget命令用来从指定的URL下载文件。wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败,wget会不断的尝试,直到整个文件下载完毕。如果是服务器打断下载过程,它会再次联到服务器上从停止的地方继续下载。这对从那些限定了链接时间的服务器上下载大文件非常有用。
wget (选项) (参数)
下载单个文件
wget http://www.testdemo.com/demo.zip
下载文件,并给文件别名
wget -O test.zip http://www.testdemo.com/demo.zip
限制速度下载
wget --limit-rate=300k http://www.testdemo.com/demo.zip
断点续传下载
wget -c http://www.testdemo.com/demo.zip
后台下载
wget -b http://www.testdemo.com/demo.zip
查看后台下载的进度
tail -f wget-log
修改linux时区
timedatectl set-timezone Asia/Shanghai
安装htop
yum install epel-release -y
yum install htop -y
centos8重启网卡
nmcli c reload enp0s3
# 马上生效
nmcli c up enp0s3
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
IP地址配置
编辑配置文件/etc/sysconfig/network-scripts/ifcfg-XXX
, XXX
根据自己的配置文件来定.替换下面的配在为自己的对应的配置.
BOOTPROTO=static
IPADDR=192.169.0.234
PREFIX=24
GATEWAY=192.169.0.1
DNS1=61.139.2.69
文件追加内容
echo "192.169.0.105 localhost" >> /etc/hosts
覆盖文件内容
echo "192.169.0.105 localhost" > /etc/hosts
查看文件的后40行
tail -n 40 文件路径
#或者
cat xxx |tail -40
查看文件前40行
head -n 40 文件路径
# 或者
cat xxx|head -40
持续更新中…