My grub doesn't have "quiet splash" so it displays text while booting, and I want to run "neofetch -L" just before it displays "Welcome to Ubuntu 20.04 LTS"
2 Answers
You can add a custom service to run your script at boot by following the steps below.
Firstly, run the following command in the terminal to create and edit a shell script file in your home directory:
nano ~/MyScript.sh
Secondly, copy and paste the following code into the editor, ( neofetch -L
is just an example ) and save it by pressing Ctrl + X then press Y then press Enter :
#!/bin/bash
neofetch -L
Thirdly, make the shell script file executable by running the following command in the terminal:
chmod +x ~/MyScript.sh
Fourthly, create and edit a custom systemd service to run the shell script at boot by running the following command in the terminal:
sudo nano /etc/systemd/system/MyCustomService.service
Fifthly, copy and paste the following code into the editor, replace USERNAME
with your username and save it by pressing Ctrl + X then press Y then press Enter :
[Unit]
Description=My Custom Service
Before=motd-news.service
[Service]
Type=oneshot
ExecStart=/home/USERNAME/MyScript.sh
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
Sixthly, start the service by running the following command in the terminal:
sudo systemctl start MyCustomService
Seventhly, enable the service by running the following command in the terminal:
sudo systemctl enable MyCustomService
Finally, reboot your system.
If for any reason you want to undo this solution, please run the following commands in the terminal one after the other in the same sequence below:
sudo systemctl stop MyCustomService
sudo systemctl disable MyCustomService
sudo rm /etc/systemd/system/MyCustomService.service
rm ~/MyScript.sh
Notice:
neofetch
must be installed on your system in order for the above example script to work. It can be installed like so:sudo apt install neofetch
StandardOutput=journal+console
will enable printing output from your script on screen.You can change when the custom service starts executing during boot by specifying in the service file under
[Unit]
theBefore=
andAfter=
system services so that your custom service will run after and / or before certain system services. Please refer to this answer to list the system services in the order they are run.
Becareful:
Test your script first and make sure it executes in a timely correct way to avoid delay or lock-up during boot.

- 32,237
-
Good response! Only problem is that it didn't work, the bash file runs normally if I run it on command line but when it's booting the logo doesn't appear, I actually saw the service being started like wayy after the welcome message but saw no logo appearing even logging on tty. I checked the service with systemctl status and it actually printed the logo there instead of tty, I'll try viewing a way to force it to print into tty. – xproot Feb 25 '21 at 20:55
-
Got it to show in the TTY! looks amazing yet its kinda sad I couldn't get it where i wanted to. I'm still happy with the result! – xproot Feb 25 '21 at 21:09
-
@ThatXPUser That is great, well done. I have updated the answer with extra information that can help. – Raffa Feb 25 '21 at 21:45
MOTD
or message of the day is what you seek from the description.
https://linuxconfig.org/how-to-change-welcome-message-motd-on-ubuntu-18-04-server
-
I didn't mean a motd. when Ubuntu starts starting services it says "Welcome to Ubuntu 20.04 LTS" then it follows with the hostname being set, I want to make the program run before that gets printed on the screen. I can provide a photo if you still don't get what I mean. – xproot Feb 25 '21 at 18:32