<?xml version="1.0" encoding="UTF-8"?>
<tips type="array">
  <tip>
    <content>&lt;p&gt;If as a Linux native you find yourself on a Solaris box, you'll noticed that from Solaris 10 SYS V rc-style scripts are no longer used to control daemon processes. Instead, the SMF system is used.&lt;/p&gt;
&lt;p&gt;Below are some service(8) commands and their Solaris counterparts:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;service httpd restart || svcadm restart httpd&lt;/p&gt;
&lt;p&gt;service --status-all || svcs -a&lt;/p&gt;
&lt;p&gt;service httpd --full-restart || svcadm disable -s httpd &amp;amp;&amp;amp; svcadm enable -s httpd&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A word about "service names" under Solaris SMF. They are not so much names, more patterns matching an identifying path-like string (or FRMI in the lingo). There may be more than one service that matches the pattern, httpd, in this case. "dns" is one such example, as it matches the services:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;svc:/network/dns/client:default&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;svc:/network/dns/server:default&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;both. In this case, you have to increase the pattern until there is only one unique match:  svcadm restart dns/server  for example. For a fuller explanation, see:&lt;a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp"&gt; http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp&lt;/a&gt;&lt;/p&gt;</content>
    <created-at type="datetime">2010-03-08T17:38:10Z</created-at>
    <id type="integer">8</id>
    <short-url nil="true"></short-url>
    <title>service(8) to Solaris SMF command lookup</title>
    <updated-at type="datetime">2010-03-08T17:38:10Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">5</votes-count>
  </tip>
  <tip>
    <content>&lt;p&gt;History expansion, much like the command&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;cd -&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;which moves you into the directory that you were in immediately prior to the current one, is an oft-overlooked but powerful and convienient mechanism for making your time in the shell more accurate, and for saving time.&lt;/p&gt;
&lt;p&gt;The simplest form of this is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$ grep -i somestring somefile&lt;/p&gt;
&lt;p&gt;$ mv !$ /tmp&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This will search the file somefile for the string somestring, and then move somefile into the directory /tmp.&lt;/p&gt;
&lt;p&gt;Another common usage is the "quick substitution" command:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;$ echo somefile&lt;/p&gt;
&lt;p&gt;$ ^echo^cat^&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This will echo the word "somefile" to STDOUT. The '^^^' command will execute the previous command, substituting the first parameter (echo) for the second (cat) - in this instance attempting to cat a file called somefile.&lt;/p&gt;
&lt;p&gt;The HISTORY EXPANSION section of the bash(1) manpage details further modifiers, all in the same vein as vi commands, that can be used to further modify or search the command history.&lt;/p&gt;</content>
    <created-at type="datetime">2010-03-02T11:09:57Z</created-at>
    <id type="integer">7</id>
    <short-url>http://moourl.com/q5lz6</short-url>
    <title>History expansion in bash shell</title>
    <updated-at type="datetime">2010-03-08T16:57:25Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">15</votes-count>
  </tip>
  <tip>
    <content>&lt;p&gt;I&amp;rsquo;ve been using a couple of nice shell aliases when working with ad-hoc iptables rules. You can spruce them up as a batch file, but they&amp;rsquo;re fine for me as a quick and dirty way to manipulate rules.&lt;/p&gt;
&lt;blockquote&gt;alias ips="/sbin/iptables --line-numbers -vn -L INPUT | grep -i"alias ipd="/sbin/iptables -D INPUT"&lt;/blockquote&gt;
&lt;p&gt;That&amp;rsquo;s all there is to it. You can then interrogate almost any aspect of the default INPUT filter with:&lt;/p&gt;
&lt;blockquote&gt;ips icmp&lt;/blockquote&gt;
&lt;blockquote&gt;ips 10.64.0&lt;/blockquote&gt;
&lt;blockquote&gt;ips drop&lt;/blockquote&gt;
&lt;p&gt;to view all ICMP rules, any rules relating to the 10.64.0 subnet, or all rules that drop packets.&lt;/p&gt;
&lt;p&gt;The way I use these together, and the reason that `ips` includes the &amp;ndash;line-numbers argument, is that I like to add rules and then easily delete them with:&lt;/p&gt;
&lt;blockquote&gt;# ips 19230       0     0 DROP       all  --  *      *       192.0.2.0/24         0.0.0.0/0&lt;/blockquote&gt;
&lt;blockquote&gt;# ipd 30&lt;/blockquote&gt;
&lt;p&gt;using the rule number as an easier way of deleting the rule without having to conjour up a matching rule specification.&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-26T15:04:00Z</created-at>
    <id type="integer">4</id>
    <short-url>http://moourl.com/pm261</short-url>
    <title>Easily manipulate iptables rules with aliases</title>
    <updated-at type="datetime">2010-03-08T16:57:23Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">4</votes-count>
  </tip>
  <tip>
    <content>&lt;p&gt;The bash shell has a powerful history mechanism, which in its default state isn't too useful. Luckily the modifications are quite easy to make.&lt;/p&gt;
