メモリ容量を確認するコマンド

ssh で Raspberry にログインしていて、「こいつメモリいくつあったっけ? 空き領域いくら?」ってときに。

free

コマンド

free コマンドで確認可能。

nekoha@raspberrypi:~$ free  

       total   used    free  shared  buff/cache  available  
Mem:  948304  52248  110112   12176      785944     818392  
Swap: 102396    256  102140  

でもオプションなしだと単位がないので、ぱっと見どのくらいあるのかわからない。

オプション

オプション 意味
-k, --kilo キビバイト表記
-m, --mega メビバイト表記
-h, --human 自動単位補正
--si SI 単位

他、テラとかペタとかラズパイには縁のない単位でも可能。
--tera とか設定すると、切り捨てなので 0 になっちゃう。

表示結果

-k オプションでキビバイト単位表示

nekoha@raspberrypi:~$ free -k  

        total   used    free  shared  buff/cache  available  
Mem:   948304  50752  113820   12204      783732     819896  
Swap:  102396      0  102396  

-h オプションで、単位を自動調整して表示。メビバイト単位で表示された。

nekoha@raspberrypi:~$ free -h  

      total  used   free  shared  buff/cache  available  
Mem:  926Mi  49Mi  111Mi    11Mi       765Mi      801Mi  
Swap:  99Mi    0B   99Mi  

ってなわけで、手元のラズパイの RAM は 1GB ってことがわかりました。

メビバイト?キビバイト?

ちなみにメビバイトとかキビバイトっていうのはメガバイトやキロバイトの間違いではないからな!

1KiB = 210 = 1024Bytes
1MiB = 220 = 1,048,576Bytes

wiki pedia: メビバイト

Subscribe to 猫好きが猫以外のことも書く

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe