<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; message of the day</title> <atom:link href="http://www.ghacks.net/tag/message-of-the-day/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 21:54:04 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Keep logged in users informed with motd</title><link>http://www.ghacks.net/2009/04/06/keep-logged-in-users-informed-with-motd/</link> <comments>http://www.ghacks.net/2009/04/06/keep-logged-in-users-informed-with-motd/#comments</comments> <pubDate>Mon, 06 Apr 2009 19:22:09 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Polls]]></category> <category><![CDATA[The Web]]></category> <category><![CDATA[Tutorials Advanced]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[log in message]]></category> <category><![CDATA[message of the day]]></category> <category><![CDATA[motd]]></category> <category><![CDATA[ubuntu]]></category> <category><![CDATA[ubuntu server]]></category> <guid
isPermaLink="false">http://www.ghacks.net/2009/04/06/keep-logged-in-users-informed-with-motd/</guid> <description><![CDATA[If you have users that log into a server, or a desktop (for whatever reason) you might want to take advantage of the Linux Message Of The Day file. This file resides in the /etc directory and, when a user logs in, the contents of that file are displayed every time a user logs into [...]]]></description> <content:encoded><![CDATA[<p>If you have users that log into a server, or a desktop (for whatever reason) you might want to take advantage of the Linux Message Of The Day file. This file resides in the <strong>/etc</strong> directory and, when a user logs in, the contents of that file are displayed every time a user logs into that machine. Of course there is a bit of a trick involved. If you write your own nice <strong>/etc/motd</strong> file every time you reboot that machine part of the <strong>/etc/motd</strong> file contents will be replaced by new information. Easily we can make the portion of the file that is not rewritten suite our needs. And with a little trickery we can fine tune the entire motd to our satisfaction.</p><p>In reality the message you see upon login is a combination of two files:<strong> /etc/motd </strong>and <strong>/etc/motd.tail</strong>. The former file is the file that is regenerated upon boot. The latter file contains static information. The first thing we will do is change the <strong>/etc/motd</strong> file so that, upon loggin in, the users can get system (or company) specific information. Once that is done we&#8217;ll trick <strong>/etc/motd.tail</strong> into getting content different than that from <strong>/etc/init.d/bootmisc.sh</strong>.</p><p><span
id="more-11723"></span><strong>/etc/motd.tail</strong></p><p>The first thing you should is open up your <strong>/etc/motd.tail</strong> file in your favorite text editor. When I open up that file in Ubuntu Server 8.10 the contents look like:</p><p><em>The programs included with the Ubuntu system are free software;<br
/> the exact distribution terms for each program are described in the<br
/> individual files in /usr/share/doc/*/copyright.</em></p><p><em>Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by<br
/> applicable law.</em></p><p><em>To access official Ubuntu documentation, please visit:<br
/> http://help.ubuntu.com/</em></p><p>I want to change that content so I know exactly which server I am on when I log in. So let&#8217;s say I want to change that to say:</p><p><em>welcome to the Ubuntu Server. have a good time and do not break anything.</em></p><p>Now when I log into my Ubuntu Server I will see the following motd:</p><p><em>welcome to the Ubuntu Server. have a good time and do not break anything.</em></p><p><em>System information as of Mon Apr 6 15:00:01 EDT 2009</em></p><p><em>System load: 0.0 Swap usage: 0% Users logged in: 1<br
/> Usage of /: 18.5% of 13.46GBTemperature: 52 C<br
/> Memory usage: 43% Processes: 104</em></p><p><em>Graph this data and manage this system at https://landscape.canonical.com/<br
/> Last login: Mon Apr 6 15:06:41 2009 from 192.168.1.8</em></p><p>As you can see there is some useful information to be had with this. But you may not want all of your users to see this information. Say you want to first let the users know which server they are on. We&#8217;ve already covered that with <strong>/etc/motd.tail</strong>. But let&#8217;s say you also want to send out a message to all users who log onto the server. You can change <strong>/etc/motd</strong> to reflect that message but when you reboot the machine that message will be replaced. So to get around that we can create a shell script that will over write the information written at bootup. A possible (and overly simple) shell script could look like this:</p><p><code>#!/bin/bash<br
/> rm /etc/motd<br
/> touch /etc/motd<br
/> echo "this is my message" &gt; /etc/motd</code></p><p>Save that file in, say <strong>/opt</strong> (for example sake we&#8217;ll call it <strong>/opt/motd_append</strong>) and make it executable with the command <em>chmod u+x /opt/motd_append. </em>Now to make sure this command runs we can create an entry at the end of <strong>/etc/rc.local</strong> like this:</p><p><em>/opt/motd_append</em></p><p>Now when <strong>/etc/rc.local </strong>runs the script will run and over write the information in <strong>/etc/motd</strong>. Now when your users log in they will see your special message every time.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/04/06/keep-logged-in-users-informed-with-motd/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