&lt;p&gt;Hit Ctrl-R and then type the first few letters of a previously executed command. Bash will search through the search history to find the command that matches this string. Continue to hit Ctrl-R to see the alternatives. When you find the command that you want, hit return and it'll be executed. Fewer keystrokes, less effort, fewer typos.&lt;/p&gt;
&lt;p&gt;The bash(1) manpage details a number of variables that dictate how bash handles command history.&lt;/p&gt;
&lt;p&gt;Two of these variables are:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;HISTFILESIZE&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;HISTSIZE&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Both have a default of 500, which if live on the command line is far too small. Increase the size of both of these variables by adding the following lines to your $HOME/.bashrc file:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;export HISTFILESIZE=20000&lt;/p&gt;
&lt;p&gt;export HISTSIZE=$HISTFILESIZE&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A pool of 20,000 previously executed commands (or more if you fancy) increases the utility of the command history search dramatically.&lt;/p&gt;
&lt;p&gt;Advanced shell users might like to take note of what the manpage says about the $HISTCONTROL variable, especially the sentence:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If the list of values includes ignorespace, lines which begin with a space character are not saved&amp;nbsp; in the history list.&lt;/p&gt;
&lt;/blockquote&gt;</content>
    <created-at type="datetime">2010-02-27T13:39:31Z</created-at>
    <id type="integer">5</id>
    <short-url>http://moourl.com/o9btn</short-url>
    <title>Fewer keystrokes in bash with Ctrl-R</title>
    <updated-at type="datetime">2010-03-08T16:57:23Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">8</votes-count>
  </tip>
  <tip>
    <content>&lt;p&gt;To display the top 10 consumers of memory:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;ps -auxf | sort -nr -k 4 | head -10&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To display the top 10 consumers of CPU:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;ps -auxf | sort -nr -k 3 | head -10&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content>
    <created-at type="datetime">2010-02-26T10:18:42Z</created-at>
    <id type="integer">3</id>
    <short-url>http://moourl.com/3w5ul</short-url>
    <title>Using ps to find the top 10 consumers of CPU and memory</title>
    <updated-at type="datetime">2010-03-08T16:57:22Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">14</votes-count>
  </tip>
  <tip>
    <content>&lt;p&gt;Hopefully you will be using &lt;a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp"&gt;SMF&lt;/a&gt; to manage the services. You will doubtless know that the command&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;svcadm restart domain1&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;would restart a domain. However, if you want to script your restart like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;svcadm restart domain1 &amp;amp;&amp;amp; touch .reload&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;perhaps, the the return code you are checking is a result of the restart command being sucessfully passed to the SMF facility. If you really want to wait for the domain to restart properly, the do then following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;svcadm disable -s domain1 &amp;amp;&amp;amp; svcadm enable -s domain1 &amp;amp;&amp;amp; touch .reload&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The -s switch svcadm waits for the result of the termination, and sets its return code appropriately. Likewise when starting the domain.&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-23T15:19:33Z</created-at>
    <id type="integer">2</id>
    <short-url>http://moourl.com/f0zys</short-url>
    <title>Restart Sun/Oracle Glassfish domain on Solaris 10 under SMF</title>
    <updated-at type="datetime">2010-03-08T16:57:21Z</updated-at>
    <user-id type="integer">1</user-id>
    <votes-count type="integer">27</votes-count>
  </tip>
</tips>
