70

When I login to my ubuntu system, it show me this this message, How can I see it any time? I tried to run . .bashrc but it didn't worked.

Welcome to Ubuntu 12.10 LTS (GNU/Linux 3.2.0-24-virtual x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Jul 13 06:16:35 UTC 2013

  System load:  0.55              Processes:           96
  Usage of /:   8.1% of 68.74GB   Users logged in:     0
  Memory usage: 55%               IP address for eth0: 198.xx.xxx.xxx
  Swap usage:   0%                IP address for eth1: xxx.1x0.xx.xxx

  => There is 1 zombie process.

  Graph this data and manage this system at https://landscape.canonical.com/

223 packages can be updated.
134 updates are security updates.

Last login: Mon Jul  8 17:47:05 2013 
1
  • So sad that there is actually no standard command to just acomplish this, and that methods change so frequently that the accepted answer and its replacement have both already been obsoleted!
    – nealmcb
    Jun 17, 2019 at 19:25

10 Answers 10

64

Looks like it changed. With Ubuntu 16.04 there is no /etc/motd but you can cat /var/run/motd.dynamic instead.

3
  • 1
    I had to use this method in Ubuntu 14.04.
    – J Smith
    Aug 28, 2017 at 18:24
  • 17
    Note that /var/run/motd.dynamic is just a cached static output of the last time it was run, upon login. To actually see live output again, you have to run the scripts that generate it, which are in /etc/update-motd.d (as of this writing, on Ubuntu 16.04.4 LTS) Feb 25, 2018 at 21:44
  • 1
    As of Ubuntu 19.04, it is now cat /var/run/motd.dynamic.new May 10, 2019 at 23:07
38

As noted a few times, scripts under /etc/update-motd.d are what provide the typical output shown upon logging in; see update-motd(5). But there's little or no need to reinvent the wheel, by scripting something yourself to run each script in turn so as to recreate the desired functionality. Use run-parts(8) instead, which is provided for just such a purpose:

sudo run-parts /etc/update-motd.d

This is akin to what the pam_motd(8) PAM module does, running as root, after user authentication and just before opening a user login shell.

Note that run-parts itself requires no special privileges; however, one or more of the update-motd scripts typically have needed them. So, unless you're in a root shell, don't leave off the sudo when you run this, or else you will likely see errors and stale system information displayed.

[2022-09-24: Self-edited for clarity. --RichieD]

1
  • 2
    This is the best answer as it a) updates the data b)runs only appropriate scripts c) prints the resulting output.
    – Eddie
    Mar 30, 2022 at 22:49
30

You can show anytime when you wish this message - message of the day - using next command in terminal:

cat /etc/motd

or, better:

