<?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>cenolan.com &#187; commands</title>
	<atom:link href="http://www.cenolan.com/tag/commands/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cenolan.com</link>
	<description>What you looking at?</description>
	<lastBuildDate>Sun, 14 Jun 2009 20:03:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Some useful linux commands</title>
		<link>http://www.cenolan.com/2008/06/some-useful-linux-commands/</link>
		<comments>http://www.cenolan.com/2008/06/some-useful-linux-commands/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 12:46:32 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[commands]]></category>

		<guid isPermaLink="false">http://www.cenolan.com/?p=15</guid>
		<description><![CDATA[A few useful linux commands and their explanations.

Recursively find in files...
find . -name \*.php -exec grep -inH discount {} \;
This finds all files ending with .php (-name \*.php) starting in the current path (.) and recurse through all subdirectories, then search (grep) case-insensitive (i) within those files ({}) for the word "discount" and outputs the [...]]]></description>
			<content:encoded><![CDATA[<p>A few useful linux commands and their explanations.</p>
<p><span id="more-15"></span></p>
<p><strong>Recursively find in files...</strong></p>
<pre><code>find . -name \*.php -exec grep -inH discount {} \;</code></pre>
<p>This finds all files ending with .php (-name \*.php) starting in the current path (.) and recurse through all subdirectories, then search (grep) case-insensitive (i) within those files ({}) for the word "discount" and outputs the filename (H), line number (n), and the line for any matches.</p>
<p><strong>Find all files older than 14 days...</strong></p>
<pre><code>find /home/*/Maildir/.Junk/cur -type f -mtime +14 -exec ls {} \;
find /home/*/Maildir/.Trash/cur -type f -mtime +14 -exec ls {} \;</code></pre>
<p>These two commands find files within system users' Maildir .Junk and .Trash folders that are older than 14 days. You could change the "-exec ls" to "-exec rm -rf" to remove the files.</p>
<p><strong>Find top 10 directories using disk space...</strong></p>
<pre><code>du -x --block-size=1024K | sort -nr | head -10</code></pre>
<p>This finds and lists the top 10 directories using disk space in the current path. Useful if you're trying to track down what is filling up your disk.</p>
<p><strong>Create and extracting a tar.gz archive of a directory...</strong></p>
<pre><code>tar -czvf (output filename) (directory to archive)</code></pre>
<p>e.g. tar -czvf myhome.tar.gz /home/myhome/</p>
<p>To extract this archive while preserving permissions, use:</p>
<pre><code>tar --preserve -zxvf (filename)</code></pre>
<p><strong>Change permissions of directories and files...</strong></p>
<pre><code>find . -type d -exec chmod 755 {} \;</code></pre>
<p>This finds all directories (indicated by the -type d) in the current path (.) and then chmods them to 755. If you wanted to recursively chmod files, you could issue this:</p>
<pre><code>find . -type f -exec chmod 644 {} \;</code></pre>
<p>This is really for my own reference, but you may find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cenolan.com/2008/06/some-useful-linux-commands/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
