6

When I log in to a TTY I get the following nice text:

Ubuntu 16.04.03 LTS
Log-in: username
Password:
Last log-in date/time
Welcome to Ubuntu 16.04.03 LTS

 * Documentation:
 * Management:
 * Support:

9 packages to update
4 updates are security updates

I would like the last 2 lines repeated every time I open a GUI terminal for all users in the adm group (but will settle for having the entire thing displayed each and every time I open a GUI Terminal for all users)

I tried the obvious:

fab-root@fab-ux-predator:~
$ cd /etc/update-motd.d/
fab-root@fab-ux-predator:/etc/update-motd.d
$ ./90-updates-available 
fab-root@fab-ux-predator:/etc/update-motd.d
$ cat /var/lib/update-notifier/updates-available
cat: /var/lib/update-notifier/updates-available: Permission denied
fab-root@fab-ux-predator:/etc/update-motd.d
$

What am I missing?

P.S. Obviously I can chmod o+r the file, but how future-proof would that be?

  • Feature of updates-available creation by /usr/lib/update-notifier/update-motd-updates-available ? – stumblebee Jan 29 '18 at 22:44
4

It is a bit slow but it will generate the package/update information. Append this to the users .bashrc file:

/usr/lib/update-notifier/apt-check --human-readable
  • Going to try both solutions tonight... Upvoted both already. – Fabby Jan 30 '18 at 19:54
  • Sorry for not coming back yet, but there haven't been any updateable packages yet... – Fabby Feb 1 '18 at 19:33
  • @Fabby Thorough testing is a good thing. Haste is not very forgiving :-) – stumblebee Feb 2 '18 at 18:02
  • I tested, and on my machine with the OS running on an SSD with not too many packages installed, it runs<1sec. :-) Looking good! – Fabby Feb 2 '18 at 18:14
  • @Fabby There user will probably hardly notice the delay if it is preceded with a fortune. – stumblebee Feb 2 '18 at 20:03
3

The entire output is in /run/motd.dynamic:

$ grep motd /etc/pam.d -R
/etc/pam.d/sshd:# This includes a dynamically generated part from /run/motd.dynamic
/etc/pam.d/sshd:# and a static (admin-editable) part from /etc/motd.
/etc/pam.d/sshd:session    optional     pam_motd.so  motd=/run/motd.dynamic
/etc/pam.d/sshd:session    optional     pam_motd.so noupdate
/etc/pam.d/login:# This includes a dynamically generated part from /run/motd.dynamic
/etc/pam.d/login:# and a static (admin-editable) part from /etc/motd.
/etc/pam.d/login:session    optional   pam_motd.so motd=/run/motd.dynamic
/etc/pam.d/login:session    optional   pam_motd.so noupdate

So, in your .bashrc, you could append:

[[ -r /run/motd.dynamic ]] && cat /run/motd.dynamic

Or:

[[ -r /run/motd.dynamic ]] && grep update /run/motd.dynamic
  • Does this file only get updated when someone logs in? – stumblebee Jan 30 '18 at 1:16
  • Seems so: askubuntu.com/q/105689/158442 – muru Jan 30 '18 at 1:19
  • ... so opening a new terminal will show stale information if no one has logged in recently :-(. – Stephen Kitt Jan 30 '18 at 7:42
  • That's already better than what I currently have! @StephenKitt – Fabby Jan 30 '18 at 19:53
  • @StephenKitt Fabby can probably set up a cron job to force update the MOTD every day or so. The scripts generating the MOTD will add a noticeable delay to shell startup if run every time. – muru Jan 31 '18 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.