小标
2018-10-26
来源 :
阅读 1039
评论 0
摘要:本文主要向大家介绍了Linux运维知识之Linux Centos6.x 下常用查询命令整理,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。
本文主要向大家介绍了Linux运维知识之Linux Centos6.x 下常用查询命令整理,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。
Linux Centos6.x 下常用查询命令整理
---- 1.系统基本信息 ----
查看 系统版本
cat /etc/redhat-release
[root@test ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
查看 处理器架构
arch 或 uname -m
[root@test ~]# arch
x86_64
[root@test ~]# uname -m
x86_64
查看 内核版本
uname -r 或 cat /proc/version
[root@test ~]# uname -r
2.6.32-696.23.1.el6.x86_64
[root@test ~]# cat /proc/version
Linux version 2.6.32-696.23.1.el6.x86_64 (mockbuild@x86-01.bsys.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Tue Mar 13 22:44:18 UTC 2018
查看 系统信息
uname -a
[root@test ~]# uname -a
Linux test 2.6.32-696.23.1.el6.x86_64 #1 SMP Tue Mar 13 22:44:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
查看 系统时间
date
[root@test ~]# date
Thu Apr 5 16:06:07 CST 2018
---- 2. 用户相关信息 ----
查看 当前用户
whoami
[root@test ~]# whoami
root
查看 目前登录系统用户
w
[root@test ~]# w
15:50:09 up 22:04, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 255.255.255.255 15:37 0.00s 0.00s 0.00s w
查看 用户信息
cat /etc/passwd
[root@test ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
查看 用户组信息
cat /etc/group
[root@test ~]# cat /etc/group
root:x:0:
bin:x:1:bin,daemon
---- 3. 硬件+性能相关 ----
查看 CPU信息
cat /proc/cpuinfo
[root@test ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz
......
查看 内存信息
cat /proc/meminfo
[root@test ~]# cat /proc/meminfo
MemTotal: 2054152 kB
MemFree: 1638884 kB
Buffers: 31096 kB
Cached: 302444 kB
SwapCached: 0 kB
......
查看 cpu 内存 每五秒更新
vmstat 5
[root@test ~]# vmstat 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1638884 31112 302536 0 0 3 3 68 157 0 0 100 0 0
0 0 0 1638728 31112 302556 0 0 0 0 79 168 0 0 100 0 0
0 0 0 1638728 31120 302556 0 0 0 2 86 176 0 0 100 0 0
0 0 0 1638728 31120 302556 0 0 0 0 79 167 0 0 100 0 0
查看 磁盘剩余空间
df -h
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
tmpfs 939M 0 939M 0% /dev/shm
查看磁盘剩余Inodes节点
df -i
[root@test ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 2621440 62268 2559172 3% /
tmpfs 240257 1 240256 1% /dev/shm
查看 系统平均负载
cat /proc/loadavg
1、5、15分钟内的平均进程数、正在运行的进程数/进程总数、最近运行的进程ID号
[root@test ~]# cat /proc/loadavg
0.00 0.00 0.00 1/103 9728
查看 系统运行时间+负载
uptime
[root@test ~]# uptime
16:01:41 up 22:15, 1 user, load average: 0.00, 0.00, 0.00
网络状态查看
// 查看 指定端口
netstat -nlpt | grep 22
[root@test test]# netstat -nlpt | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1245/sshd
// 查看当前tcp连接数(ESTABLISHED)
netstat -nat | grep ESTABLISHED|wc -l
[root@test test]# netstat -nat | grep ESTABLISHED|wc -l
2
// 查看当前tcp连接数(TIME_WAIT)
netstat -na | grep ‘TIME_WAIT‘ |wc -l
[root@test test]# netstat -na | grep ‘TIME_WAIT‘ |wc -l
0
// 查看当前tcp连接数(指定端口)
netstat -nat | grep -i "22"|wc -l
[root@test test]# netstat -nat | grep -i "22"|wc -l
2
---- 4. 服务相关 ----
系统运行情况 - top
top
[root@test ~]# top
top - 16:11:31 up 22:25, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 76 total, 1 running, 75 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.3%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2054152k total, 417164k used, 1636988k free, 31384k buffers
Swap: 0k total, 0k used, 0k free, 303324k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1168 root 20 0 125m 12m 8588 S 0.0 0.6 2:31.16 AliYunDun
9677 root 20 0 100m 4464 3424 S 0.0 0.2 0:00.04 sshd
1364 postfix 20 0 81200 3516 2632 S 0.0 0.2 0:00.04 qmgr
系统运行情况 - htop
htop
需 yum install htop
[root@test ~]# htop
CPU[ 0.0%] Tasks: 25, 27 thr; 1 running
Mem[|||||##**************** 81/2006MB] Load average: 0.00 0.00 0.00
Swp[ 0/0MB] Uptime: 22:26:59
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1168 root 20 0 125M 12832 8588 S 0.3 0.6 2:31.33 /usr/local/aegis/aegis_client/aegis_10_41/AliYunDun
查看指定进程
ps -ef | grep 进程名
[root@test ~]# ps -ef | grep sshd
root 1245 1 0 Apr04 ? 00:00:00 /usr/sbin/sshd
root 9677 1245 0 15:37 ? 00:00:00 sshd: root@pts/0
查看服务状态
chkconfig --list
[root@test ~]# chkconfig --list
aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
agentwatch 0:off 1:off 2:on 3:on 4:on 5:on 6:off
aliyun-util 0:off 1:off 2:on 3:on 4:on 5:on 6:off
---- 5. 日志相关 ----
查看 当前用户执行过的命令
history
[root@test ~]# history
1 ls
2 clear
3 history
查看 最近5行系统日志
dmesg | tail -n5
[root@test ~]# dmesg | tail -n5
alloc irq_desc for 30 on node -1
alloc kstat_irqs on node -1
virtio-pci 0000:00:04.0: irq 30 for MSI/MSI-X
IPv6: Loaded, but administratively disabled, reboot required to enable
type=1305 audit(1522835175.952:3): audit_pid=1031 old=0 auid=4294967295 ses=4294967295 res=1
---- 6. 文件相关 ----
显示文件总大小 每个文件大小
ll -ht
[root@test test]# ll -ht
total 12K
-rw-r--r-- 1 root root 19 Apr 5 09:48 1.txt
-rw-r--r-- 1 root root 1 Apr 4 17:56 3.png
-rw-r--r-- 1 root root 1 Apr 4 17:56 2.png
tail 查看文件
// 显示最后20行
tail -n 20 error.log
// 时时刷新日志显示
tail -f access.log
全局查找文件
find / -name 1.txt
[root@test test]# find / -name 1.txt
/usr/local/src/test/1.txt
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注系统运维Linux频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号