查看Linux系统的常见命令

一、主机型号

[[email protected] ~]# dmidecode | grep "Product Name"

[[email protected] ~]# dmidecode | grep -i "product name"

Product Name: VMware Virtual Platform

Product Name: 440BX Desktop Reference Platform

二、查看CPU型号

[[email protected] ~]# cat /proc/cpuinfo |grep "model name"

[[email protected] ~]# grep -i "model name" /proc/cpuinfo

model name      : Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz

cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep "physical id"

说明:Linux下可以在/proc/cpuinfo中看到每个cpu的详细信息。但是对于双核的cpu,在cpuinfo中会看到两个cpu。常常会让人误以为是两个单核的cpu。
其实应该通过Physical Processor ID来区分单核和双核。而Physical Processor ID可以从cpuinfo或者dmesg中找到. flags 如果有 ht 说明支持超线程技术 判断物理CPU的个数可以查看physical id 的值,相同则为

三、查看CPU信息

[[email protected] ~]# cat /proc/cpuinfo

processor       : 0

vendor_id       : GenuineIntel

cpu family      : 6

model           : 78

model name      : Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz

stepping        : 3

cpu MHz         : 2399.997

cache size      : 3072 KB

fpu             : yes

fpu_exception   : yes

cpuid level     : 22

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 pdpe1gb rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb xsaveopt pln pts dts fsgsbase smep

bogomips        : 4799.99

clflush size    : 64

cache_alignment : 64

address sizes   : 40 bits physical, 48 bits virtual

power management:

四、内存大小(总量)

[[email protected] ~]# cat /proc/meminfo |grep MemTotal

[[email protected]_TEST_201 ~]# grep -i "memtotal" /proc/meminfo

MemTotal:        1020296 kB

五、查看空闲内存

[[email protected] ~]# grep MemFree /proc/meminfo(不是全部的free mem)

MemFree:          218748 kB

[[email protected]_TEST_201 ~]# free |grep buffer|sed '1d'|awk '{print $4}'(这是实际的free mem)

628732

六、硬盘大小

[[email protected] ~]# fdisk -l |grep Disk

[[email protected]_TEST_201 ~]# fdisk -l|grep -i "disk"

Disk /dev/sda: 21.5 GB, 21474836480 bytes

Disk identifier: 0x000c15de

七、查看内核/操作系统信息的linux系统信息命令

[[email protected]_TEST_201 ~]# uname

Linux

[[email protected] ~]# uname -a

Linux ycl201 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

LSB(Linux Standards Base)

红帽企业级Linux 6(代号Santiago)

[[email protected] ~]# lsb_release -a

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch

Distributor ID: RedHatEnterpriseServer

Description:    Red Hat Enterprise Linux Server release 6.5 (Santiago)

Release:        6.5

Codename:       Santiago

