[RPi] 開機後顯示 IP 位置
2021-05-25
最近在玩 Raspberry Pi ,因為我裝了一個 3.5" LCD ,我設定開機後是直接進入 console 而不是進入視窗介面的,但是我遇到一個麻煩,我需要 開啟登入後出現 我的 IP 資訊,但是我網路上找了個遍..
試了幾種方法才成功..
1. 首先 我針對 /etc/rc.local 下手,但是我發現裡面竟然已經有寫了顯示 IP 的指令碼,但是卻沒有顯示,就算了我補了 ifconfig 也沒有用
2. 所以之後經過幾番查詢,最後我是對 ~./bashrc 下手
輸入指令碼
sudo nano ~/.bashrc
之後在結尾加入這一段
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show IP information | |
_IP=$(hostname -I) || true | |
if [ "$_IP" ]; then | |
printf "My IP address is %s\n" "$_IP" | |
fi | |
這樣就可以了,筆記一下..
reference:
https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/
標籤: IoT , Raspberry Pi , RPi
--
Yesterday I wrote down the code. I bet I could be your hero. I am a mighty little programmer.
如果這篇文章有幫助到您,簡單留個言,或是幫我按個讚,讓我有寫下去的動力...