<?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>Tue, 15 May 2012 09:23:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Increase size of /tmp folder on CentOS Linux under Cpanel</title><link>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel</link> <comments>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel#comments</comments> <pubDate>Sat, 30 Apr 2011 09:28:23 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Hosting]]></category> <category><![CDATA[Unix]]></category> <category><![CDATA[centos]]></category> <category><![CDATA[cpanel]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[unix]]></category><guid
isPermaLink="false">http://sniptools.com/?p=590</guid> <description><![CDATA[Any dedicated server hosting some websites that get meaningful traffic will quickly ourgrow Cpanel's default /tmp folder size of 512MB. It houses PHP session files, temporary file uploads, your database temporary files, your web server's cache including the one from caches such as APC or eAccelerator, and other such stuff. With the tmp partition full, [...]]]></description> <content:encoded><![CDATA[<p>Any dedicated server hosting some websites that get meaningful traffic will quickly ourgrow Cpanel's default <code>/tmp</code> folder size of 512MB. It houses PHP session files, temporary file uploads, your database temporary files, your web server's cache including the one from caches such as APC or eAccelerator, and other such stuff.</p><p>With the tmp partition full, the server will experience many random issues such as server crashes. Your sites will quickly go down and leave you head-scratching.</p><p>Fortunately, it's quite easy to resize the /tmp partition on cPanel servers — especially if it is the default one created by cPanel installs. There's a handy script at <code>/scripts/securetmp</code>.</p><p>Open this file:</p><blockquote><p><code>pico /scripts/securetmp<br
/> </code></p></blockquote><p>And find this line:</p><blockquote><p><code>my $tmpdsksize     = 512000;    # Must be larger than 250000<br
/> </code></p></blockquote><p>Change it to a larger number than 512 MB. Say you want it to be 2 GB:</p><blockquote><p><code>my $tmpdsksize     = 2097152;   # 2GB for the /tmp folder<br
/> </code></p></blockquote><p>Now close and save the file.</p><p>We need to stop all services that may be using this folder. For me, this includes MySQL, Apache and Nginx.</p><blockquote><p><code>service mysql stop<br
/> service nginx stop<br
/> service httpd stop<br
/> </code></p></blockquote><p>Now we will simply unmount the /tmp folder and recreate it. Here's the sequence of commands to create it:</p><blockquote><p><code>lsof /tmp<br
/> umount -l /tmp<br
/> umount -l /var/tmp<br
/> rm -fv /usr/tmpDSK<br
/> /scripts/securetmp<br
/> </code></p></blockquote><p>Done. You can verify the size of the /tmp folder among others:</p><blockquote><p><code>df -h<br
/> </code></p></blockquote><p>This should show you something like this:</p><blockquote><p><code>...<br
/> /usr/tmpDSK   ext3    2.0G  996M  1.1G  51%   /tmp<br
/> ...<br
/> </code></p></blockquote><p>NOTE: If you have any problems, for instance, the size of the recreated /tmp folder is not really 2GB despite that code in the /scripts/securetmp we changed, it may be because of some settings you have in the /etc/fstab file. Take a look at it and comment out any lines that interfere with the LABEL for /tmp mount.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Save SSH password for use in &quot;Terminal&quot; (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. ]]></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'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't truly need an SSH client at all, because the "<a
href="http://www.osxterminal.com/">Terminal</a>" 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'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><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">pico .profile</pre></div></div><li>Enter a new line for our shortcut.</li><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">s</span>=<span style="color: #ff0000;">'ssh -2 -p 22 user@host.com'</span></pre></div></div></ol><p>Quick explanation for that command in step 3. The letter "s" 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 "s" and it connects me via SSH to the sniptools.com server. The "-p" 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 "-2" 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><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> .profile</pre></div></div><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 "s". From now when you type "s" 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><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># generate pub and priv keys, leave the passphrase empty</span>
<span style="color: #666666; font-style: italic;"># (simply press ENTER when asked for it)</span>
<span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#copy the pub key to the remote computer</span>
<span style="color: #666666; font-style: italic;">#(change port number if different from the usual 22)</span>
<span style="color: #666666; font-style: italic;">#change &quot;user&quot; to your user name</span>
<span style="color: #666666; font-style: italic;">#change &quot;host&quot; to your domain name</span>
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-P</span> <span style="color: #000000;">22</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub user<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#log on to the remote computer</span>
<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">22</span> user<span style="color: #000000; font-weight: bold;">@</span>host
&nbsp;
<span style="color: #666666; font-style: italic;">#create the .ssh directory in the root login directory, if it doesn't already exist</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> .ssh
&nbsp;
<span style="color: #666666; font-style: italic;">#append key to file</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> id_rsa.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys
&nbsp;
<span style="color: #666666; font-style: italic;">#delete the public key file, no longer needed</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> id_rsa.pub
&nbsp;
<span style="color: #666666; font-style: italic;">#log off the remote server</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#logon to the remote server, without password prompt</span>
<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-2</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">22</span> user<span style="color: #000000; font-weight: bold;">@</span>host</pre></td></tr></table></div><p>That's it. This is a huge timesaver. Now all I need to do to login to the sniptools.com server is type one letter, "s" in the Terminal, and I'm on! Follow these instructions for each host you connect to on a regular basis and you'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>19</slash:comments> </item> <item><title>Upgrade PostgreSQL within the same &quot;minor version&quot; (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 — if not an outright better — alternative to the raging popularity of a significantly simpler MySQL. Yet, for all its merits and addictive features, PostgreSQL is a beast to upgrade [...]]]></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 — if not an outright better — 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 "major upgrades". 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 — thereby avoiding the downtime of the hassle (here'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'm assuming Linux here but the same would work for other platforms.</p><ol><li>Check what version you have currently installed:<div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-qa</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> postgres <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>rpm_pgsql</pre></div></div></li><li>Stop your postgres server<div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>service postgresql stop</pre></div></div></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'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 — the backslash is included here for formatting (so it won't break on the command line).<div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-Uvh</span> 
  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></div></div></li><li>Hopefully that went without a hitch. Now restart the postgresql server:<div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">service postgresql restart</pre></div></div></li></ol><p>That's it. That should do it. It is highly unlikely that you'll see errors. And if you're running an older 8.2.x, it'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 &#123;/path/to/folder/&#125; -type f -size +&#123;size-in-kb&#125;k -exec ls -lh &#123;&#125; \; &#124; awk '{ print $9 &#34;: &#34; $5 }' Which lists the largest files in the folder /path/to/folder. You could just use the ls command too, as such: ls [...]]]></description> <content:encoded><![CDATA[<p>There are several ways to do this, the most prevalent among sys admins being this:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>folder<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-size</span> +<span style="color: #7a0874; font-weight: bold;">&#123;</span>size-in-kb<span style="color: #7a0874; font-weight: bold;">&#125;</span>k <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lh</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \; <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $9 &quot;: &quot; $5 }'</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lhS</span></pre></div></div><p>But there is a simpler, more efficient method to do this:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-xak</span> .<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-50</span></pre></div></div><p>But the best method involves a small Perl hack that shows a very neatly laid out listing of largest files:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-k</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf  (&quot;%6.1f\t%s\t%25s  %s\n&quot;,($1/(2**(10*$m))),((&quot;K&quot;,&quot;M&quot;,&quot;G&quot;,&quot;T&quot;,&quot;P&quot;)[$m]),&quot;*&quot;x (1.5*$l),$2);}'</span></pre></div></div>]]></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>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 4/8 queries in 0.002 seconds using disk: basic
Object Caching 781/787 objects using disk: basic

Served from: sniptools.com @ 2012-05-17 20:29:22 -->
