Raspberry Pi – Creating a custom login banner

When I started working with Raspian, I tried to figure out a “good” way to document what was on each SD card that I was using. My first instinct was to use a labeling machine. My concern with that option was that even the minimal bulk of the label might present a problem when inserting the SD card into the RPi slot. Remote but still something to be concerned about. Replacing the label was even more problematic. I started looking for a simpler way that could be changed on demand without having to change labels and possible damage to the SD card itself at some point. When I thought about using the microSD cards in the RPi, the challenge became even more interesting.

After doing a little digging I found about something called a bash_profile. It is a text profile that goes in the home directory of the login id that you are using. If you use more than one id, you would need to place the file in each home directory for the login id that you want to have this file. There may be more than one way to do this but this is what I have found at this point.

You create the file by using the following command – sudo nano /home/pi/.bash_profile. The # command acts like a REM statement and helps you document something that won’t be displayed at login. Here is the file that I started with –

# My first attempt at a banner
echo ”
*************************************
* Configuration: Base Raspian Boot *
*************************************

Everything after echo ” until the next ” is displayed on the screen. The echo command does exactly what it implies, it echo’s everything to the screen. You will find other examples of what you can do by displaying your private and public ip addresses, how many processes are running, etc. What you can do is limited only by your imagination. You can test your changes by either doing a sudo login. You have to use sudo in front of the login command unless you use the logout command. You can also do a cat .bash_profile but you will just see the text file displayed but not what you would see by actually logging in.

To see more of my posts about the Raspberry Pi, please go to http://www.ronnutter.com/category/raspberry-pi/

Send to Kindle
This entry was posted in Blog Entries, Raspberry Pi and tagged . Bookmark the permalink.