<?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"
	>

<channel>
	<title>PinoyTux Weblog &#187; How-To&#8217;s</title>
	<atom:link href="http://www.pinoytux.com/category/how-tos/feed" rel="self" type="application/rss+xml" />
	<link>http://www.pinoytux.com</link>
	<description>Get Fresh News About Linux, Philippines and Everything in Between</description>
	<pubDate>Mon, 06 Oct 2008 13:21:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Tip: Perl Script to Archive Log Files</title>
		<link>http://www.pinoytux.com/how-tos/tip-perl-script-to-archive-log-files</link>
		<comments>http://www.pinoytux.com/how-tos/tip-perl-script-to-archive-log-files#comments</comments>
		<pubDate>Mon, 14 Jul 2008 11:27:46 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[archive]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[logs]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[rotate]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/?p=401</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/how-tos/tip-perl-script-to-archive-log-files';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Tip: Perl Script to Archive Log Files';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
This is a simple Perl script I wrote to search a given directory for *.log files, tag with the current date and archive them.

#!/usr/bin/perl
$DIR=&#8221;/var/www/html/sites/logs&#8221;;
$DATE=`date +%F`;
chomp $DATE;
@log = `/usr/bin/find $DIR -type f -name &#8220;*.log&#8221; `;
#print &#8220;\nRotating $DATE\n&#8221;;
foreach $log (@log) {
chomp $log;
$new_fn=&#8221;$log&#8221;.&#8221;-&#8221;.&#8221;$DATE&#8221;;
#print &#8220;$log $new_fn\n&#8221;;
`mv &#8220;$log&#8221; &#8220;$new_fn&#8221;`;
}
@raw=`/usr/bin/find $DIR -type f -name &#8220;*$DATE*&#8221;`;
foreach $raw (@raw) {
chomp $raw;
#print &#8220;$raw\n&#8221;;
`gzip -9 [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/how-tos/tip-perl-script-to-archive-log-files';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Tip: Perl Script to Archive Log Files';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>This is a simple Perl script I wrote to search a given directory for *.log files, tag with the current date and archive them.<br />
<span class="note"></p>
<p>#!/usr/bin/perl</p>
<p>$DIR=&#8221;/var/www/html/sites/logs&#8221;;<br />
$DATE=`date +%F`;<br />
chomp $DATE;</p>
<p>@log = `/usr/bin/find $DIR -type f -name &#8220;*.log&#8221; `;</p>
<p>#print &#8220;\nRotating $DATE\n&#8221;;</p>
<p>foreach $log (@log) {<br />
chomp $log;<br />
$new_fn=&#8221;$log&#8221;.&#8221;-&#8221;.&#8221;$DATE&#8221;;<br />
#print &#8220;$log $new_fn\n&#8221;;<br />
`mv &#8220;$log&#8221; &#8220;$new_fn&#8221;`;</p>
<p>}</p>
<p>@raw=`/usr/bin/find $DIR -type f -name &#8220;*$DATE*&#8221;`;</p>
<p>foreach $raw (@raw) {<br />
chomp $raw;<br />
#print &#8220;$raw\n&#8221;;<br />
`gzip -9 $raw`;</p>
<p>}</p>
<p></span></p>
<p>EDIT:</p>
<p>Modified version:</p>
<p><span class="note"></p>
<p>#!/usr/bin/perl</p>
<p>$DIR=&#8221;/var/www/html/sites/logs&#8221;;<br />
$DATE=`date +%F`;<br />
chomp $DATE;</p>
<p>@log = `/usr/bin/find $DIR -type f -name &#8220;*.log&#8221; `;</p>
<p>#print &#8220;\nRotating $DATE\n&#8221;;</p>
<p>foreach $log (@log) {<br />
chomp $log;<br />
$new_fn=&#8221;$log&#8221;.&#8221;-&#8221;.&#8221;$DATE&#8221;;<br />
#print &#8220;$log $new_fn\n&#8221;;<br />
`mv &#8220;$log&#8221; &#8220;$new_fn&#8221;`;<br />
`gzip -9 $new_fn`;</p>
<p>}</p>
<p></span><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/tip-using-dig-to-show-nameservers" title="Tip: Using dig to Show Nameservers">Tip: Using dig to Show Nameservers (0)</a></li>
<li><a href="http://www.pinoytux.com/tips/tip-perl-script-to-check-site-availability" title="Tip: Perl script to Check Site Availability">Tip: Perl script to Check Site Availability (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-hiding-files-inside-an-image-in-linux" title="Tip: Hiding Files Inside An Image in Linux">Tip: Hiding Files Inside An Image in Linux (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-script-for-checking-for-server-load" title="Tip: Script for Checking for Server Load">Tip: Script for Checking for Server Load (2)</a></li>
<li><a href="http://www.pinoytux.com/pinoytux/pinoytux-break" title="PinoyTux Break">PinoyTux Break (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/how-tos/tip-perl-script-to-archive-log-files/feed</wfw:commentRss>
		</item>
		<item>
		<title>10 Good Unix Habits</title>
		<link>http://www.pinoytux.com/linux/10-good-unix-habits</link>
		<comments>http://www.pinoytux.com/linux/10-good-unix-habits#comments</comments>
		<pubDate>Sat, 01 Mar 2008 21:28:47 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[cat]]></category>

		<category><![CDATA[command line. command]]></category>

		<category><![CDATA[grep]]></category>

		<category><![CDATA[howto]]></category>

		<category><![CDATA[ls]]></category>

		<category><![CDATA[mkdir]]></category>

		<category><![CDATA[unix]]></category>

		<category><![CDATA[xarg]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/10-good-unix-habits</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/10-good-unix-habits';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = '10 Good Unix Habits';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
Adopt 10 good habits that improve your UNIXÂ® command line efficiency &#8212; and break away from bad usage patterns in the process. This article takes you step-by-step through several good, but too often neglected, techniques for command-line operations. Learn about common errors and how to overcome them, so you can learn exactly why these UNIX [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/10-good-unix-habits';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = '10 Good Unix Habits';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>Adopt 10 good habits that improve your UNIXÂ® command line efficiency &#8212; and break away from bad usage patterns in the process. This article takes you step-by-step through several good, but too often neglected, techniques for command-line operations. Learn about common errors and how to overcome them, so you can learn exactly why these UNIX habits are worth picking up.</p>
<p>Introduction</p>
<p>When you use a system often, you tend to fall into set usage patterns. Sometimes, you do not start the habit of doing things in the best possible way. Sometimes, you even pick up bad practices that lead to clutter and clumsiness. One of the best ways to correct such inadequacies is to conscientiously pick up good habits that counteract them. This article suggests 10 UNIX command-line habits worth picking up &#8212; good habits that help you break many common usage foibles and make you more productive at the command line in the process. Each habit is described in more detail following the list of good habits.</p>
<p>Adopt 10 good habits</p>
<p>Ten good habits to adopt are:</p>
<p>1. Make directory trees in a single swipe.<br />
2. Change the path; do not move the archive.<br />
3. Combine your commands with control operators.<br />
4. Quote variables with caution.<br />
5. Use escape sequences to manage long input.<br />
6. Group your commands together in a list.<br />
7. Use xargs outside of find.<br />
8. Know when grep should do the counting &#8212; and when it should step aside.<br />
9. Match certain fields in output, not just lines.<br />
10. Stop piping cats.</p>
<p><strong>Make directory trees in a single swipe</strong></p>
<p>Listing 1 illustrates one of the most common bad UNIX habits around: defining directory trees one at a time.</p>
<p>Listing 1. Example of bad habit #1: Defining directory trees individually</p>
<p>~ $ mkdir tmp<br />
~ $ cd tmp<br />
~/tmp $ mkdir a<br />
~/tmp $ cd a<br />
~/tmp/a $ mkdir b<br />
~/tmp/a $ cd b<br />
~/tmp/a/b/ $ mkdir c<br />
~/tmp/a/b/ $ cd c<br />
~/tmp/a/b/c $</p>
<p>It is so much quicker to use the -p option to mkdir and make all parent directories along with their children in a single command. But even administrators who know about this option are still caught stepping through the subdirectories as they make them on the command line. It is worth your time to conscientiously pick up the good habit:</p>
<p>Listing 2. Example of good habit #1: Defining directory trees with one command</p>
<p>~ $ mkdir -p tmp/a/b/c</p>
<p>You can use this option to make entire complex directory trees, which are great to use inside scripts; not just simple hierarchies. For example:</p>
<p>Listing 3. Another example of good habit #1: Defining complex directory trees with one command</p>
<p>~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}</p>
<p>In the past, the only excuse to define directories individually was that your mkdir implementation did not support this option, but this is no longer true on most systems. IBM, AIXÂ®, mkdir, GNU mkdir, and others that conform to the Single UNIX Specification now have this option.</p>
<p>For the few systems that still lack the capability, use the mkdirhier script (see Resources), which is a wrapper for mkdir that does the same function:</p>
<p>~ $ mkdirhier project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}</p>
<p><strong>Change the path; do not move the archive</strong></p>
<p>Another bad usage pattern is moving a .tar archive file to a certain directory because it happens to be the directory you want to extract it in. You never need to do this. You can unpack any .tar archive file into any directory you like &#8212; that is what the -C option is for. Use the -C option when unpacking an archive file to specify the directory to unpack it in:</p>
<p>Listing 4. Example of good habit #2: Using option -C to unpack a .tar archive file</p>
<p>~ $ tar xvf -C tmp/a/b/c newarc.tar.gz</p>
<p>Making a habit of using -C is preferable to moving the archive file to where you want to unpack it, changing to that directory, and only then extracting its contents &#8212; especially if the archive file belongs somewhere else.</p>
<p><strong>Combine your commands with control operators</strong></p>
<p>You probably already know that in most shells, you can combine commands on a single command line by placing a semicolon ( ; ) between them. The semicolon is a shell control operator, and while it is useful for stringing together multiple discrete commands on a single command line, it does not work for everything. For example, suppose you use a semicolon to combine two commands in which the proper execution of the second command depends entirely upon the successful completion of the first. If the first command does not exit as you expected, the second command still runs &#8212; and fails. Instead, use more appropriate control operators (some are described in this article). As long as your shell supports them, they are worth getting into the habit of using them.</p>
<p>Run a command only if another command returns a zero exit status</p>
<p>Use the &amp;&amp; control operator to combine two commands so that the second is run only if the first command returns a zero exit status. In other words, if the first command runs successfully, the second command runs. If the first command fails, the second command does not run at all. For example:</p>
<p>Listing 5. Example of good habit #3: Combining commands with control operators</p>
<p>~ $ cd tmp/a/b/c &amp;&amp; tar xvf ~/archive.tar</p>
<p>In this example, the contents of the archive are extracted into the ~/tmp/a/b/c directory unless that directory does not exist. If the directory does not exist, the tar command does not run, so nothing is extracted.<br />
<strong>Run a command only if another command returns a non-zero exit status</strong></p>
<p>Similarly, the || control operator separates two commands and runs the second command only if the first command returns a non-zero exit status. In other words, if the first command is successful, the second command does not run. If the first command fails, the second command does run. This operator is often used when testing for whether a given directory exists and, if not, it creates one:</p>
<p>Listing 6. Another example of good habit #3: Combining commands with control operators</p>
<p>~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c</p>
<p>You can also combine the control operators described in this section. Each works on the last command run:</p>
<p>Listing 7. A combined example of good habit #3: Combining commands with control operators</p>
<p>~ $ cd tmp/a/b/c || mkdir -p tmp/a/b/c &amp;&amp; tar xvf -C tmp/a/b/c ~/archive.tar</p>
<p><strong>Quote variables with caution</strong></p>
<p>Always be careful with shell expansion and variable names. It is generally a good idea to enclose variable calls in double quotation marks, unless you have a good reason not to. Similarly, if you are directly following a variable name with alphanumeric text, be sure also to enclose the variable name in curly braces ({}) to distinguish it from the surrounding text. Otherwise, the shell interprets the trailing text as part of your variable name &#8212; and most likely returns a null value. Listing 8 provides examples of various quotation and non-quotation of variables and their effects.</p>
<p>Listing 8. Example of good habit #4: Quoting (and not quoting) a variable</p>
<p>~ $ ls tmp/<br />
a b<br />
~ $ VAR=&#8221;tmp/*&#8221;<br />
~ $ echo $VAR<br />
tmp/a tmp/b<br />
~ $ echo &#8220;$VAR&#8221;<br />
tmp/*<br />
~ $ echo $VARa</p>
<p>~ $ echo &#8220;$VARa&#8221;</p>
<p>~ $ echo &#8220;${VAR}a&#8221;<br />
tmp/*a<br />
~ $ echo ${VAR}a<br />
tmp/a<br />
~ $</p>
<p><strong>Use escape sequences to manage long input</strong></p>
<p>You have probably seen code examples in which a backslash (\) continues a long line over to the next line, and you know that most shells treat what you type over successive lines joined by a backslash as one long line. However, you might not take advantage of this function on the command line as often as you can. The backslash is especially handy if your terminal does not handle multi-line wrapping properly or when your command line is smaller than usual (such as when you have a long path on the prompt). The backslash is also useful for making sense of long input lines as you type them, as in the following example:</p>
<p>Listing 9. Example of good habit #5: Using a backslash for long input</p>
<p>~ $ cd tmp/a/b/c || \<br />
&gt; mkdir -p tmp/a/b/c &amp;&amp; \<br />
&gt; tar xvf -C tmp/a/b/c ~/archive.tar</p>
<p>Alternatively, the following configuration also works:</p>
<p>Listing 10. Alternative example of good habit #5: Using a backslash for long input</p>
<p>~ $ cd tmp/a/b/c \<br />
&gt;                 || \<br />
&gt; mkdir -p tmp/a/b/c \<br />
&gt;                    &amp;&amp; \<br />
&gt; tar xvf -C tmp/a/b/c ~/archive.tar</p>
<p>However you divide an input line over multiple lines, the shell always treats it as one continuous line, because it always strips out all the backslashes and extra spaces.</p>
<p>Note: In most shells, when you press the up arrow key, the entire multi-line entry is redrawn on a single, long input line.</p>
<p><strong>Group your commands together in a list</strong></p>
<p>Most shells have ways to group a set of commands together in a list so that you can pass their sum-total output down a pipeline or otherwise redirect any or all of its streams to the same place. You can generally do this by running a list of commands in a subshell or by running a list of commands in the current shell.</p>
<p>Run a list of commands in a subshell</p>
<p>Use parentheses to enclose a list of commands in a single group. Doing so runs the commands in a new subshell and allows you to redirect or otherwise collect the output of the whole, as in the following example:</p>
<p>Listing 11. Example of good habit #6: Running a list of commands in a subshell</p>
<p>~ $ ( cd tmp/a/b/c/ || mkdir -p tmp/a/b/c &amp;&amp; \<br />
&gt; VAR=$PWD; cd ~; tar xvf -C $VAR archive.tar ) \<br />
&gt; | mailx admin -S &#8220;Archive contents&#8221;</p>
<p>In this example, the content of the archive is extracted in the tmp/a/b/c/ directory while the output of the grouped commands, including a list of extracted files, is mailed to the admin address.</p>
<p>The use of a subshell is preferable in cases when you are redefining environment variables in your list of commands and you do not want those definitions to apply to your current shell.</p>
<p>Run a list of commands in the current shell</p>
<p>Use curly braces ({}) to enclose a list of commands to run in the current shell. Make sure you include spaces between the braces and the actual commands, or the shell might not interpret the braces correctly. Also, make sure that the final command in your list ends with a semicolon, as in the following example:</p>
<p>Listing 12. Another example of good habit #6: Running a list of commands in the current shell</p>
<p>~ $ { cp ${VAR}a . &amp;&amp; chown -R guest.guest a &amp;&amp; \<br />
&gt; tar cvf newarchive.tar a; } | mailx admin -S &#8220;New archive&#8221;</p>
<p><strong>Use xargs outside of find</strong></p>
<p>Use the xargs tool as a filter for making good use of output culled from the find command. The general precept is that a find run provides a list of files that match some criteria. This list is passed on to xargs, which then runs some other useful command with that list of files as arguments, as in the following example:</p>
<p>Listing 13. Example of the classic use of the xargs tool</p>
<p>~ $ find some-file-criteria some-file-path | \<br />
&gt; xargs some-great-command-that-needs-filename-arguments</p>
<p>However, do not think of xargs as just a helper for find; it is one of those underutilized tools that, when you get into the habit of using it, you want to try on everything, including the following uses.</p>
<p>Passing a space-delimited list</p>
<p>In its simplest invocation, xargs is like a filter that takes as input a list (with each member on a single line). The tool puts those members on a single space-delimited line:</p>
<p>Listing 14. Example of output from the xargs tool</p>
<p>~ $ xargs<br />
a<br />
b<br />
c<br />
Control-D<br />
a b c<br />
~ $</p>
<p>You can send the output of any tool that outputs file names through xargs to get a list of arguments for some other tool that takes file names as an argument, as in the following example:</p>
<p>Listing 15. Example of using of the xargs tool</p>
<p>~/tmp $ ls -1 | xargs<br />
December_Report.pdf README a archive.tar mkdirhier.sh<br />
~/tmp $ ls -1 | xargs file<br />
December_Report.pdf: PDF document, version 1.3<br />
README: ASCII text<br />
a: directory<br />
archive.tar: POSIX tar archive<br />
mkdirhier.sh: Bourne shell script text executable<br />
~/tmp $</p>
<p>The xargs command is useful for more than passing file names. Use it any time you need to filter text into a single line:</p>
<p>Listing 16. Example of good habit #7: Using the xargs tool to filter text into a single line</p>
<p>~/tmp $ ls -l | xargs<br />
-rw-r&#8211;r&#8211; 7 joe joe 12043 Jan 27 20:36 December_Report.pdf -rw-r&#8211;r&#8211; 1 \<br />
root root 238 Dec 03 08:19 README drwxr-xr-x 38 joe joe 354082 Nov 02 \<br />
16:07 a -rw-r&#8211;r&#8211; 3 joe joe 5096 Dec 14 14:26 archive.tar -rwxr-xr-x 1 \<br />
joe joe 3239 Sep 30 12:40 mkdirhier.sh<br />
~/tmp $</p>
<p>Be cautious using xargs</p>
<p>Technically, a rare situation occurs in which you could get into trouble using xargs. By default, the end-of-file string is an underscore (_); if that character is sent as a single input argument, everything after it is ignored. As a precaution against this, use the -e flag, which, without arguments, turns off the end-of-file string completely.</p>
<p><strong> Know when grep should do the counting &#8212; and when it should step aside</strong></p>
<p>Avoid piping a grep to wc -l in order to count the number of lines of output. The -c option to grep gives a count of lines that match the specified pattern and is generally faster than a pipe to wc, as in the following example:</p>
<p>Listing 17. Example of good habit #8: Counting lines with and without grep</p>
<p>~ $ time grep and tmp/a/longfile.txt | wc -l<br />
2811</p>
<p>real    0m0.097s<br />
user    0m0.006s<br />
sys     0m0.032s<br />
~ $ time grep -c and tmp/a/longfile.txt<br />
2811</p>
<p>real    0m0.013s<br />
user    0m0.006s<br />
sys     0m0.005s<br />
~ $</p>
<p>An addition to the speed factor, the -c option is also a better way to do the counting. With multiple files, grep with the -c option returns a separate count for each file, one on each line, whereas a pipe to wc gives a total count for all files combined.</p>
<p>However, regardless of speed considerations, this example showcases another common error to avoid. These counting methods only give counts of the number of lines containing matched patterns &#8212; and if that is what you are looking for, that is great. But in cases where lines can have multiple instances of a particular pattern, these methods do not give you a true count of the actual number of instances matched. To count the number of instances, use wc to count, after all. First, run a grep command with the -o option, if your version supports it. This option outputs only the matched pattern, one on each line, and not the line itself. But you cannot use it in conjunction with the -c option, so use wc -l to count the lines, as in the following example:</p>
<p>Listing 18. Example of good habit #8: Counting pattern instances with grep</p>
<p>~ $ grep -o and tmp/a/longfile.txt | wc -l<br />
3402<br />
~ $</p>
<p>In this case, a call to wc is slightly faster than a second call to grep with a dummy pattern put in to match and count each line (such as grep -c).</p>
<p><strong>Match certain fields in output, not just lines</strong></p>
<p>A tool like awk is preferable to grep when you want to match the pattern in only a specific field in the lines of output and not just anywhere in the lines.</p>
<p>The following simplified example shows how to list only those files modified in December:</p>
<p>Listing 19. Example of bad habit #9: Using grep to find patterns in specific fields</p>
<p>~/tmp $ ls -l /tmp/a/b/c | grep Dec<br />
-rw-r&#8211;r&#8211;  7 joe joe  12043 Jan 27 20:36 December_Report.pdf<br />
-rw-r&#8211;r&#8211;  1 root root  238 Dec 03 08:19 README<br />
-rw-r&#8211;r&#8211;  3 joe joe   5096 Dec 14 14:26 archive.tar<br />
~/tmp $</p>
<p>In this example, grep filters the lines, outputting all files with Dec in their modification dates as well as in their names. Therefore, a file such as December_Report.pdf is matched, even if it has not been modified since January. This probably is not what you want. To match a pattern in a particular field, it is better to use awk, where a relational operator matches the exact field, as in the following example:</p>
<p>Listing 20. Example of good habit #9: Using awk to find patterns in specific fields</p>
<p>~/tmp $ ls -l | awk &#8216;$6 == &#8220;Dec&#8221;&#8216;<br />
-rw-r&#8211;r&#8211;  3 joe joe   5096 Dec 14 14:26 archive.tar<br />
-rw-r&#8211;r&#8211;  1 root root  238 Dec 03 08:19 README<br />
~/tmp $</p>
<p><strong><br />
Stop piping cats</strong></p>
<p>A basic-but-common grep usage error involves piping the output of cat to grep to search the contents of a single file. This is absolutely unnecessary and a waste of time, because tools such as grep take file names as arguments. You simply do not need to use cat in this situation at all, as in the following example:</p>
<p>Listing 21. Example of good and bad habit #10: Using grep with and without cat</p>
<p>~ $ time cat tmp/a/longfile.txt | grep and<br />
2811</p>
<p>real    0m0.015s<br />
user    0m0.003s<br />
sys     0m0.013s<br />
~ $ time grep and tmp/a/longfile.txt<br />
2811</p>
<p>real    0m0.010s<br />
user    0m0.006s<br />
sys     0m0.004s<br />
~ $</p>
<p>This mistake applies to many tools. Because most tools take standard input as an argument using a hyphen (-), even the argument for using cat to intersperse multiple files with stdin is often not valid. It is really only necessary to concatenate first before a pipe when you use cat with one of its several filtering options.</p>
<p>Source: <a href="http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html?ca=dgr-jw64tenunixtips&amp;S_TACT=105AGX59&amp;S_CMP=GR#ten">ibm.com</a><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/tip-how-to-use-awk-with-netstat" title="Tip: How to Use Awk with Netstat">Tip: How to Use Awk with Netstat (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-how-to-schedule-tasks" title="Tip: How to Schedule Tasks">Tip: How to Schedule Tasks (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/vista-vs-mac-vs-linux-on-latest-trends" title="Vista vs Mac vs Linux on Latest Trends">Vista vs Mac vs Linux on Latest Trends (3)</a></li>
<li><a href="http://www.pinoytux.com/linux/more-unix-jokes" title="More Unix Jokes">More Unix Jokes (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/unix-is-the-devils-os" title="Unix is the Devil&#8217;s OS">Unix is the Devil&#8217;s OS (3)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/10-good-unix-habits/feed</wfw:commentRss>
		</item>
		<item>
		<title>Basic Apache and PHP Install from Source Part 1</title>
		<link>http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1</link>
		<comments>http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1#comments</comments>
		<pubDate>Sat, 16 Feb 2008 17:05:28 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[LAMP]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[compile]]></category>

		<category><![CDATA[configure]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[install]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[source]]></category>

		<category><![CDATA[tarball]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Basic Apache and PHP Install from Source Part 1';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
Ok, I may not be a guru when it comes to installing and configuring Apache and PHP but here is a sample of how I install Apache and PHP on Fedora or Red Hat boxes fresh from source. Pardon my newbie-sh technique but here it goes:
Installing Apache:
 # cd /usr/src
- Download the http package
# wget [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Basic Apache and PHP Install from Source Part 1';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>Ok, I may not be a guru when it comes to installing and configuring Apache and PHP but here is a sample of how I install Apache and PHP on Fedora or Red Hat boxes fresh from source. Pardon my newbie-sh technique but here it goes:</p>
<p>Installing Apache:</p>
<blockquote><p><em> # cd /usr/src</em></p>
<p>- Download the http package</p>
<p><em># wget http://www.apache.org/dist/httpd/httpd-2.2.8.tar.gz</em> (change this to a mirror available to you)</p>
<p>- Extract the contents of the package</p>
<p><em># tar zxf  httpd-2.2.8.tar.gz</em></p>
<p><em># cd  httpd-2.2.8</em></p>
<p>- Configure the source depending on your requirements. At this point, configure may fail because of unsatisfied dependencies. Check what the error is and you can download the required package using yum or up2date.  If you do not need SSL module for secure page (https), you can leave out the  &#8211;enable-ssl part.</p>
<p><em>#  ./configure &#8211;prefix=/usr/local/apache &#8211;with-mpm=prefork  &#8211;enable-ssl &#8211;with-ssl=/usr/local/ssl &#8211;enable-log_config=static &#8211;enable-vhost_alias=static &#8211;enable-includes=static &#8211;enable-dir=static &#8211;enable-access=static &#8211;enable-mime=static &#8211;enable-mime_magic=static &#8211;enable-mods-shared=most &#8211;enable-cache=shared &#8211;enable-disk_cache=shared &#8211;enable-file_cache=shared &#8211;enable-mem_cache=shared</em></p>
<p>Tip: To check what these directives mean, you can issue ./configure &#8211;help .</p>
<p><em># make</em></p>
<p>- If everything goes well, your fresh http will be installed in /usr/local/apache with the following command:</p>
<p><em># make install</em></p></blockquote>
<p>Installing PHP:</p>
<blockquote><p><em># cd /usr/src</em></p>
<p><em>#  wget http://www.php.net/get/php-5.2.5.tar.gz/from/us.php.net/mirror </em>(change this to a mirror available to you)</p>
<p><em># tar zxf  php-5.2.5.tar.gz</em></p>
<p><em># cd  php-5.2.5</em></p>
<p>- Same with http. The configure part will depend on your requirement.</p>
<p><em>#  ./configure &#8211;with-config-file-path=/usr/local/apache/conf &#8211;with-apxs2=/usr/local/apache/bin/apxs &#8211;enable-calendar &#8211;enable-ftp &#8211;without-pgsql &#8211;with-zlib &#8211;with-openssl=/usr/local/ssl &#8211;with-mysql &#8211;with-mhash &#8211;with-mcrypt &#8211;with-curl &#8211;disable-cgi &#8211;enable-mbstring &#8211;enable-soap &#8211;with-bz2 &#8211;enable-sockets &#8211;enable-zip  </em>(If configure fails, read the error why the it failed and install first the dependencies then run again the configure.)</p>
<p><em># make</em></p>
<p><em># make test</em></p>
<p><em># make install</em></p>
<p>To start the httpd service, execute</p>
<p><em># /usr/local/apache/bin/apachectl start</em></p>
<p>You can create a symlink to your /etc/init.d so you can start apache by typing /etc/init.d/httpd start</p>
<p><em># ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd</em></p></blockquote>
<p>There you have it. You have successfully installed Apache with PHP on your webserver. I will continue this little howto with how to configure your webserver.<br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/tip-testing-your-phpmysql-connection" title="Tip: Testing Your PHP/MySQL Connection">Tip: Testing Your PHP/MySQL Connection (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-no-space-left-on-device-error" title="Tip: No Space Left on Device Error">Tip: No Space Left on Device Error (0)</a></li>
<li><a href="http://www.pinoytux.com/tips/tip-simple-ssl-certificate-scanner" title="Tip: Simple SSL Certificate Scanner">Tip: Simple SSL Certificate Scanner (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/how-to-create-self-signed-certificate" title="How To Create Self Signed Certificate">How To Create Self Signed Certificate (2)</a></li>
<li><a href="http://www.pinoytux.com/others/why-should-we-take-trainings" title="Why Should We Take Trainings?">Why Should We Take Trainings? (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/basic-apache-and-php-install-from-source-part-1/feed</wfw:commentRss>
		</item>
		<item>
		<title>Ultimate Linux Cheat Sheets</title>
		<link>http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets</link>
		<comments>http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets#comments</comments>
		<pubDate>Sat, 16 Feb 2008 14:52:04 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[commands]]></category>

		<category><![CDATA[guide]]></category>

		<category><![CDATA[help]]></category>

		<category><![CDATA[list]]></category>

		<category><![CDATA[newbie]]></category>

		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Ultimate Linux Cheat Sheets';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
If you are in dire need of SOS because of that little command that is stuck at the tip of your tongue or you are having a huge case of memory gap, fret not. Here is a quick link to a massive list of Unix/Linux cheat sheets. One link points to http://www.tuxfiles.org/linuxhelp/linuxcommands.html which profiles a [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Ultimate Linux Cheat Sheets';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>If you are in dire need of SOS because of that little command that is stuck at the tip of your tongue or you are having a huge case of memory gap, fret not. <a href="http://www.scottklarr.com/topic/115/linux-unix-cheat-sheets---the-ultimate-collection/" title="linux command" target="_blank">Here is a quick link</a> to a massive list of Unix/Linux cheat sheets. One link points to <a href="http://www.tuxfiles.org/linuxhelp/linuxcommands.html" target="_blank">http://www.tuxfiles.org/linuxhelp/linuxcommands.html</a> which profiles a list of Linux commands that are newbie friendly.</p>
<p>List too long for you? You can try the Linux command <em>apropos</em> &lt;keyword&gt;. This command searches the whatis database for strings that matches your keyword. Let&#8217;s say you forgot the command to copy a file (uh-oh) so we go like this:</p>
<blockquote><p># apropos copy</p>
<p># cp                   (1)  - copy files and directories<br />
# cp                   (1p)  - copy files</p></blockquote>
<p>Hey there it is! <img src='http://www.pinoytux.com/smilies/yahoo_wink.gif' alt='&#59;&#41;' class='wp-smiley' width='18' height='18' title='&#59;&#41;' /> So we got cp. You can now use man command to check if cp is really what you are looking for.  Google is also a neat tool if internet access is readily available. <img src='http://www.pinoytux.com/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/10-things-you-didnt-know-you-could-do-in-ubuntu" title="10 Things You Didn&#8217;t Know You Could Do In Ubuntu">10 Things You Didn&#8217;t Know You Could Do In Ubuntu (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-prevent-ssh-session-from-disconnecting" title="Tip: Prevent SSH Session from Disconnecting">Tip: Prevent SSH Session from Disconnecting (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-resume-session-with-screen" title="Tip: Resume Session with screen">Tip: Resume Session with screen (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/more-unix-jokes" title="More Unix Jokes">More Unix Jokes (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-how-to-schedule-tasks" title="Tip: How to Schedule Tasks">Tip: How to Schedule Tasks (2)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/ultimate-linux-cheat-sheets/feed</wfw:commentRss>
		</item>
		<item>
		<title>Save Your Files With FlyBack</title>
		<link>http://www.pinoytux.com/linux/save-your-files-with-flyback</link>
		<comments>http://www.pinoytux.com/linux/save-your-files-with-flyback#comments</comments>
		<pubDate>Sun, 20 Jan 2008 20:48:34 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[News]]></category>

		<category><![CDATA[apple]]></category>

		<category><![CDATA[backup]]></category>

		<category><![CDATA[flyback]]></category>

		<category><![CDATA[rsync]]></category>

		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/save-your-files-with-flyback</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/save-your-files-with-flyback';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Save Your Files With FlyBack';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
Still looking for a backup program for your Linux files? Finally, FlyBack is available to Linux users to backup our stuff and save our a$$es from humiliating and headache-producing data loss.
FlyBack is a snapshot-based backup tool based on rsync It creates successive backup directories mirroring the files you wish to backup, but hard-links unchanged files [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/save-your-files-with-flyback';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Save Your Files With FlyBack';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>Still looking for a backup program for your Linux files? Finally, FlyBack is available to Linux users to backup our stuff and save our a$$es from humiliating and headache-producing data loss.</p>
<p><a href="http://code.google.com/p/flyback/" target="_blank">FlyBack</a> is a snapshot-based backup tool based on <a href="http://en.wikipedia.org/wiki/Rsync" rel="nofollow">rsync</a> It creates successive backup directories mirroring the files you wish to backup, but hard-links unchanged files to the previous backup. This prevents wasting disk space while providing you with full access to all your files without any sort of recovery program. If your machine crashes, just move your external drive to your new machine and copy the latest backup using whatever file browser you normally use.</p>
<p>Bernazâ€™s Weblog writes about FlyBack and you can continue reading <a href="http://bernaz.wordpress.com/2008/01/19/flyback-a-time-machine-backup-utility-for-linux/" target="_blank">here</a>.<br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/mythbusters-7-tech-headaches-and-how-to-fix-them" title="MythBusters: 7 Tech Headaches - and How to Fix Them">MythBusters: 7 Tech Headaches - and How to Fix Them (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/torvalds-microsoft-is-bluffing-on-patents" title="Torvalds: Microsoft is bluffing on patents">Torvalds: Microsoft is bluffing on patents (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/the-most-hated-company-in-pc-industry" title="The Most Hated Company In PC Industry">The Most Hated Company In PC Industry (2)</a></li>
<li><a href="http://www.pinoytux.com/pinoytux/pinoytux-break" title="PinoyTux Break">PinoyTux Break (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/pinoytux-reaches-30k-visitors" title="PinoyTux Reaches 30K Visitors!">PinoyTux Reaches 30K Visitors! (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/save-your-files-with-flyback/feed</wfw:commentRss>
		</item>
		<item>
		<title>Howto: Install yum On RHEL 4</title>
		<link>http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4</link>
		<comments>http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4#comments</comments>
		<pubDate>Wed, 02 Jan 2008 16:25:28 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Troubleshooting]]></category>

		<category><![CDATA[centos]]></category>

		<category><![CDATA[package]]></category>

		<category><![CDATA[repository]]></category>

		<category><![CDATA[rhel]]></category>

		<category><![CDATA[rpm]]></category>

		<category><![CDATA[up2date]]></category>

		<category><![CDATA[update]]></category>

		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Howto: Install yum On RHEL 4';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
There are more than a couple of ways of updating Red Hat Enterprise Linux (RHEL) packages on your machine. One is by using up2date, the default package updater of RHEL systems. Unlike Fedora and CentOS which uses yum, up2date requires you to be registered to Red Hat Network (RHN) to be able to download or [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Howto: Install yum On RHEL 4';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>There are more than a couple of ways of updating Red Hat Enterprise Linux (RHEL) packages on your machine. One is by using up2date, the default package updater of RHEL systems. Unlike Fedora and CentOS which uses yum, up2date requires you to be registered to Red Hat Network (RHN) to be able to download or update your packages from the RHN repository.</p>
<p>Now, what if you need to install a certain package that is not available in your current repository by up2date? Or what if the package in the repository wreaks havoc in your system?  Maybe you should try using yum to install or update rpm packages.</p>
<p>But&#8230; but&#8230; but how can I install yum in my RHEL machine?, you may ask. It&#8217;s actually very simple.</p>
<p>I got this tip from <a href="http://babarhaq.blogspot.com/2006/01/installing-yum-on-rhel-3.html" target="_blank">Babar Haq&#8217;s Blog</a> with a little modification since I am using RHEL 4.<a href="http://babarhaq.blogspot.com/2006/01/installing-yum-on-rhel-3.html" target="_blank"><br />
</a></p>
<p>1. Download yum by using wget</p>
<p># wget <a href="http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.8-1.noarch.rpm" target="_blank">http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.8-1.noarch.rpm</a></p>
<p>2. Install the rpm</p>
<p># rpm -ivh yum-2.0.8-1.noarch.rpm</p>
<p>3. Configure /etc/yum.conf to use compatible repository</p>
<p><span style="font-family: courier new">[main]<br />
</span><span style="font-family: courier new">cachedir=/var/cache/yum<br />
</span><span style="font-family: courier new">debuglevel=2<br />
</span><span style="font-family: courier new">logfile=/var/log/yum.log<br />
</span><span style="font-family: courier new">pkgpolicy=newest<br />
</span><span style="font-family: courier new">distroverpkg=redhat-release<br />
</span><span style="font-family: courier new">tolerant=1<br />
</span><span style="font-family: courier new">exactarch=1</span></p>
<p><span style="font-family: courier new"></span><span style="font-family: courier new">[base]</span><br />
<span style="font-family: courier new">name=CentOS-$releasever - Base<br />
</span><span style="font-family: courier new">baseurl=http://mirror.centos.org/centos/4/os/i386/<br />
</span><span style="font-family: courier new">gpgcheck=1</span></p>
<p><span style="font-family: courier new">[updates]<br />
</span><span style="font-family: courier new">name=Red Hat Linux $releasever - Updates<br />
</span><span style="font-family: courier new">baseurl=http://mirror.centos.org/centos/4/updates/i386/<br />
</span><span style="font-family: courier new">gpgcheck=1</span></p>
<p>4. Download and install the CentOS GPG Key</p>
<p># wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4</p>
<p># rpm &#8211;import RPM-GPG-KEY-CentOS-4</p>
<p>5. Test yum to see if it works (I tested by running full update on my machine)</p>
<p># yum update</p>
<p>*Note: This will update ALL installed packages in your machine. If you do not want to do this, cancel the process or skip this step.</p>
<p>If you reach step 5 without encountering any errors, it means that yum is successfully updating your machine with the latest versions available in the repo. <img src='http://www.pinoytux.com/smilies/yahoo_wave.gif' alt='&#58;&#45;&#104;' class='wp-smiley' width='28' height='18' title='&#58;&#45;&#104;' /></p>
<p>This worked perfectly fine for me. If you experienced any errors, post a message and I will try to help you out <img src='http://www.pinoytux.com/smilies/yahoo_wink.gif' alt='&#59;&#41;' class='wp-smiley' width='18' height='18' title='&#59;&#41;' /><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/tip-testing-your-phpmysql-connection" title="Tip: Testing Your PHP/MySQL Connection">Tip: Testing Your PHP/MySQL Connection (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/nasa-uses-linux-a-lot" title="NASA Uses Linux - A Lot!">NASA Uses Linux - A Lot! (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/latest-stable-version-of-linux-kernel-released" title="Latest Stable Version of Linux Kernel Released">Latest Stable Version of Linux Kernel Released (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/fedora-8-code-name-werewolf" title="Fedora 8: Code Name Werewolf">Fedora 8: Code Name Werewolf (0)</a></li>
<li><a href="http://www.pinoytux.com/pinoytux/pinoytux-break" title="PinoyTux Break">PinoyTux Break (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/howto-install-yum-on-rhel-4/feed</wfw:commentRss>
		</item>
		<item>
		<title>Setting Up Remote Connection Using FreeNX</title>
		<link>http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx</link>
		<comments>http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx#comments</comments>
		<pubDate>Sun, 23 Dec 2007 04:13:59 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[fedora]]></category>

		<category><![CDATA[freenx]]></category>

		<category><![CDATA[nomachine]]></category>

		<category><![CDATA[remote access]]></category>

		<category><![CDATA[remote desktop]]></category>

		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Setting Up Remote Connection Using FreeNX';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
Want to remote access your Linux desktop? Or access your workstation similar the way Remote Desktop does it?
While Linux offers a wide array of ways to connect to a remote computer, some people still prefer to connect the traditional way by using ssh. Not only it is secure, it is sure is a fast way [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Setting Up Remote Connection Using FreeNX';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>Want to remote access your Linux desktop? Or access your workstation similar the way Remote Desktop does it?</p>
<p>While Linux offers a wide array of ways to connect to a remote computer, some people still prefer to connect the traditional way by using ssh. Not only it is secure, it is sure is a fast way of connecting a remote terminal. However, if you want to remotely access your Linux desktop, freeNX can do the job along with NoMachine client.</p>
<p>What is freeNX?</p>
<p>From the official website:</p>
<blockquote><p><em>NX is an exciting new technology for remote display. It provides </em><em>near local speed application responsiveness over high latency, low bandwidth links. The core libraries for NX are provided by <a href="http://www.nomachine.com/">NoMachine</a> under the GPL. FreeNX is a GPL implementation of the NX Server.</em></p></blockquote>
<p>Linux is to <a href="http://freenx.berlios.de/download.php" title="freenx" target="_blank">freeNX</a> as Windows is to Remote Desktop. I decided to use freeNX to access my Linux desktop in office if ever I need to.</p>
<p>Setting up freeNx:</p>
<p>freeNX is available for download in <a href="http://developer.berlios.de/project/showfiles.php?group_id=2978" target="_blank" title="freenx">source tarballs</a> and <a href="http://freenx.berlios.de/download.php" target="_blank" title="freenx">distribution packages</a>.I personally use the distribution package for <a href="http://fedoranews.org/contributors/rick_stout/freenx/" target="_blank" title="freenx fedora">Fedora/Redhat which is available via yum.</a> I am using Fedora 7 so in this case, I will use the steps of setting up freeNX for my distro.</p>
<blockquote>
<pre class="screen"># Make sure you are up-to-date
yum update

# Install FreeNX and all dependencies
yum install freenx

#SERVER SETUP IS DONE! The RPM takes care of the required setup.</pre>
</blockquote>
<p>That&#8217;s it! However, if you are using Fedora versions older than Fedora 5, there is a special how-to for freeNX setup that you might want to <a href="http://fedoranews.org/contributors/rick_stout/freenx/" target="_blank" title="freenx">check</a>.</p>
<p>Install NoMachine client:</p>
<p>Remote connection also needs a client which is the program you use that connects to your remote server, in this case the freeNX server. In this tutorial, we will be using NoMachine as the client. You can download the <a href="http://www.nomachine.com/download.php" title="nomachine" target="_blank">NoMachine client here</a>. In my example, I will be using Windows XP for my workstation client so I have to download and install the NoMachine client for Windows. Install the client and run the NX Client for Windows. This will open up a dialog box for your client configuration. Here are the steps you need to setup your client:</p>
<ul>
<li>Â When the dialog box opens, enter the Session and Host name for your connection. Session name is the name of your connection and your settings will be saved under this name. Host name is the ip address or hostname and port of the remote machine. The default port is 22 (SSH). Click Next.</li>
<li>In the next dialog box, select Unix and choose which type of window manager you want to use and the resolution. In this case I user KDE and Available Area for my resolution. Check the box for Enable SSL encryption. Click Next.</li>
<li>If you want to put a shortcut to this connection on your desktop, put a tick on the Create shortcut on desktop checkbox and click Finish.</li>
</ul>
<p>If you want to open the session, double click the shortcut on your Desktop and type in your username and password for this session. You will be connecting now to your freeNX server and you will see your Available sessions box. Select New to create a new session to begin connecting to your remote desktop. Wait for the desktop to load and voila! You are now connected to your remote desktop.<br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/linux/vmware-failed-to-open-sound-device" title="VMware: Failed to Open Sound Device">VMware: Failed to Open Sound Device (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/linux-evolution" title="Linux Evolution">Linux Evolution (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-how-change-default-os-in-dual-boot-ubuntu" title="Tip: How Change Default OS in Dual Boot Ubuntu">Tip: How Change Default OS in Dual Boot Ubuntu (5)</a></li>
<li><a href="http://www.pinoytux.com/microsoft/unpopular-but-useful-windows-shortcut-keys" title="Unpopular But Useful Windows Shortcut Keys">Unpopular But Useful Windows Shortcut Keys (2)</a></li>
<li><a href="http://www.pinoytux.com/linux/linux-file-directory-structure" title="Linux File Directory Structure">Linux File Directory Structure (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/setting-up-remote-connection-using-freenx/feed</wfw:commentRss>
		</item>
		<item>
		<title>Partitioning Disks with fdisk</title>
		<link>http://www.pinoytux.com/linux/partitioning-disks-with-fdisk</link>
		<comments>http://www.pinoytux.com/linux/partitioning-disks-with-fdisk#comments</comments>
		<pubDate>Sat, 04 Aug 2007 11:23:47 +0000</pubDate>
		<dc:creator>Rai</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://pinoytux.com/linux/howto/partitioning-disks-with-fdisk</guid>
		<description><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/partitioning-disks-with-fdisk';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Partitioning Disks with fdisk';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
Every computer owner will come across the street road called Partitioning. Partitioning simply means dividing your physical hard drive into 2 or more logical (or virtual) drives. In Linux there are different kinds of applications that can help you do this, and one is fdisk.
For this example, I will demonstrate how to use fdisk.
The basic [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;"">
<div>
<script type="text/javascript">
digg_url = 'http://www.pinoytux.com/linux/partitioning-disks-with-fdisk';
digg_bgcolor = '#FFFFFF';
digg_skin = '';
digg_window = 'new';
digg_title = 'Partitioning Disks with fdisk';
digg_bodytext = '';
digg_media = 'news';
digg_topic = '';
</script>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
</div>
</div>
<p>Every computer owner will come across the street road called Partitioning. Partitioning simply means dividing your physical hard drive into 2 or more logical (or virtual) drives. In Linux there are different kinds of applications that can help you do this, and one is <strong><em>fdisk.</em></strong></p>
<p>For this example, I will demonstrate how to use fdisk.</p>
<p>The basic command goes like <strong><em>fdisk &lt;device-name&gt; </em></strong>like:</p>
<blockquote><p># fdisk /dev/hda</p>
<p>The number of cylinders for this disk is set to 14596.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)</p>
<p>Command (m for help):</p></blockquote>
<p>To display the help menu or if you want to list all of available commands:</p>
<blockquote><p>Command (m for help): m<br />
Command action<br />
a   toggle a bootable flag<br />
b   edit bsd disklabel<br />
c   toggle the dos compatibility flag<br />
d   delete a partition<br />
l   list known partition types<br />
m   print this menu<br />
n   add a new partition<br />
o   create a new empty DOS partition table<br />
p   print the partition table<br />
q   quit without saving changes<br />
s   create a new empty Sun disklabel<br />
t   change a partition&#8217;s system id<br />
u   change display/entry units<br />
v   verify the partition table<br />
w   write table to disk and exit<br />
x   extra functionality (experts only)</p></blockquote>
<p>Now for the action. Let&#8217;s say we need to see how many partitions are in the disk.</p>
<blockquote><p>Command (m for help): p</p>
<p>Disk /dev/hda: 120.0 GB, 120060444672 bytes<br />
255 heads, 63 sectors/track, 14596 cylinders, total 234493056 sectors<br />
Units = sectors of 1 * 512 = 512 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/hda1   *          63    30716279    15358108+  83  Linux<br />
/dev/hda2        30716280    81915434    25599577+  83  Linux<br />
/dev/hda3        81915435    82975724      530145   82  Linux swap / Solaris<br />
/dev/hda4        82975725   234484739    75754507+   5  Extended<br />
/dev/hda5        82975788   234484739    75754476   83  Linux</p></blockquote>
<p>So there are 4 primary partitions - hda1, hda2, hda3 and hda4. The last partition, hda4, is the Extended Partition or the Logical Partition which contains the hda5 partition.</p>
<p>Now that we have seen all the partitions, let us say that we are going to delete the /dev/hda1partition and create a new one.</p>
<p>But before we can create a new one, we should delete the old one first. These steps does not execute the commands at once. If you made a mistake, you can just quit the program without committing any changes.</p>
<p>To delete a partition, just type d on the prompt. For this example, what I want to do is delete the first partition, /dev/hda1:</p>
<blockquote><p>Command (m for help): d<br />
Partition number (1-5): 1</p></blockquote>
<p>The partition number means that /dev/hda1will be deleted. To check if we have typed in the correct partition number (I hope I did!) just do:</p>
<blockquote><p>Command (m for help): p</p>
<p>Disk /dev/hda: 120.0 GB, 120060444672 bytes<br />
255 heads, 63 sectors/track, 14596 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/hda2            1913        5099    25599577+  83  Linux<br />
/dev/hda3            5100        5165      530145   82  Linux swap / Solaris<br />
/dev/hda4            5166       14596    75754507+   5  Extended<br />
/dev/hda5            5166       14596    75754476   83  Linux</p></blockquote>
<p>Voila! /dev/hda1 is no longer there. But no worries, it is still there. We just need to create a new one.</p>
<blockquote><p>Command (m for help): n<br />
Command action<br />
l   logical (5 or over)<br />
p   primary partition (1-4)<br />
p<br />
Selected partition 1<br />
First cylinder (1-14596, default 1):<br />
Using default value 1<br />
Last cylinder or +size or +sizeM or +sizeK (1-1912, default 1912):<br />
Using default value 1912</p>
<p>Command (m for help): p</p>
<p>Disk /dev/hda: 120.0 GB, 120060444672 bytes<br />
255 heads, 63 sectors/track, 14596 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/hda1               1        1912    15358108+  83  Linux<br />
/dev/hda2            1913        5099    25599577+  83  Linux<br />
/dev/hda3            5100        5165      530145   82  Linux swap / Solaris<br />
/dev/hda4            5166       14596    75754507+   5  Extended<br />
/dev/hda5            5166       14596    75754476   83  Linux</p></blockquote>
<p>The n command will create a new partition, in this case, replacing the old /dev/hda1 that we have deleted and the p command will display that we have successfully created a new one (yay!).</p>
<p>To commit the changes, type w on the prompt.</p>
<blockquote><p>Command (m for help): m<br />
Command action<br />
w   write table to disk and exit</p></blockquote>
<p>But for now we will exit fdisk without saving the changes.</p>
<blockquote><p>Command (m for help): q</p></blockquote>
<p>That&#8217;s all for fdisk for now. There are other commands available on fdisk, just do not forget the use the man pages and the m command. If you have deleted a big chunk of important files, well, experience is the best teacher <img src='http://www.pinoytux.com/smilies/yahoo_wink.gif' alt='&#59;&#41;' class='wp-smiley' width='18' height='18' title='&#59;&#41;' /><br />
<h3>Most Popular Posts</h3>
<ul class="related_post">
<li><a href="http://www.pinoytux.com/games/create-your-own-poker-league-with-pokerdiy" title="Create Your Own Poker League with PokerDIY">Create Your Own Poker League with PokerDIY (0)</a></li>
<li><a href="http://www.pinoytux.com/others/21-funny-christmas-cards" title="21 Funny Christmas Cards">21 Funny Christmas Cards (0)</a></li>
<li><a href="http://www.pinoytux.com/linux/tip-hiding-files-inside-an-image-in-linux" title="Tip: Hiding Files Inside An Image in Linux">Tip: Hiding Files Inside An Image in Linux (2)</a></li>
<li><a href="http://www.pinoytux.com/rantings/cebu-pacific-airlines-is-evil" title="Cebu Pacific Airlines is Evil!">Cebu Pacific Airlines is Evil! (25)</a></li>
<li><a href="http://www.pinoytux.com/pinoytux/site-disclosure" title="Site Disclosure">Site Disclosure (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.pinoytux.com/linux/partitioning-disks-with-fdisk/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
