Closed7

【Linux/WSL】動作環境取得

arikaarika

調べてもサクッと出てこなかったので。
長々とした出力にならないものを選んでいます。

arikaarika

OS

kernelを知りたい場合

uname -sro
Linux 5.4.72-microsoft-standard-WSL2 GNU/Linux

distrobutionを知りたい場合

awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release  | sed 's/"//g'
Ubuntu 20.04.2 LTS
arikaarika

CPU

lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1'
Intel(R) Core(TM) i7-9700KF CPU @ 3.60GHz
arikaarika

GPU

NVIDIAの場合

nvidia-smi --query-gpu=name --format=csv | awk '$1!="name" {print $0}'
NVIDIA GeForce GTX 1660 SUPER
arikaarika

Memory

awk '{ printf "Memory: %.2f MiB\n", $2/1024 ; exit}' /proc/meminfo
Memory: 7916.95 MiB

dmidecodeを使うのが一般的だが、WSLでは使えないのでパス。

arikaarika

全部知りたいとき

インストールが必要になるがinxiがいい感じ。

sudo apt install inxi
inxi -F
System:    Host: **** Kernel: 5.4.72-microsoft-standard-WSL2 x86_64 bits: 64 Console: tty 8 
           Distro: Ubuntu 20.04.2 LTS (Focal Fossa) 
Machine:   Message: No machine data: try newer kernel. Is dmidecode installed? Try -M 
           --dmidecode. 
CPU:       Topology: 8-Core model: Intel Core i7-9700KF bits: 64 type: MCP 
           L2 cache: 12.0 MiB 
           Speed: 3600 MHz min/max: N/A Core speeds (MHz): 1: 3600 2: 3600 3: 3600 4: 3600 
           5: 3600 6: 3600 7: 3600 8: 3600 
Graphics:  Device-1: Microsoft driver: N/A 
           Display: server: No display server data found. Headless machine? tty: 96x17 
           Message: Advanced graphics data unavailable in console. Try -G --display 
Audio:     Message: No Device data found. 
Network:   Message: No Device data found. 
           IF-ID-1: bond0 state: down mac: b2:a9:80:45:59:95 
           IF-ID-2: bonding_masters state: N/A speed: N/A duplex: N/A mac: N/A 
           IF-ID-3: dummy0 state: down mac: 62:c0:d9:c6:5b:44 
           IF-ID-4: eth0 state: up speed: 10000 Mbps duplex: full mac: 00:15:5d:de:93:fa 
           IF-ID-5: sit0 state: down mac: 00:00:00:00 
Drives:    Local Storage: total: 1024.00 GiB used: 348.97 GiB (34.1%) 
           ID-1: /dev/sda model: Virtual Disk size: 256.00 GiB 
           ID-2: /dev/sdb model: Virtual Disk size: 256.00 GiB 
           ID-3: /dev/sdc model: Virtual Disk size: 256.00 GiB 
           ID-4: /dev/sdd model: Virtual Disk size: 256.00 GiB 
Partition: ID-1: / size: 250.98 GiB used: 15.87 GiB (6.3%) fs: ext4 dev: /dev/sdd 
Sensors:   Message: No sensors data was found. Is sensors configured? 
Info:      Processes: 43 Uptime: 6d 9h 37m Memory: 7.73 GiB used: 850.5 MiB (10.7%) 
           Init: N/A Shell: bash inxi: 3.0.38
arikaarika

おまけ

inxiではお天気情報がなぜか見れる。

inxi -w
Weather:   Temperature: 8.9 C (48 F) Conditions: Drizzle 
           Current Time: Wed Mar 23 19:45:26 2022 (Asia/Tokyo) Source: WeatherBit.io
このスクラップは2022/03/23にクローズされました