<?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>Sniptools &#187; Linux</title>
	<atom:link href="http://sniptools.com/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://sniptools.com</link>
	<description>Design &#38; Technology Observations</description>
	<lastBuildDate>Fri, 11 Dec 2009 18:00:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Save SSH password for use in &#8220;Terminal&#8221; (OSX or *Nix)</title>
		<link>http://sniptools.com/mac-osx/save-ssh-password-in-terminal</link>
		<comments>http://sniptools.com/mac-osx/save-ssh-password-in-terminal#comments</comments>
		<pubDate>Sat, 19 Jul 2008 04:37:39 +0000</pubDate>
		<dc:creator>Shanx</dc:creator>
				<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[System Maintenance]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[SecureCRT]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Tips/Tricks]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://sniptools.com/cms/?p=163</guid>
		<description><![CDATA[How to set up time-saving shortcuts for SSH in Mac OSX or Linux, a bit like SecureCRT on Windows.  <a href="http://sniptools.com/mac-osx/save-ssh-password-in-terminal">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Anyone who runs hosted remote servers and has to log into remote terminals for regular use, it is vital to have shortcuts that allow for quick login. SSH2 is the recommended way.</p>
<p>On Windows, there is the fantastic SSH2 tool <a href="http://www.vandyke.com/products/securecrt/">SecureCRT</a>. Or if you&#8217;re cash crunched, a combination of Putty and Putty Connection Manager works for many.</p>
<p>On Mac OSX and Unix/Linux systems, one doesn&#8217;t truly need an SSH client at all, because the &#8220;<a href="http://www.osxterminal.com/">Terminal</a>&#8221; application is inbuilt. People talk of iTerm and such, but I have still to see a value add for such tools.</p>
<p>But one does miss the convenience of SecureCRT on OSX, because I have still to find a true SecureCRT alternative for the Mac platform. Something that allows me to make pre-determined connections so I can just click on them to connect (which tools like <a href="http://www.grepsoft.net/jellyfissh.html">JellyfiSSH</a> do) and then logs me in directly without prompting for a password (which JellyfiSHH does not do).</p>
<p>So I have simply made aliases in my [code].profile[/code] file, which gets executed everytime you start your Terminal window (so it&#8217;s a good place to put your shortcuts and any code you wish to execute when the terminal starts, such as paths).</p>
<ol>
<li>Start the Terminal.</li>
<li>Open the profile file for the current user (you).</li>
<pre lang="bash">pico .profile</pre>
<li>Enter a new line for our shortcut.</li>
<pre lang="bash">alias s='ssh -2 -p 22 user@host.com'</pre>
</ol>
<p>Quick explanation for that command in step 3. The letter &#8220;s&#8221; is the shortcut I make for connecting to the sniptools.com server. Change it to what you wish. This will mean that when I start Terminal, all I need to do is type &#8220;s&#8221; and it connects me via SSH to the sniptools.com server. The &#8220;-p&#8221; switch is an important one because some of us with paranoid security settings might have a different port number than the default port 22 for secure SSH. The rest user/host stuff is self-explanatory. The &#8220;-2&#8243; is to force SSH2 connections instead of older vanilla SSH.</p>
<p>Now. Save the profile file and source it to try it out:</p>
<pre lang="bash">source .profile</pre>
<p>Sourcing is only for this one time, for your current Terminal window, which had already executed the profile file *before* we added this alias. When you start a new Terminal session, these aliases et al will be automatically set for you.</p>
<p>Done. Now your profile has the alias for &#8220;s&#8221;. From now when you type &#8220;s&#8221; in your Terminal, it will connect, but it will ask you for a password. To get rid of the nagging password, we need to create public authentication key for the domain. This, in fact is what SecureCRT does behind the scenes on Windows too.</p>
<p>Here are the steps to accomplish this. Run these <strong>one-time</strong> commands in order from the Terminal window.</p>
<pre lang="bash" line="1">
# generate pub and priv keys, leave the passphrase empty
# (simply press ENTER when asked for it)
ssh-keygen

#copy the pub key to the remote computer
#(change port number if different from the usual 22)
#change "user" to your user name
#change "host" to your domain name
scp -P 22 ~/.ssh/id_rsa.pub user@host:~/

#log on to the remote computer
ssh -p 22 user@host

#create the .ssh directory in the root login directory, if it doesn't already exist
mkdir .ssh

#append key to file
cat id_rsa.pub >> ~/.ssh/authorized_keys

#delete the public key file, no longer needed
rm -f id_rsa.pub

#log off the remote server
exit

#logon to the remote server, without password prompt
ssh -2 -p 22 user@host
</pre>
<p>That&#8217;s it. This is a huge timesaver. Now all I need to do to login to the sniptools.com server is type one letter, &#8220;s&#8221; in the Terminal, and I&#8217;m on! Follow these instructions for each host you connect to on a regular basis and you&#8217;ll love the convenience henceforth.</p>
]]></content:encoded>
			<wfw:commentRss>http://sniptools.com/mac-osx/save-ssh-password-in-terminal/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Upgrade PostgreSQL within the same &#8220;minor version&#8221; (8.2.3 -&gt; 8.2.9)</title>
		<link>http://sniptools.com/databases/upgrade-postgresql-within-the-same-minor-version</link>
		<comments>http://sniptools.com/databases/upgrade-postgresql-within-the-same-minor-version#comments</comments>
		<pubDate>Mon, 28 Apr 2008 04:30:58 +0000</pubDate>
		<dc:creator>Shanx</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://sniptools.com/?p=377</guid>
		<description><![CDATA[PostgreSQL is a full-fledged enterprise-grade database brought into the public domain. Many homemade webmasters now have to deal with what is a very viable &#8212; if not an outright better &#8212; alternative to the raging popularity of a significantly simpler &#8230; <a href="http://sniptools.com/databases/upgrade-postgresql-within-the-same-minor-version">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>PostgreSQL is a full-fledged enterprise-grade database brought into the public domain. Many homemade webmasters now have to deal with what is a very viable &#8212; if not an outright better &#8212; alternative to the raging popularity of a significantly simpler MySQL.</p>
<p>Yet, for all its merits and addictive features, PostgreSQL is a <a href="http://www.devissues.com/upgrading-postgresql-new-major-version">beast to upgrade</a> between major version releases.</p>
<p>If you were going from 8.2.x to the latest stable at the time of this writing, 8.3.x, then the move from the 8.2 series to 8.3 would require you to dump/restore your entire database. Not a simple chore if you have a 100 GB worth of critical data, but you have no choice as the innards of PG typically change between &#8220;major upgrades&#8221;. For this, replication technologies such as <a href="http://slony.info">Slony</a> are a useful option as you can install the new database separately, replicate the data over, and then make a switch when the two databases are mirrored &#8212; thereby avoiding the downtime of the hassle (here&#8217;s an <a href="http://www.pgcon.org/2007/schedule/events/20.en.html">informative PGCON presentation</a>).</p>
<h2>Fortunately, minor version upgrades are much simpler.</h2>
<p>No dump/restore is needed. If you were to go from, say 8.2.<span style="color: #cc0000;">3</span> to 8.2.<span style="color: #cc0000;">9</span>, all you would have to do is to upgrade the RPMs. I&#8217;m assuming Linux here but the same would work for other platforms.</p>
<ol>
<li>Check what version you have currently installed:
<pre lang="bash">rpm -qa | grep postgres | tee /root/rpm_pgsql</pre>
</li>
<li>Stop your postgres server
<pre lang="bash">/sbin/service postgresql stop</pre>
</li>
<li>We will now simply execute the RPM upgrade command, which of course assumes that you have the latest <a href="http://www.postgresql.org/download/">RPMs downloaded</a> from the PG website. Notice below that they&#8217;re all lumped into the same command to prevent any (unlikely) possibility of dependency issues, so make sure all of this appears on one line &#8212; the backslash is included here for formatting (so it won&#8217;t break on the command line).
<pre lang="bash">rpm -Uvh
  postgresql-8.2.9-1PGDG.rhel4.i386.rpm
  postgresql-contrib-8.2.9-1PGDG.rhel4.i386.rpm
  postgresql-devel-8.2.9-1PGDG.rhel4.i386.rpm
  postgresql-libs-8.2.9-1PGDG.rhel4.i386.rpm
  postgresql-server-8.2.9-1PGDG.rhel4.i386.rpm</pre>
</li>
<li>Hopefully that went without a hitch. Now restart the postgresql server:
<pre lang="bash">service postgresql restart</pre>
</li>
</ol>
<p>That&#8217;s it. That should do it. It is highly unlikely that you&#8217;ll see errors. And if you&#8217;re running an older 8.2.x, it&#8217;s highly recommended you upgrade to 8.2.9 anyway due to performance increases and some bug fixes.</p>
]]></content:encoded>
			<wfw:commentRss>http://sniptools.com/databases/upgrade-postgresql-within-the-same-minor-version/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find and list large files on Linux (or Unix, BSD, Mac OSX)</title>
		<link>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx</link>
		<comments>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx#comments</comments>
		<pubDate>Mon, 24 Jul 2006 04:20:21 +0000</pubDate>
		<dc:creator>Shanx</dc:creator>
				<category><![CDATA[System Maintenance]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OSX]]></category>

		<guid isPermaLink="false">http://sniptools.com/?p=537</guid>
		<description><![CDATA[There are several ways to do this, the most prevalent among sys admins being this: find {/path/to/folder/} -type f -size +{size-in-kb}k -exec ls -lh {} \; &#124; awk '{ print $9 ": " $5 }' Which lists the largest files &#8230; <a href="http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are several ways to do this, the most prevalent among sys admins being this: </p>
<pre lang="bash">
find {/path/to/folder/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
</pre>
<p>Which lists the largest files in the folder <code>/path/to/folder</code>. You could just use the <code>ls</code> command too, as such: </p>
<pre lang="bash">
ls -lhS
</pre>
<p>But there is a simpler, more efficient method to do this: </p>
<pre lang="bash">
du -xak .|sort -n|tail -50
</pre>
<p>But the best method involves a small Perl hack that shows a very neatly laid out listing of largest files:  </p>
<pre lang="bash">
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf  ("%6.1f\t%s\t%25s  %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sniptools.com/system-maintenance/find-and-list-large-files-on-linux-or-unix-bsd-mac-osx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
