如何查看Ubuntu在登录时随时显示的详细信息?

当我登录我的ubuntu系统时,它会向我显示此消息,我怎样才能看到它? 我试着跑. .bashrc . .bashrc但它没有用。

 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 

您可以随时显示您希望收到此消息的消息 – 使用终端中的下一个命令:

 cat /etc/motd 

或更好:

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

如果你想在每次打开终端时看到这条消息,只需在~/.bashrc文件的末尾插入上面的一行(你可以用gedit ~/.bashrc命令打开它)。

/ etc / motd是类Unix系统上的一个文件,它包含一个“当天的消息”,用于向所有用户发送公共消息,其方式比向所有用户发送电子邮件更有效。

更多关于: http : //en.wikipedia.org/wiki/Motd_(Unix)

相关: / etc / motd如何更新?

看起来好像变了。 使用Ubuntu 16.04时没有/etc/motd但你可以改为cat /var/run/motd.dynamic

Ubuntu在登录时运行:

 /usr/bin/landscape-sysinfo 

您只需使用以下命令通过终端运行它:

 landscape-sysinfo 

我想这是由PAM管理的,通过/etc/pam.d/login ,查找motd (当天的消息)。

您可以使用cat /etc/motd生成该消息的静态部分。 我没有你展示的动态部分,所以我无法帮助你。

你还没有启用安静模式 。 如果启用了静默模式登录,则以前的解决方案中的答案将不起作用。

您可以在/var/run/motd.dynamic/run/motd.dynamic看到上次用户登录 /run/motd.dynamic时生成的motd消息。 这两个文件都指向同一个inode,这意味着它们是硬链接。

如果您未以安静模式登录,则在您登录后该信息是静态的。 如果您是第一个登录系统的用户,并且您有.hushlogin文件,则不会生成该文件。 如果您的用户没有.hushlogin文件,当您尝试访问该文件时,您将看到过时的内容。

我能想到的最好方法是简单地通过touch ~/.hushlogin来创建一个touch ~/.hushlogin

编辑.bashrc文件并添加内容为@RaduRădeanu指出:

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

所以每当你跑步. .bashrc . .bashrc ,您将看到新消息而不是静态消息。

注意: .bashrc是针对所有非登录交互式shell执行的,因此当您通过键入bash打开交互式shell时,您将看到此消息。

您可以运行landscape-sysinfo获取系统信息和

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

有关数据包的信息。

看起来该输出是由位于文件夹/etc/update-motd.d的脚本生成的;
如果您进入该目录,则可以针对不同的信息位运行各个脚本; 或者您可以查看脚本的来源以查看它实际运行的命令以获取该信息,这些信息似乎在发布之间发生变化(使用cat或文本编辑器,如nanopicoemacsvim等) )。

例:

 $ 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* 

此信息是撰写本文和Ubuntu 16.04.4 LTS时的最新信息。