[Tutorial] Editing DitePi Terminal Banner


Some notes on editing or removing the banner / motd that appears when you login over ssh. There are two main files to edit to change the banner’s behavior.

  • /DietPi/dietpi/func/dietpi-banner : Script for displaying the banner
  • /DietPi/dietpi/login : Script Called on login, calls dietpi-banner

Removing Banner

In the login file find the entry for the type of login you want to change the banner for in the Main Loop of the script. The one I changed was Normal Login.

    #Normal Login
    if (( $G_DIETPI_INSTALL_STAGE == 1 )); then

            /DietPi/dietpi/func/dietpi-banner 1

            (( $AUTO_START_INDEX > 0 )) && Run_AutoStart


To remove the menu completely just make the line that calls the banner script a comment.

#/DietPi/dietpi/func/dietpi-banner 1

To remove only the credits, you can change the banner script argument to 0. Using 0 as the argument will not clear the screen before printing meaning it is useful if you just want to append the dietpi banner to your own message of the day through /etc/update-motd.d

/DietPi/dietpi/func/dietpi-banner 0

If you would like to clear the system MOTD when using the 0 banner argument you have to edit the banner script’s Banner_Dietpi function, see “Editing Banner” for more instructions on editing the banner file directly.

       if (( $INPUT == 1 )); then  #"if(( $INPUT < 1)); then" will clear the MOTD when argument is 0
               printf '\ec' # clear current terminal screen

Editing Banner

The banner actually is a nice base if you add don’t want to make a motd script from scratch. The following is an example to display the $SHELL environment variable in the banner. If you would like to edit the DietPi banner first follow the instructions for removing it and then make a copy of dietpi-banner in /etc/update-motd.d or replace /etc/motd if you do not want the default motd to be shown with it. This will allow your changes to persist through an update but you might have to remove the default banner again after an update. The copy can be made with the following commands

sudo cp /DietPi/dietpi/func/dietpi-banner /etc/update-motd.d/


sudo mv /etc/motd /etc/motd.old && sudo cp /DietPi/dietpi/func/dietpi-banner /etc/motd

Create a function in dietpi-banner to echo out the information you want to display, I used a copy of the Hardware_Model_Print function and appended it to the Globals section.


                echo -e " \e[1m"Shell Path"\e[0m \e[90m| $SHELL\e[0m\n \e[38;5;154m────────────────────────────────────────────────\e[0m"
# Banner Print

In order to add your message to the banner edit the Banner_Dietpi function in the Banner Print section to include your function, this is also where you can remove any unwanted banner sections by commenting out or deleting their print function.

                ... # Terminal Clearing Code
                echo -e " \e[38;5;154m────────────────────────────────────────────────\e[0m\n \e[1mDietPi\e[0m $TEXT_TOP\n \e[38;5;154m────────────────────────────────────────────────\e[0m"

This should allow you to add any entry you need to the banner, the rest of the dietpi-banner script is also a good example however hopefully this gave you an idea where to start.

Great tutorial :smiley:.
Note that on update, the script(s) will be overwritten, so take care to backup (the essential custom parts). On update we might improve some methods the banner uses or changed global variables/functions, so restoring the whole script might break things. So you would need to restore the custom entries only.

Perhaps we can by times add a customization GUI that allows to add/remove columns/lines of the banner and fill the cells with custom and predefined entries.

The dietpi-* command hints could be turned into optional. Makes sense, since users will know them after using 1-2 times and can easily recheck via dietpi- :wink:.

Personally I would keep the credits fixed, simply fair for the contributors/tions :roll_eyes:.

Thanks for the feedback, I changed the “Editing Banner” section a little to hopefully work around the update issue.

This would be interesting, what would be the most DietPi like way to do this? add an option to the dietpi-config command? or something entirely seperate? Hopefully a solution like this would allow configurations to persist through updates as well.

Maybe if someone wanted a small ASCII art on startup that represents the logo.

Finally an issue is opened for this request on GitHub: https://github.com/MichaIng/DietPi/issues/2627

Just noticed that these files are now in /boot/dietpi, not /DietPi/dietpi. The login code has also changed, so this document is not that helpful now. Is there a more recent version of this documentation I am missing?

adjusting the DietPi scripts is not a good idea as they will be overwritten on each dietpi-update. In general the whole source code is available on GitHub.

You can now run dietpi-banner from the console to open the configuration menu.

I have this line in the custom entry, called “Reboot”:

[ -f /var/run/reboot-required ] && echo -e '\033[0;31m' "*** System restart required ***" || echo "No reboot required"

It checks if /var/run/reboot-required exists, and if yes it will tell you a system restart is required in red text when you ssh in.

Use /run/reboot-required, /var/run is deprecated and a symlink to /run only :wink:. But otherwise a good idea when using some triggers which create that flag.

Thanks, have updated it:

[[ -f '/run/reboot-required' ]] && { echo -e '\e[0;31m*** System restart required ***\e[0m'; cat /run/reboot-required.pkgs; :; } || echo 'No reboot required'

Edit: updated with MichaIng’s code

[[ -f '/run/reboot-required' ]] && { echo -e '\e[0;31m*** System restart required ***\e[0m'; cat /run/reboot-required.pkgs; :; } || echo 'No reboot required'

The dummy command : and that the commands in the braces are separated by ; to execute even when the previous one failed for some reason, assure that “No reboot required” is really only printed when the flag file is not present.