0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Raspberry PIのコンソール接続し、ローカルIP及びSD情報表示

Last updated at Posted at 2020-06-21

#概要
RaspberryPIでSSHターミナルを起動した際に現在DHCPから配布されているIPアドレスを表示します。
そしてSDカードの容量も表示します。

#修正ファイル 「.bashrc」
下記のコマンドでファイルを修正します。
VIを使っていますが、他の編集ツールでも大丈夫です。

vi ~/.bashrc

上記のファイルに以下の内容を追記し、保存します。

echo "==IP Address=="
ip addr | grep "inet " | grep brd | awk '{print $2}' | awk -F/ '{print $1}'
echo ""
echo "==Disk Space=="
df -h

#SSHターミナルを起動
ターミナルを起動すると以下の画面のように表示されます。

Linux raspberrypi 4.19.118-v7l+ #1311 SMP Mon Apr 27 14:26:42 BST 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Jun 21 08:19:14 2020 from 192.168.1.2

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

==IP Address==
192.168.1.13

==Disk Space==
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  5.8G  7.9G  43% /
devtmpfs        841M     0  841M   0% /dev
tmpfs           970M     0  970M   0% /dev/shm
tmpfs           970M  8.6M  962M   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           970M     0  970M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   51M  202M  21% /boot

tmpfs           194M     0  194M   0% /run/user/1000

#その他
グローバルのIPも表示したい場合は、下記のコマンドを利用してください。

pi@raspberrypi:~ $ curl globalip.me
219.107.XXX.XXX

#終わりに
今日はSSHで接続した場合、「.bashrc」が実行される内容にコマンドを追記してみました。
何より現在使っているディスクの容量が確認できてよかったと思います。
皆さんも表示したい情報がありましたらこのファイルに追記してみてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?