[[email protected] ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.5 (Santiago)

八、Linux文件系统

suse的文件系统是XFS(XFS 特别擅长处理大文件,同时提供平滑的数据传输)

[[email protected] ~]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Wed Mar  1 04:27:19 2017

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=52e6ed3f-6bb8-42ef-94c0-92b3a79d528d /                       ext4    defaults        1 1

UUID=37ec7bb3-0219-4e18-854e-1659cfdb97c9 /boot                   ext4    defaults        1 2

UUID=150cb11d-ae64-4eae-a063-2c52c867fefa swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

九、操作系统版本

[[email protected] ~]# head -n 1 /etc/issue

Red Hat Enterprise Linux Server release 6.5 (Santiago)

[[email protected] ~]# cat /proc/version

Linux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Sun Nov 10 22:19:54 EST 2013

十、查看环境信息

[[email protected] ~]# env

HOSTNAME=ycl201

SHELL=/bin/bash

TERM=vt100

HISTSIZE=1000

QTDIR=/usr/lib64/qt-3.3

QTINC=/usr/lib64/qt-3.3/include

USER=root

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:

MAIL=/var/spool/mail/root

PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

PWD=/root

LANG=zh_CN.UTF-8

SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass

HISTCONTROL=ignoredups

SHLVL=1

HOME=/root

LOGNAME=root

QTLIB=/usr/lib64/qt-3.3/lib

CVS_RSH=ssh

LESSOPEN=|/usr/bin/lesspipe.sh %s

G_BROKEN_FILENAMES=1

_=/bin/env

十一、内存和swap的使用情况

[[email protected] ~]# free -m

total       used       free     shared    buffers     cached

Mem:           996        782        214          0         86        316

-/+ buffers/cache:        378        617

Swap:         2047          0       2047

十二、查看所有的swap区

[[email protected] ~]# swapon -s

Filename                                Type            Size    Used    Priority

/dev/sda2                               partition       2097144 0       -1

十三、查看各分区

[[email protected] ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000c15de

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          52      409600   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              52         313     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             313        2611    18463744   83  Linux

十四、查看各分区使用情况

[[email protected] ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.3G   12G  32% /

tmpfs           499M   32M  468M   7% /dev/shm

/dev/sda1       388M   35M  334M  10% /boot

十五、查看指定目录的大小

[[email protected] ~]# du -sh /opt/

306M    /opt/

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

[[email protected] ~]# uptime

22:23:43 up  2:53,  1 user,  load average: 0.07, 0.02, 0.00

十七、查看磁盘参数(仅用于IDE设备)

[[email protected] ~]# hdparm -i /dev/sda

/dev/sda:

Model=VMware Virtual IDE Hard Drive, FwRev=00000001, SerialNo=00000000000000000001

Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }

RawCHS=16383/15/63, TrkSize=0, SectSize=0, ECCbytes=0

BuffType=unknown, BuffSize=32kB, MaxMultSect=64, MultSect=16

CurCHS=17475/15/63, CurSects=16513875, LBA=yes, LBAsects=41943040

IORDY=on/off, tPIO={min:160,w/IORDY:120}, tDMA={min:120,rec:120}

PIO modes:  pio0 pio1 pio2 pio3 pio4

DMA modes:  mdma0 mdma1 mdma2

UDMA modes: udma0 udma1 *udma2

AdvancedPM=yes: disabled (255)

Drive conforms to: ATA/ATAPI-4 T13 1153D revision 17:  ATA/ATAPI-1,2,3,4

* signifies the current active mode

十八、查看所有的网络接口属性

[[email protected] ~]# ifconfig

eth1      Link encap:Ethernet  HWaddr 00:0C:29:70:CE:8F

inet addr:192.168.46.201  Bcast:192.168.46.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe70:ce8f/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:154408 errors:0 dropped:0 overruns:0 frame:0

TX packets:73298 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:118163696 (112.6 MiB)  TX bytes:7821839 (7.4 MiB)

Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback

inet addr:127.0.0.1  Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING  MTU:16436  Metric:1

RX packets:20696 errors:0 dropped:0 overruns:0 frame:0

TX packets:20696 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:2008135 (1.9 MiB)  TX bytes:2008135 (1.9 MiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:7A:33:B5

inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

十九、查看防火墙设置

[[email protected]_TEST_201 ~]# service iptables status

[[email protected] ~]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination

ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain

ACCEPT     udp  --  anywhere             anywhere            udp dpt:bootps

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:bootps

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination

ACCEPT     all  --  anywhere             192.168.122.0/24    state RELATED,ESTABLISHED

ACCEPT     all  --  192.168.122.0/24     anywhere

ACCEPT     all  --  anywhere             anywhere

REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable

REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

二十、查看路由表

[[email protected] ~]# route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.46.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth1

0.0.0.0         192.168.46.254  0.0.0.0         UG    0      0        0 eth1

二十一、查看所有的监听端口

[[email protected] ~]# netstat -lntp

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:6957                0.0.0.0:*                   LISTEN      4345/python

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1296/rpcbind

tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1875/dnsmasq

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1534/sshd

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1411/cupsd

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1614/master

tcp        0      0 0.0.0.0:5050                0.0.0.0:*                   LISTEN      4175/gbased

tcp        0      0 0.0.0.0:6268                0.0.0.0:*                   LISTEN      4298/gcrecover

tcp        0      0 127.0.0.1:2812              0.0.0.0:*                   LISTEN      1796/monit

tcp        0      0 0.0.0.0:35490               0.0.0.0:*                   LISTEN      1341/rpc.statd

tcp        0      0 0.0.0.0:5288                0.0.0.0:*                   LISTEN      4291/gc_sync_server

tcp        0      0 0.0.0.0:5258                0.0.0.0:*                   LISTEN      4216/gclusterd

tcp        0      0 :::111                      :::*                        LISTEN      1296/rpcbind

tcp        0      0 :::22                       :::*                        LISTEN      1534/sshd

tcp        0      0 ::1:631                     :::*                        LISTEN      1411/cupsd

tcp        0      0 ::1:25                      :::*                        LISTEN      1614/master

tcp        0      0 :::23773                    :::*                        LISTEN      1341/rpc.statd

二十二、查看网络统计信息进程

[[email protected] ~]# netstat -s

Ip:

174414 total packets received

0 forwarded

0 incoming packets discarded

174414 incoming packets delivered

99748 requests sent out

Icmp:

125 ICMP messages received

0 input ICMP message failed.

ICMP input histogram:

destination unreachable: 125

95 ICMP messages sent

0 ICMP messages failed

ICMP output histogram:

destination unreachable: 95查看sshd进程

[[email protected] ~]# ps -ef|grep sshd

root      1534     1  0 19:30 ?        00:00:00 /usr/sbin/sshd

root      2547  1534  0 19:33 ?        00:00:01 sshd: [email protected]/0

root      4075  1534  0 20:53 ?        00:00:03 sshd: [email protected]

root      5633  4549  0 22:36 pts/0    00:00:00 grep sshd

附录

top # 实时显示进程状态用户
w # 查看活动用户(who是w的缩写)
id # 查看指定用户信息
last # 查看用户登录日志
cut -d: -f1 /etc/passwd|sort|uniq # 查看系统所有用户
cut -d: -f1 /etc/group|sort|uniq # 查看系统所有组
crontab -l # 查看当前用户的计划任务服务
chkconfig –list # 列出所有系统服务
chkconfig –list | grep on # 列出所有启动的系统服务程序
rpm -qa # 查看所有安装的软件包
cat /proc/cpuinfo :查看CPU相关参数的linux系统命令
cat /proc/partitions :查看linux硬盘和分区信息的系统信息命令
cat /proc/meminfo :查看linux系统内存信息的linux系统命令
cat /proc/version :查看版本,类似uname -r
cat /proc/ioports :查看设备io端口
cat /proc/interrupts :查看中断
cat /proc/pci :查看pci设备的信息
cat /proc/swaps :查看所有swap分区的信息

原文地址:http://blog.51cto.com/12942223/2134014

时间: 2024-11-12 18:39:59

查看Linux系统的常见命令的相关文章

查看linux系统常用的命令,Linux查看系统配置常用命令

一.linux CPU大小  cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep "physical id" 说明:Linux下可以在/proc/cpuinfo中看到每个cpu的详细信息.但是对于双核的cpu,在cpuinfo中会看到两个cpu.常常会让人误以为是两个单核的cpu.其实应该通过Physical Processor ID来区分单核和双核.而Physical Pr

查看linux系统版本的命令

在我们在linux下安装软件的时候,相应的软件包会有对应的系统版本,在CRT或Xshell下,需查看其系统版本及内核版本是基本常用命令. (1) 查看内核版本及平台 uname -r -m3.2.0-24-generic x86_64 (2) 查看发行版版本lsb_release -a Distributor ID: UbuntuDescription: Ubuntu 12.04 LTSRelease: 12.04Codename: precise

安装Linux系统与常见命令(一)

安装Linux系统:重置root管理员密码 RPM软件包管理器:通过将安装规则与源代码打包到一起,降低软件安装难度. Yum软件仓库:通过将大量常用的RPM软件包存放到一起,解决软件包之间的依赖关系,进一步降低软件安装难度. systemd初始化进程:RHEL 7系统用systemd初始化代替原有system V init命令systemctl start 服务名称 ---启动服务systemctl stop 服务名称 ---停止服务systemctl restart 服务名称 ---重启服务s

查看Linux系统版本信息

一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [[email protected]CentOS home]# cat /proc/versionLinux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013 2.uname -a [

【转载】查看Linux系统版本

本文转自:http://www.linuxidc.com/Linux/2016-05/131749.htm 一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [[email protected]CentOS home]# cat /proc/versionLinux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (G

【LInux】查看Linux系统版本信息

一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [[email protected]CentOS home]# cat /proc/versionLinux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013 2.uname -a [

查看linux系统版本信息(Oracle Linux、Centos Linux、Redhat Linux、Debian、Ubuntu)

一.查看Linux系统版本的命令(3种方法) 1.cat /etc/issue,此命令也适用于所有的Linux发行版. [[email protected] home]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m 2.cat /etc/redhat-release,这种方法只适合Redhat系的Linux: [[email protected] home]# cat /etc/redhat-release CentO

查看Linux系统版本信息的几种方法

一.查看Linux内核版本命令(两种方法): 1.cat /proc/version 2.uname -a 二.查看Linux系统版本的命令(3种方法): 1.lsb_release -a,即可列出所有版本信息: 这个命令适用于所有的Linux发行版,包括RedHat.SUSE.Debian…等发行版. 2.cat /etc/redhat-release,这种方法只适合Redhat系的Linux: [[email protected] home]# cat /etc/redhat-release

【linux】查看Linux系统版本信息的几种方法

一.查看Linux内核版本命令(两种方法): 1.cat /proc/version 2.uname -a 二.查看Linux系统版本的命令(3种方法): 1.lsb_release -a,即可列出所有版本信息: 这个命令适用于所有的Linux发行版,包括RedHat.SUSE.Debian…等发行版. 2.cat /etc/redhat-release,这种方法只适合Redhat系的Linux: [[email protected] home]# cat /etc/redhat-release