查看Linux系统信息命令详解

查看Linux系统信息命令是Linux初学者必备的基础知识,这些基础命令非常有用, 如果你是使用字符界面进行操作,你需要知道你现在使用的Linux系统版本、位数等信息。在了解了这些信息后,你才好选择安装x86还是x64类型的工具软件,不然安装就有可能出现问题。

查看Linux系统信息命令是Linux初学者必备的基础知识,这些基础命令非常有用, 如果你是使用字符界面进行操作,你需要知道你现在使用的Linux系统版本、位数等信息。在了解了这些信息后,你才好选择安装x86还是x64类型的工具软件,不然安装就有可能出现问题。

下面列出了Linux发行版比较常用的系统信息查询的命令, 供大家可以参考:

uname -a 查看内核/操作系统/CPU信息

[chenwei@localhost /]$ uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

head -n 1 /etc/issue 查看操作系统版本

cat /proc/cpuinfo 查看CPU信息

[chenwei@localhost /]$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 45
model name      : Intel(R) Xeon(R) CPU E5-2407 0 @ 2.20GHz
stepping        : 7
microcode       : 0x70d
cpu MHz         : 2194.759
cache size      : 10240 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
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 dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx hypervisor lahf_lm arat epb pln pts dtherm tsc_adjust
bogomips        : 4389.51
clflush size    : 64
cache_alignment : 64
address sizes   : 42 bits physical, 48 bits virtual
power management:

hostname 查看计算机名

[chenwei@localhost /]$ hostname
localhost.localdomain

lspci -tv 列出所有PCI设备

lsusb -tv 列出所有USB设备

lsmod 列出加载的内核模块

env 查看环境变量资源

free -m 查看内存使用量和交换区使用量

df -h 查看各分区使用情况

du -sh <目录名> 查看指定目录的大小

grep MemTotal /proc/meminfo 查看内存总量

grep MemFree /proc/meminfo 查看空闲内存量

uptime 查看系统运行时间、用户数、负载

cat /proc/loadavg 查看系统负载磁盘和分区

mount | column -t 查看挂接的分区状态 

fdisk -l 查看所有分区

swapon -s  查看所有交换分区

hdparm -i /dev/hda   查看磁盘参数(仅适用于IDE设备)

dmesg | grep IDE  查看启动时IDE设备检测状况网络

ifconfig   查看所有网络接口的属性

iptables -L   查看防火墙设置

route -n  查看路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.3.254   0.0.0.0         UG    100    0        0 eno16777736
192.168.3.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777736

netstat -lntp   查看所有监听端口

(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:631                 :::*                    LISTEN      -                   
tcp6       0      0 ::1:25                  :::*                    LISTEN      -

netstat -antp   查看所有已经建立的连接

netstat -s   查看网络统计信息进程

Ip:
    158343 total packets received
    0 forwarded
    0 incoming packets discarded
    2815 incoming packets delivered
    3656 requests sent out
    108 outgoing packets dropped
Icmp:
    232 ICMP messages received
    0 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 218
        echo requests: 9
        echo replies: 5
    355 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 341

ps -ef   查看所有进程

top - 19:34:38 up 17:12,  3 users,  load average: 0.00, 0.01, 0.05
Tasks: 404 total,   2 running, 402 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
KiB Mem :  1870496 total,    85636 free,   753024 used,  1031836 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   860212 avail Mem 
   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND     
 58599 chenwei   20   0  130288   2068   1264 R  0.7  0.1   0:00.45 top         
 12438 chenw     20   0 1794716 421380  40952 S  0.3 22.5   6:33.77 gnome-shell 
     1 root      20   0   60520   7856   2672 S  0.0  0.4   0:05.06 systemd     
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.03 kthreadd    
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.87 ksoftirqd/0 
     5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:+ 
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.86 kworker/u2+ 
     7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0 
     8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh      
     9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/0     
    10 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/1

top  实时显示进程状态用户

top - 19:34:07 up 17:11,  3 users,  load average: 0.01, 0.02, 0.05
Tasks: 404 total,   2 running, 402 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
KiB Mem :  1870496 total,    86316 free,   752344 used,  1031836 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   860892 avail Mem 
   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND     
 58599 chenwei   20   0  130288   2068   1264 R  0.7  0.1   0:00.26 top         
   138 root      20   0       0      0      0 R  0.3  0.0   0:09.61 rcuos/0     
 12438 chenw     20   0 1794716 421380  40952 S  0.3 22.5   6:33.68 gnome-shell 
     1 root      20   0   60520   7856   2672 S  0.0  0.4   0:05.06 systemd     
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.03 kthreadd    
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.87 ksoftirqd/0 
     5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:+ 
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.86 kworker/u2+ 
     7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0 
     8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh      
     9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/0

w  查看活动用户

id <用户名>  查看指定用户信息

last  查看用户登录日志

cut -d: -f1 /etc/passwd  查看系统所有用户

cut -d: -f1 /etc/group  查看系统所有组

crontab -l  查看当前用户的计划任务服务

chkconfig –list  列出所有系统服务

chkconfig –list | grep on  列出所有启动的系统服务程序

rpm -qa  查看所有安装的软件包

活着就要学习,学习不是为了活着。 —— 培根
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号