Displays the IP address currently distributed by DHCP when the SSH terminal is started with Raspberry PI. And the capacity of the SD card is also displayed.
Modify the file with the following command. I'm using VI, but other editing tools are fine.
vi ~/.bashrc
Add the following contents to the above file and save it.
echo "==IP Address=="
ip addr | grep "inet " | grep brd | awk '{print $2}' | awk -F/ '{print $1}'
echo ""
echo "==Disk Space=="
df -h
When you start the terminal, it will be displayed as shown in the screen below.
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
If you also want to display the global IP, use the command below.
pi@raspberrypi:~ $ curl globalip.me
219.107.XXX.XXX
Today I added a command to the content where ".bashrc" is executed when connecting with SSH. Above all, I'm glad I was able to confirm the capacity of the disk I'm currently using. If you have any information you would like to see, please add it to this file.
Recommended Posts