26

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 
  • 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 at 19:25
15

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?

  • 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 '18 at 2:11
  • 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 at 18:53
28

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

  • I had to use this method in Ubuntu 14.04. – J Smith Aug 28 '17 at 18:24
  • 7
    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) – Aaron Wallentine Feb 25 '18 at 21:44
  • As of Ubuntu 19.04, it is now cat /var/run/motd.dynamic.new – Adam Erickson May 10 at 23:07
7

Ubuntu runs this at login:

/usr/bin/landscape-sysinfo

You can simply run it through terminal using following command:

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

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.

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.

1

You could run landscape-sysinfo for system information and

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

for information about packets.

  • 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 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 at 18:48
1

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.

0

First answer here so sorry about any format issues.

Aaron Wallentine's answer lead 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 belive, 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. ex:

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 " ; " 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.

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.