{"id":411,"date":"2010-01-18T01:09:43","date_gmt":"2010-01-18T06:09:43","guid":{"rendered":"http:\/\/yourlinuxguy.com\/?p=411"},"modified":"2010-01-17T20:16:32","modified_gmt":"2010-01-18T01:16:32","slug":"handy-little-rug-lu-commands","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=411","title":{"rendered":"Handy little &#8220;rug lu&#8221; commands"},"content":{"rendered":"<p>This question came in from Steve in a <a title=\"http:\/\/yourlinuxguy.com\/?page_id=7&amp;cpage=1#comment-4624\" href=\"http:\/\/yourlinuxguy.com\/?page_id=7&amp;cpage=1#comment-4624\" target=\"_blank\">comment<\/a>:\u00a0 &#8220;&#8230;<em>I am looking for a way to run the \u201crug lu\u201d command and have it dump the output my local machine to look over and see what updates I have ahead of me&#8230;<\/em>&#8221;<\/p>\n<p><span style=\"color: #888888;\">So <a title=\"http:\/\/yourlinuxguy.com\/?page_id=7&amp;cpage=1#comment-4625\" href=\"http:\/\/yourlinuxguy.com\/?page_id=7&amp;cpage=1#comment-4625\" target=\"_blank\">I replied<\/a>, but then I thought of alot more stuff&#8230; so much more in fact, that I thought it deserved its own post&#8230;\u00a0 So here you go, an &#8220;extended play&#8221; version of my reply&#8230;<\/span><\/p>\n<p><strong>For OpenSuse servers\u2026<\/strong><\/p>\n<p>Please see this post:\u00a0 <a rel=\"nofollow\" href=\"..\/?p=324\">http:\/\/yourlinuxguy.com\/?p=324<\/a><\/p>\n<p>That is exactly what I was going for in the post linked above.\u00a0 If you download that script I mention there in that post, then change it to executable (for instance, <code>chmod 700 filename<\/code>), then run it, it will generate a comparison and dump the results to screen and output file, and tell you where the file is.<\/p>\n<p>The script will not actually update your system (in the current state); it will only report about potential updates. But, if you get more brave, you can go in the file and un-comment the zypper lines I commented out that actually update the system\u2026\u00a0 Or change them to rug lines\u2026\u00a0 Which leads me to&#8230;<\/p>\n<p><strong>For SLES\/OES servers\u2026<\/strong><\/p>\n<p>Just do this:<br \/>\n<code>rug lu &gt; \/tmp\/lu.txt<\/code><\/p>\n<p>&#8230;then go look at the file with:<br \/>\n<code>less \/tmp\/lu.txt<\/code><\/p>\n<p>&#8230;Or, you could have it emailed to yourself like this:<br \/>\n<code>rug lu |mailx -s \"Updates from $HOSTNAME\" root<\/code><\/p>\n<p>\u2026of course, that assumes that you are having root mail sent off the box (<a title=\"http:\/\/yourlinuxguy.com\/?p=38\" href=\"http:\/\/yourlinuxguy.com\/?p=38\" target=\"_blank\">see this<\/a> if you&#8217;re not).\u00a0  Otherwise you use your email address instead of root.<\/p>\n<p>But what if you want to limit the updates list?\u00a0 Perhaps something more specific; to report only that in which you are interested in updating?\u00a0 See these examples (note that you can change the rug catalog to taste, of course, depending on your version):<\/p>\n<pre><code>rug lu -t patch SLES10-SP3-Updates OES2-SP2-Updates |mailx -s \"Updates from $HOSTNAME\" root<\/code><\/pre>\n<p>By adding a grep statement to block out the &#8220;optional&#8221; lines, the result is even cleaner.\u00a0 Here&#8217;s an example:<\/p>\n<pre><code>rug lu -t patch SLES10-SP3-Updates OES2-SP2-Updates |grep -v optional|mailx -s \"Updates from $HOSTNAME\" root<\/code><\/pre>\n<p>On the other hand, by only *including* the lines you want (instead of excluding those you don&#8217;t), you lose the headers and separators, and only get the lines in which you&#8217;re interested (if any).\u00a0 Here&#8217;s an example:<\/p>\n<pre><code>rug lu -t patch SLES10-SP3-Updates OES2-SP2-Updates |grep -e security -e recommended|mailx -s \"Updates from $HOSTNAME\" root<\/code><\/pre>\n<p>Or if you were to be running this in a mass-batch (hmm&#8230; future post&#8230;) to a bunch of servers or a cron job, and just don&#8217;t want an email at all if there are no results (and you *do* want an email if there *are* results):<\/p>\n<pre><code>RESULT=`rug lu -t patch SLES10-SP3-Updates OES2-SP2-Updates |grep -e security -e recommended`;if [ \"XX$RESULT\" != \"XX\" ];then echo \"optional updates:\" $RESULT |mailx -s \"Updates from $HOSTNAME\" root;fi<\/code><\/pre>\n<p>Okay now, that&#8217;s good; but here&#8217;s a prettier version of the same&#8230;\u00a0 Okay, the command itself is uglier, but the resulting email is prettier at least.\u00a0 The above one doesn&#8217;t format the results as nicely as I like (losing all the line returns), so I had to make use of a temp file to maintain the output formatted with returns:<\/p>\n<pre><code>rug lu -t patch SLES10-SP3-Updates OES2-SP2-Updates |grep -e security -e recommended&gt;\/tmp\/ruglu.txt;RESULT=`cat \/tmp\/ruglu.txt`;if [ \"XX$RESULT\" != \"XX\" ];then cat \/tmp\/ruglu.txt|mailx -s \"Updates from $HOSTNAME\" root;fi<\/code><\/pre>\n<p>And that&#8217;s about it, with a couple closing thoughts:\u00a0 Remember, it&#8217;s definitely a good idea to do a &#8220;rug ping&#8221; before doing this, to wake it all up, so you&#8217;re not waiting in silence for each command to run while it wakes up.\u00a0 Then if you actually need updates, do this:<\/p>\n<pre><code>rug up -y -t patch -g security -g recommended SLES10-SP3-Updates OES2-SP2-Updates<\/code><\/pre>\n<p>Do you feel updated?\u00a0 I do.<\/p>\n<p>\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This question came in from Steve in a comment:\u00a0 &#8220;&#8230;I am looking for a way to run the \u201crug lu\u201d command and have it dump the output my local machine to look over and see what updates I have ahead&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=411\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,83,82,72],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-intermediate","category-oes2sp1","category-oes2sp2","category-rug"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-6D","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=411"}],"version-history":[{"count":11,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":461,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions\/461"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}