0%

linux infomation

linux 資訊

有時登入一個 linux 系統,我們不知道系統的環境。
透過探查系統資訊,就可以了解目前所在 linux 的資訊。

下面就是我們可能想知道的資訊

  • linux 的版本
  • kernel 資訊
  • 開機時間
  • 記憶體資訊
  • CPU 資訊
  • 磁碟資訊
  • 登入資訊
  • 執行的程序
  • 電腦名稱
  • 時間
  • ip
  • 系統負載

版本

1
2
3
4
5
6
7
 $ cat /etc/os-release 
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.12.0
PRETTY_NAME="Alpine Linux v3.12"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

kernel

1
2
 $ uname -a
Linux 8f05004d4f82 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 Linux

開機時間

1
2
$ uptime
01:24:34 up 29 days, 21:23, load average: 1.23, 1.80, 1.62

記憶體

1
2
3
4
 $ free -m
total used free shared buff/cache available
Mem: 64105 32898 17445 0 13761 30548
Swap: 65535 47559 17976

CPU

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 $ cat /proc/cpuinfo 
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
stepping : 13
microcode : 0xb8
cpu MHz : 3392.138
cache size : 16384 KB
physical id : 0
siblings : 16
core id : 0
cpu cores : 8
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 acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips : 7200.00
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

磁碟資訊

1
2
3
4
5
6
 $ df -h
Filesystem Size Used Available Use% Mounted on
overlay 299.9G 115.2G 184.7G 38% /
tmpfs 64.0M 0 64.0M 0% /dev
tmpfs 31.3G 0 31.3G 0% /sys/fs/cgroup
shm 64.0M 0 64.0M 0% /dev/shm

登入資訊

1
2
3
4
5
6
 $ last 
oo ttys006 Wed Oct 7 06:52 still logged in
oo ttys005 Wed Oct 7 06:52 still logged in
oo ttys004 Wed Oct 7 06:52 still logged in
oo console Wed Oct 7 06:51 still logged in
reboot ~ Wed Oct 7 06:48

執行的程序

1
2
3
4
5
6
$ ps
PID TTY TIME CMD
621 ttys004 0:02.81 -zsh
625 ttys004 0:00.01 -zsh
737 ttys004 0:00.00 -zsh
739 ttys004 0:00.30 -zsh

電腦名稱

1
$ hostname

時間

1
2
 $ date
Thu Oct 8 09:32:37 CST 2020

ip

1
2
3
4
5
6
7
8
9
 $ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=400<CHANNEL_IO>
ether ac:bc:32:78:4d:93
inet6 fe80::75:35e4:b6a8:f8be%en0 prefixlen 64 secured scopeid 0x4
inet 192.168.16.151 netmask 0xfffffc00 broadcast 192.168.19.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active

系統負載

1
2
3
4
5
6
7
 $ top
Mem: 64636232K used, 1007532K free, 1460980K shrd, 48K buff, 15812704K cached
CPU: 19% usr 6% sys 0% nic 74% idle 0% io 0% irq 0% sirq
Load average: 3.39 2.32 1.88 5/13612 6937
PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
42 0 root S 67284 0% 3 0% {jupyter-lab} /usr/bin/python3 /usr/bin/jupyter-lab --NotebookApp.password=sha1:3de3565ce2b7:dbc6f2d59e5ff
9353fc8