linux上 shell 的指令操作 ,指令。
指令:
uname -o: 查看操作系统类型
uname -n: 查看用户名
uname -m:查看 cpu 的指令集
uname -a: 查看操作系统内核信息
Usage: uname [OPTION]...
Print certain system information. With no OPTION, same as -s.
-a, --all print all information, in the following order,
except omit -p and -i if unknown:
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type or "unknown"
-i, --hardware-platform print the hardware platform or "unknown"
-o, --operating-system print the operating system
--help display this help and exit
--version output version information and exit
hostname -i: 查看内网ip
curl -s ipecho.net/plain: 查看外网ip
ping -c 2 baidu.com : ping一下外网方式
who:查看 当前登录用户数
获取操作系统的内容:
free -m:获取操作系统内容
top -n 1 : 查看cpu 使用情况
top -n 1 b : 查看cpu 使用情况
查看磁盘信息
ds -f:
root@aliyun247 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 5.8G 13G 31% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/xvdb1 493G 3.7G 464G 1% /data
[root@aliyun247 ~]# df -h |grep -vE 'Filesystem'
/dev/xvda1 20G 5.8G 13G 31% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/xvdb1 493G 3.7G 464G 1% /data
[root@aliyun247 ~]# df -hP |grep -vE 'Filesystem' |awk '{print $1 $5}'
/dev/xvda 131%
tmpfs 0%
/dev/xvdb 11%
[root@aliyun247 ~]# df -hP|grep -vE 'Filesystem|tmpfs' |awk '{print $1 $5}'
/dev/xvda131%
/dev/xvdb11%
[root@aliyun247 ~]# df -hP|grep -vE 'Filesystem | tmpfs' |awk '{print $1 $5}'
/dev/xvda131%
tmpfs0%
/dev/xvdb11%
注意: -vE 'Fileyste|tempfs' | 直接的字段内容不能空格
Filesystem :磁盘设备名称
Size:设备总容量
Used: 已用容量
Avail: 可用容量
Use%: 使用容量百分比
Mounted on: 设备挂载的系统目录文件
1 主控制脚本的实现
2 系统信息及运行状态的获取
3 ngnix和mysql 运行状态分析
4 应用日志分析