centOS7下實踐查詢版本/CPU/內存/硬盤容量等硬件信息

1.系統

  1.1版本

  uname -a 能確認是64位仍是32位,其它的信息很少php

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

  more /etc/*release 能夠看到更多信息html

[root@localhost ~]# more /etc/*release
::::::::::::::
/etc/centos-release
::::::::::::::
CentOS Linux release 7.2.1511 (Core) 
::::::::::::::
/etc/os-release
::::::::::::::
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

::::::::::::::
/etc/redhat-release
::::::::::::::
CentOS Linux release 7.2.1511 (Core) 
::::::::::::::
/etc/system-release
::::::::::::::
CentOS Linux release 7.2.1511 (Core)

 

  1.2核數

    cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

     

[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      1  Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz

1個邏輯CPU,i5型等信息mysql

 

[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      8  Intel(R) Xeon(R) CPU E7-4820 v2 @ 2.00GHz

8個邏輯CPUlinux

  cat /proc/cpuinfo | grep physical | uniq -c

 

[root@localhost ~]# cat /proc/cpuinfo | grep physical | uniq -c
      1 physical id     : 0
      1 address sizes   : 42 bits physical, 48 bits virtual

其實是一顆一核的CPUnginx

 

[root@localhost ~]# cat /proc/cpuinfo | grep physical | uniq -c
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual
      1 physical id     : 0
      1 address sizes   : 40 bits physical, 48 bits virtual

由8個1核的CPU組成8核sql

  cat /proc/cpuinfo能夠看到更爲詳細的信息

 

[root@localhost ~]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 94
model name      : Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz
stepping        : 3
microcode       : 0x74
cpu MHz         : 2304.004
cache size      : 6144 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
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 arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt xsavec xgetbv1 xsaves
bogomips        : 4608.00
clflush size    : 64
cache_alignment : 64
address sizes   : 42 bits physical, 48 bits virtual
power management:

1.3運行模式

getconf LONG_BIT  CPU運行在多少位模式下docker

 

[root@localhost ~]# getconf LONG_BIT
64

若是是32,說明當前CPU運行在32bit模式下, 但不表明CPU不支持64bitshell

cat /proc/cpuinfo | grep flags | grep ‘ lm ‘ | wc -l 是否支持64位

 

[root@localhost ~]# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
1

結果大於0, 說明支持64bit計算. lm指long mode, 支持lm則是64bitvim

1.4計算機名

  hostname

 

[root@localhost ~]# hostname
localhost.localdomain

1.5.查看環境變量

  env

 

[root@localhost ~]# env
XDG_SESSION_ID=4
HOSTNAME=localhost.localdomain
SELINUX_ROLE_REQUESTED=
TERM=vt100
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=192.168.174.1 58896 22
SELINUX_USE_CURRENT_RANGE=
SSH_TTY=/dev/pts/0
USER=root

1.6系統容許多長時間了/負載數

uptime

 

[root@localhost proc]# uptime
 10:55:01 up  1:28,  2 users,  load average: 0.00, 0.01, 0.05

1.當前時間10:55:01centos

2.系統運行了多少時間,1:28(1小時28分)
3.多少個用戶,2 users
4.平均負載:0.00, 0.01, 0.05,最近1分鐘、5分鐘、15分鐘系統的負載

直接查看平均負載狀況 cat /proc/loadavg

 

[root@localhost proc]# cat /proc/loadavg
0.00 0.01 0.05 4/524 7152

除了前3個數字表示平均進程數量外,後面的1個分數,分母表示系統進程總數,分子表示正在運行的進程數;最後一個數字表示最近運行的進程ID

2.資源

  2.1內存

   cat /proc/meminfo內存的詳細信息

 

[root@localhost proc]# cat /proc/meminfo
MemTotal:        1001332 kB
MemFree:           99592 kB
MemAvailable:     420940 kB
Buffers:            1064 kB
Cached:           405292 kB
SwapCached:            0 kB
Active:           412548 kB
Inactive:         250192 kB
Active(anon):     205264 kB
Inactive(anon):    58460 kB
Active(file):     207284 kB
Inactive(file):   191732 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2097148 kB
SwapFree:        2097140 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        256416 kB
Mapped:           103344 kB
Shmem:              7340 kB
Slab:             126408 kB
SReclaimable:      69912 kB
SUnreclaim:        56496 kB
KernelStack:       10416 kB
PageTables:        15520 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2597812 kB
Committed_AS:    1578872 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      170756 kB
VmallocChunk:   34359564288 kB
HardwareCorrupted:     0 kB
AnonHugePages:     75776 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       73600 kB
DirectMap2M:      974848 kB
DirectMap1G:           0 kB

MemTotal總內存,MemFree可用內存
free -m(-m,單位是m,若是是-g,單位是g)查看可用內存

 

[root@localhost proc]# free -m
              total        used        free      shared  buff/cache   available
Mem:            977         360          97           7         520         411
Swap:          2047           0        2047

空閒內存total-used=free+buff/cache

咱們經過free命令查看機器空閒內存時,會發現free的值很小。這主要是由於,在linux中有這麼一種思想,內存不用白不用,所以它儘量的cache和buffer一些數據,以方便下次使用。但實際上這些內存也是能夠馬上拿來使用的。

 

 

3.磁盤和分區

  3.1查看各分區使用狀況

df -h

 

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   45G   22G   24G  48% /
devtmpfs                 906M     0  906M   0% /dev
tmpfs                    921M   96K  921M   1% /dev/shm
tmpfs                    921M 1004K  920M   1% /run
tmpfs                    921M     0  921M   0% /sys/fs/cgroup
/dev/sda1                497M  195M  303M  40% /boot
tmpfs                    185M     0  185M   0% /run/user/1001
tmpfs                    185M     0  185M   0% /run/user/0
[root@localhost ~]#

  3.2查看指定目錄的大小

   du -sh <目錄名>

 

[root@localhost ~]# du -sh /root
1.2G    /root

3.3查看全部分區

fdisk -l

 

[root@localhost proc]# fdisk -l

磁盤 /dev/sda:32.2 GB, 32212254720 字節,62914560 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標籤類型:dos
磁盤標識符:0x000a0cd4

   設備 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

磁盤 /dev/mapper/centos-root:29.5 GB, 29490151424 字節,57597952 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節


磁盤 /dev/mapper/centos-swap:2147 MB, 2147483648 字節,4194304 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節


磁盤 /dev/mapper/centos-docker--poolmeta:33 MB, 33554432 字節,65536 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節


磁盤 /dev/mapper/docker-253:0-101330881-pool:107.4 GB, 107374182400 字節,209715200 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):65536 字節 / 65536 字節

3.4查看全部交換分區

swapon -s

 

[root@localhost proc]# swapon -s
文件名                          類型            大小    已用    權限
/dev/dm-1                       partition       2097148 8       -1

4.網絡

  4.1查看全部網絡接口的屬性

  ifconfig

 

[root@localhost proc]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        ether 02:42:e1:b8:a5:4f  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.174.129  netmask 255.255.255.0  broadcast 192.168.174.255
        inet6 fe80::20c:29ff:fe50:b3b4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:50:b3:b4  txqueuelen 1000  (Ethernet)
        RX packets 28649  bytes 38411280 (36.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8937  bytes 1226914 (1.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 4  bytes 340 (340.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 340 (340.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 00:00:00:00:00:00  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 4.2 帶寬

ethtool 網卡名

[root@localhost php-tomcat-base]# ethtool ens192
Settings for ens192:
        Supported ports: [ TP ]
        Supported link modes:   1000baseT/Full 
                                10000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 10000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        MDI-X: Unknown
        Supports Wake-on: uag
        Wake-on: d
        Link detected: yes

看Speed

4.3查看路由表

  route -n

 

[root@localhost proc]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.174.2   0.0.0.0         UG    100    0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.174.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
[root@localhost proc]#

 4.4查看全部監聽端口

netstat -lntp

[root@localhost ~]# 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:111             0.0.0.0:*               LISTEN      743/rpcbind         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1740/nginx: master  
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      1740/nginx: master  
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2194/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1543/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      12610/cupsd         
tcp        0      0 0.0.0.0:40536           0.0.0.0:*               LISTEN      19964/rpc.statd     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2133/master         
tcp6       0      0 :::111                  :::*                    LISTEN      743/rpcbind         
tcp6       0      0 :::81                   :::*                    LISTEN      1740/nginx: master  
tcp6       0      0 :::22                   :::*                    LISTEN      1543/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      12610/cupsd         
tcp6       0      0 ::1:25                  :::*                    LISTEN      2133/master         
tcp6       0      0 :::35420                :::*                    LISTEN      19964/rpc.statd     
[root@localhost ~]#

4.5查看全部已經創建的鏈接

netstat -antp

 

[root@localhost ~]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      743/rpcbind         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1740/nginx: master  
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      1740/nginx: master  
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2194/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1543/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      12610/cupsd         
tcp        0      0 0.0.0.0:40536           0.0.0.0:*               LISTEN      19964/rpc.statd     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2133/master         
tcp        0      0 172.31.4.233:22         121.34.147.13:57190     ESTABLISHED 29540/sshd: cavan [ 
tcp        0      0 172.31.4.233:22         121.34.147.13:54544     ESTABLISHED 27077/sshd: cavan [ 
tcp        0     96 172.31.4.233:22         219.137.32.66:60645     ESTABLISHED 30315/sshd: root@pt 
tcp        0      0 172.31.4.233:22         121.34.147.13:56319     ESTABLISHED 28703/sshd: cavan [ 
tcp6       0      0 :::111                  :::*                    LISTEN      743/rpcbind         
tcp6       0      0 :::81                   :::*                    LISTEN      1740/nginx: master  
tcp6       0      0 :::22                   :::*                    LISTEN      1543/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      12610/cupsd         
tcp6       0      0 ::1:25                  :::*                    LISTEN      2133/master         
tcp6       0      0 :::35420                :::*                    LISTEN      19964/rpc.statd     
[root@localhost ~]# 

4.6 某端口使用狀況

lsof -i:端口號

[root@localhost mysql]# lsof -i:22
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd    1150 root    3u  IPv4  18264      0t0  TCP *:ssh (LISTEN)
sshd    1150 root    4u  IPv6  18273      0t0  TCP *:ssh (LISTEN)
sshd    2617 root    3u  IPv4  20437      0t0  TCP localhost.localdomain:ssh->192.168.174.1:60426 (ESTABLISHED)
[root@localhost mysql]#

或者

netstat -apn|grep 端口號

[root@localhost mysql]# netstat -apn|grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1150/sshd           
tcp        0     96 192.168.174.136:22      192.168.174.1:60426     ESTABLISHED 2617/sshd: root@pts 
tcp6       0      0 :::22                   :::*                    LISTEN      1150/sshd

 

5.進程

  5.1查看全部進程

  ps -ef,使用ps -ef|gerp tomcat過濾

 

[root@localhost ~]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 09:26 ?        00:00:03 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root          2      0  0 09:26 ?        00:00:00 [kthreadd]
root          3      2  0 09:26 ?        00:00:00 [ksoftirqd/0]
root          6      2  0 09:26 ?        00:00:00 [kworker/u256:0]
root          7      2  0 09:26 ?        00:00:00 [migration/0]
root          8      2  0 09:26 ?        00:00:00 [rcu_bh]
root          9      2  0 09:26 ?        00:00:00 [rcuob/0]
root         10      2  0 09:26 ?        00:00:00 [rcuob/1]
root         11      2  0 09:26 ?        00:00:00 [rcuob/2]
root         12      2  0 09:26 ?        00:00:00 [rcuob/3]
root         13      2  0 09:26 ?        00:00:00 [rcuob/4]
root         14      2  0 09:26 ?        00:00:00 [rcuob/5]
root         15      2  0 09:26 ?        00:00:00 [rcuob/6]
root         16      2

ps -aux能夠看到進程佔用CPU,內存狀況

 

[root@localhost ~]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.6 126124  6792 ?        Ss   09:26   0:03 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root          2  0.0  0.0      0     0 ?        S    09:26   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        S    09:26   0:00 [ksoftirqd/0]
root          6  0.0  0.0      0     0 ?        S    09:26   0:00 [kworker/u256:0]
root          7  0.0  0.0      0     0 ?        S    09:26   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    09:26   0:00 [rcu_bh]
root          9  0.0  0.0      0     0 ?        S    09:26   0:00 [rcuob/0]
root         10  0.

5.2實時顯示進程狀態

  top

 

[root@localhost ~]# top
top - 11:29:02 up  2:02,  2 users,  load average: 0.12, 0.04, 0.05
Tasks: 408 total,   2 running, 406 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.3 us,  0.3 sy,  0.0 ni, 98.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1001332 total,    92184 free,   370332 used,   538816 buff/cache
KiB Swap:  2097148 total,  2097140 free,        8 used.   419124 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                              
  3001 gdm       20   0 1419364 122996  45860 S  1.0 12.3   0:06.50 gnome-shell                                                                                                          
   276 root      20   0       0      0      0 S  0.3  0.0   0:09.72 kworker/0:1                                                                                                          
  3765 root      20   0  142864   5128   3876 S  0.3  0.5   0:00.77 sshd                                                                                                                 
  7740 root      20   0  146452   2384   1432 R  0.3  0.2   0:00.17 top                                                                                                                  
     1 root      20   0  126124   6792   3912 S  0.0  0.7   0:03.58 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.37 ksoftirqd/0                                                                                                          
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.39 kworker/u256:0                                                                                                       
     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                                                                                                              
    11 root      20   0       0

 

6.用戶

  6.1查看活動用戶

   w

 

[root@localhost ~]# w
 11:32:36 up 72 days, 20:50,  3 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
cavan    pts/0    121.34.147.13    09:47    1:14m  0.17s  0.17s sshd: cavan [priv]  
root     pts/1    219.137.32.66    11:19    4.00s  0.05s  0.00s w
cavan    pts/3    121.34.147.13    10:14   20:44   0.38s  0.11s vim Dockerfile
[root@localhost ~]#

6.2查看指定用戶的信息

id <用戶名>

[root@localhost ~]# id root
uid=0(root) gid=0(root) groups=0(root)
[root@localhost ~]# id cavan
uid=1001(cavan) gid=1001(cavan) groups=1001(cavan)
[root@localhost ~]#

 

6.3查看用戶登陸日誌

last

 

[root@localhost 1]# last
root     pts/0        192.168.174.1    Mon Oct 24 09:51   still logged in   
(unknown :0           :0               Mon Oct 24 09:27   still logged in   
reboot   system boot  3.10.0-327.el7.x Mon Oct 24 09:26 - 11:35  (02:09)    
root     pts/0        192.168.174.1    Fri Oct 21 09:41 - 18:44  (09:03)    
(unknown :0           :0               Fri Oct 21 09:15 - 18:44  (09:28)    
reboot   system boot  3.10.0-327.el7.x Fri Oct 21 09:15 - 11:35 (3+02:20)   
root     pts/1        192.168.174.1    Thu Oct 20 10:05 - 18:13  (08:08)    
root     pts/0

6.4查看系統全部用戶

cut -d: -f1 /etc/passwd

[root@localhost ~]# cut -d: -f1 /etc/passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
dbus
polkitd
abrt
unbound
colord
usbmuxd
ntp
相關文章
相關標籤/搜索