for i in /etc/update-motd.d/*; do if [ "$i" != "/etc/update-motd.d/98-fsck-at-reboot" ]; then $i; fi; done

If you want to see this message everytime when you open a terminal, just insert one of the above lines at the end of ~/.bashrc file (you can open it with gedit ~/.bashrc command).

The /etc/motd is a file on Unix-like systems that contains a "message of the day", used to send a common message to all users, in a more efficient manner than sending them all an e-mail message.

More about: http://en.wikipedia.org/wiki/Motd_(Unix)

Related: How is /etc/motd updated?

2
  • The same, but shorter discharging error messages (as from time to time the contents fo /etc/update-motd.d change): for i in /etc/update-motd.d/*; do $i 2>/dev/null; done
    – luis_js
    Nov 20, 2018 at 2:11
  • 4
    You can no longer cat /etc/motd, unfortunately, as others have noted. And it has changed twice since that. (Why isn't there a standard command to do this? sigh)
    – nealmcb
    Jun 17, 2019 at 18:53
18

Ubuntu runs this at login:

/usr/bin/landscape-sysinfo

You can simply run it through terminal using following command:

landscape-sysinfo
1
  • 4
    Interesting. But that is only one part of the full motd.
    – nealmcb
    Jun 17, 2019 at 18:46
6

If you are looking to refresh and display the motd, try:

run-parts /etc/update-motd.d/
2
  • 1
    Thank you for highlighting that this can be done without sudo. Clearly it's done on login without sudo. :) Apr 20, 2022 at 19:23
  • 1
    @nonrectangular: When "done on login", the equivalent of the above command is run as root, before the system opens a user shell for you. run-parts itself doesn't require root privileges; it's just a handy tool to run some scripts grouped into a named directory. However the scripts therein may well require some privileges; typically 50-landscape-sysinfo is such a case, pertinent to this question. Hence my advice to run with sudo or in a root shell. But sure, if you don't mind seeing error messages or stale system info, you needn't bother with that fussiness: nothing will break. :)
    – RichieD
    Sep 25, 2022 at 1:44
4

You have not yet enabled hushed mode as I see. If you enable hushed mode login, the answers in the previous solution's will not work.

You can see the motd message in either /var/run/motd.dynamic and /run/motd.dynamic that was generated the last time a user has logged in non-hushed mode. Both the files point to the same inode which mean they are hard links.

The information is static once you login if you do not login in hushed mode. The file is not generated if you are the first user who does login to the system and if you have .hushlogin file. If you have a user who did not have the .hushlogin file, you will see the stale contents when you try to access that.

The best way I can think of is by creating a .hushlogin simply by doing touch ~/.hushlogin.

Edit you .bashrc file and add the contents as @Radu Rădeanu has pointed:

for i in /etc/update-motd.d/*; do if [ "$i" != "/etc/update-motd.d/98-fsck-at-reboot" ]; then $i; fi; done

So whenever you run . .bashrc, you will see new message instead of the static message.

Note: .bashrc is executed for all non-login interactive shells and hence you will see this messages when you open an interactive shell by typing bash.

3

Looks like that output is generated by the scripts located in the folder /etc/update-motd.d;
If you go into that directory, you can run the individual scripts for the different bits of info; or you can look at the source of the scripts to see the commands it's actually running to get that information, which seem to change from release to release (using cat, or a text editor, such as nano, pico, emacs, vim, etc.).

Example:

$ ll /etc/update-motd.d/
total 44
drwxrwxr-x   2 root root 4096 Feb 25 21:27 ./
drwxr-xr-x 110 root root 4096 Feb 25 21:33 ../
-rwxr-xr-x   1 root root 1220 Oct 22  2015 00-header*
-rwxr-xr-x   1 root root 1157 Jun 14  2016 10-help-text*
-rwxr-xr-x   1 root root  334 Jan 12 14:30 51-cloudguest*
-rwxr-xr-x   1 root root   97 May 24  2016 90-updates-available*
-rwxr-xr-x   1 root root  299 Jul 22  2016 91-release-upgrade*
-rwxr-xr-x   1 root root  111 May 11  2017 97-overlayroot*
-rwxr-xr-x   1 root root  142 May 24  2016 98-fsck-at-reboot*
-rwxr-xr-x   1 root root  144 May 24  2016 98-reboot-required*
-rwxrwxr-x   1 root root 1204 Jan 15 19:11 99-one-click*

This information is current as of this writing and Ubuntu 16.04.4 LTS.

2

I suppose this is managed by PAM, via /etc/pam.d/login, look for motd (message of the day).

You can produce the static part of that message with cat /etc/motd. I do not have the dynamic part that you show, so I cannot help with that.

0
2

Aaron Wallentine's answer led me to my solution. "Looks like that output is generated by the scripts located in the folder /etc/update-motd.d. If you go into that directory, you can run the individual scripts for the different bits of info."

Each of the scripts in the folder /etc/update-motd.d run, I believe, in order of the number they have in their names at login. As an example mine were:

10-header 30-sysinfo  32-site  35-motd  98-autoreboot-warn

You can run each separately to display their data. e.g.:

cd /etc/update-motd.d
sudo ./10-header  or  sudo ./30-sysinfo**

You could run them all together like this:

sudo /etc/update-motd.d/10-header ; sudo /etc/update-motd.d/30-sysinfo ; ... using the ;(semi-colon) symbol to link commands.

but who wants to type all that out, i ended up turning that long linked command string into a shell script.

Change to the bin directory:

cd /bin

create a file, i called mine "clr" because im using it to clear my screen too, call yours whatever:

sudo touch clr

Make your script executable:

sudo chmod +x clr

I used nano to edit mine, use your favorite:

sudo nano clr

Then, add that long command string from before to your file, remember to use your motd files, not mine, as they will be different:

clear ; sudo /etc/update-motd.d/10-header ; sudo /etc/update-motd.d/30-sysinfo ; sudo /etc/update-motd.d/ ; sudo /etc/update-motd.d/32-site ; sudo /etc/update-motd.d/35-motd ; sudo /etc/update-motd.d/98-autoreboot-warn

Save it, and run it whenever to see your motd freshly updated, note I added clear ; in mine, so when I type clr it will clear my screen and show updated stats.

I think that is all I got, hope it helps someone.

1

You could run landscape-sysinfo for system information and

/usr/lib/update-notifier/update-motd-updates-available

for information about packets.

2
  • obviously this works only if you have landscape installed. It is a commercial (not free) tool (for those that don't know about it).
    – aenw
    Apr 6, 2019 at 20:30
  • I get: find: ‘/var/lib/apt/lists/partial’: Permission denied and mktemp: failed to create file via template ‘/var/lib/update-notifier/tmp.XXXXXXXXXX’: Permission denied
    – nealmcb
    Jun 17, 2019 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .