<?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>UKoom &#187; Linux</title>
	<atom:link href="http://www.ukoom.com/category/consultant/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ukoom.com</link>
	<description>Documentum, SharePoint, Alfresco, ECM...</description>
	<lastBuildDate>Tue, 25 Oct 2011 15:11:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Nginx configuration &#8211; nginx.conf</title>
		<link>http://www.ukoom.com/nginx-configuration-nginx-conf.htm</link>
		<comments>http://www.ukoom.com/nginx-configuration-nginx-conf.htm#comments</comments>
		<pubDate>Tue, 10 Aug 2010 11:52:05 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1109</guid>
		<description><![CDATA[server { listen 80; server_name nginx.org www.nginx.org; root /data/www; location / { index index.html index.php; } location ~* \.(gif&#124;jpg&#124;png)$ { expires 30d; } location ~ \.php$ { fastcgi_pass localhost:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } nginx first searches for the most specific location given by literal strings regardless of the listed order. In the [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<pre>server {
    listen        80;
    server_name   nginx.org  www.nginx.org;
    root          /data/www;

    location / {
        index     index.html  index.php;
    }

    location ~* \.(gif|jpg|png)$ {
        expires   30d;
    }

    location ~ \.php$ {
        fastcgi_pass   localhost:9000;
        fastcgi_param  SCRIPT_FILENAME
                       $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}</pre>
</blockquote>
<p>nginx first searches for the most specific location given by literal strings regardless of the listed order. In the configuration above the only literal location is “<code>/</code>” and since it matches any request it will be used as a last resort. Then nginx checks locations given by regular expression in the order listed in the configuration file. The first matching expression stops the search and nginx will use this location. If no regular expression matches a request, then nginx uses the most specific literal location found earlier.</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directives</em></p>
<pre>location / { }
location /images/ { }
location /blog/ { }
location /planet/ { }
location /planet/blog/ { }

location ~ IndexPage\.php$ { }
location ~ ^/BlogPlanet(/|/index\.php)$ { }

location ~* \.(pl|cgi|perl|prl)$ { }
location ~* \.(md|mdwn|txt|mkdn)$ { }

location ^~ /images/IndexPage/ { }
location ^~ /blog/BlogPlanet/ { }

location = / { }</pre>
<p>The first five examples are &#8220;literal string&#8221; matches, and match the beginning part of the request following the host portion. In a hypothetical request for <tt><span>http://ducklington.org/</span></tt>, assuming that there is a <tt>server_name</tt> for <tt>ducklington.org</tt>, the &#8220;<tt>location /</tt>&#8221; directive will catch this request. Nginx will always fulfill a request with most specific match. A request for <tt><span>http://ducklington.org/planet/blog/</span></tt> and <tt><span>http://ducklington.org/planet/blog/about/</span></tt> will be fulfilled by the &#8220;<tt>location /planet/blog/</tt>&#8221; even though &#8220;<tt>location /planet/</tt>&#8221; also fills this request.</p>
<p>When a <tt>location</tt> directive is followed by a tilde (e.g. <tt>~</tt>) as in the fourth group of examples, nginx performs a regular expression match. These matches are always case sensitive, so in the first example requests ending in <tt>IndexPage.php</tt> would match, but <tt>indexpage.php</tt> would not. In the second the regular expression <tt><span>^/BlogPlanet(/|index\.php)$</span></tt> will match requests for <tt>/BlogPlanet/</tt> and <tt>/BlogPlanet/index.php</tt>, but <strong>not</strong> <tt>/BlogPlanet</tt>, <tt>/blogplanet/</tt>, or <tt>/blogplanet/index.php</tt>. Nginx uses Perl Compatible Regular Expressions (PCRE).</p>
<p>Using a tilde-asterisk (e.g. <tt>~*</tt>) as an argument to a <tt>location</tt> directive, as in the third group of examples, removes case sensitivity from the matches. These examples all specify how nginx should process requests that end in a particular file extension. In the first example, any file ending in: <tt>.pl</tt>, <tt>.PL</tt>, <tt>.cgi</tt>, <tt>.CGI</tt>, <tt>.perl</tt>, <tt>.Perl</tt>, <tt>.prl</tt>, and <tt>.PrL</tt> (among others) will match the request.</p>
<p>In the next group of examples, the caret-tilde argument (e.g. <tt>^~</tt>) to <tt>location</tt> functions like the literal string matches of the first group. However, when used, they force nginx to stop searching for more specific matches. So in these examples, the <tt>location</tt> directives for &#8220;<tt>^~ /images/IndexPage/</tt>&#8221; and &#8220;<tt>^~ /blog/BlogPlanet/</tt>&#8221; would be used even though the request matches another location directive. See below for more information about the order and priority of <tt>location</tt> directive processing.</p>
<p>Finally, using the equal sign (e.g. <tt>=</tt>) as an argument to <tt>location</tt> forces an exact match with the path requested and then stops searching for more specific matches. For instance, the final example will only match <tt><span>http://ducklington.org/</span></tt> but not <tt><span>http://ducklington.org/index.html</span></tt>. Using exact matches can speed up request times slightly especially when some requests are particularly popular.</p>
<p>Directives are processed in the following manner:</p>
<ul>
<li>Exact string matches are processed first. If a match is found, nginx stops searching and fulfills the request.</li>
<li>Remaining literal string directives are processed next. If the &#8220;<tt>^~</tt>&#8221; argument is used, then ngnix stops here and fulfills the request. Otherwise, nginx continues to process location directives.</li>
<li>All location directives specified by regular expressions (with the <tt>~</tt> and <tt>~*</tt> arguments) are processed. If a regular expression matches the request, nginx stops here and fulfills the request.</li>
<li>When there are no regular expressions, or no regular expressions match, the most specific literal string match is used.</li>
</ul>
<p>It is incumbent upon the administrator to ensure that possible <tt>location</tt> directives will match for every resource nginx is to provide for a given domain within the <tt>server</tt> block. Additionally, while nginx&#8217;s configuration parser is capable of reading nested location blocks, using <tt>location</tt> directives in this manner is not a supported behavior.</p>
<div id="location-configuration"><a name="location_configuration"></a></p>
<h2>Location Configuration <a href="http://library.linode.com/guniDB"><img style="border: medium none; margin: 0px; padding: 0px;" src="http://library.linode.com/images/link-icon.png" alt="Link" /></a></h2>
<p>Once nginx has selected a <tt>location</tt> to provide the resource for a given request, the response to this request is determined by the contents of the location directive block. Allow us to consider the following basic configuration block:</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directive</em></p>
<pre>location / {
    root   html;
    index  index.html index.htm;
}</pre>
<p>In this example the document root is located in the <tt>html/</tt> directory. Given the default installation prefix for nginx, the full path to this location is <tt>/opt/nginx/http/</tt>. A request for the resource located at <tt>/blog/includes/style.css</tt> and assuming no other location directives matched, would serve the resource located on the file system at <tt>/opt/nginx/html/blog/includes/style.css</tt>. If you like, you can specify absolute paths for the <tt>root</tt> directive.</p>
<p>The <tt>index</tt> directive tells nginx which resource on the file system should be used if the request does not include a file name. Therefore, in this case the request for <tt><span>http://.ducklington.org/</span></tt> would be fulfilled by the resource located at <tt>/opt/nginx/http/index.html</tt>. If multiple files are specified for the <tt>index</tt> directive, nginx will process the list in order and fulfill the request with the first file that exists. If <tt>index.html</tt> doesn&#8217;t exist in the relevant directory, <tt>index.htm</tt> would be used. If neither exist, a 404 message would be sent.</p>
<p>Allow us to consider additional examples of <tt>location</tt> directives from the <a href="http://library.linode.com/web-servers/nginx/perl-fastcgi/debian-5-lenny">serving websites with nginx and Perl-FastCGI guide</a> for a server responding for the domain <tt>ducklington.org</tt>:</p>
<p><strong>File excerpt:</strong> <em>nginx.conf location directive</em></p>
<pre>location / {
    root   /srv/www/ducklington.org/public_html;
    index  index.html index.htm;
}

location ~ \.pl$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:8999;
    fastcgi_index index.pl;
    fastcgi_param  SCRIPT_FILENAME  /srv/www/ducklington.org/public_html$fastcgi_script_name;
}</pre>
<p>In this example, all requests for resources that end in a <tt>.pl</tt> extension are handled by the second location block, which specifies a <tt>fastcgi</tt> handler for these requests. Otherwise, nginx uses the first location directive. Resources are located on the file system at <tt>/srv/www/ducklington.org/public_html/</tt>. If no file name is specified in the request, nginx will look for and provide the <tt>index.html</tt> and <tt>index.htm</tt> files in turn. If no <tt>index</tt> files are found, the server will return a 404 error. Consider the following requests:</p>
<ul>
<li>The request for <tt><span>http://ducklington.org/</span></tt> will return the file located at <tt>/srv/www/ducklington.org/public_html/index.html</tt> if it exists. If that file doesn&#8217;t exist, it will fulfill <tt>/srv/www/ducklington.org/public_html/index.htm</tt>. If neither exists, nginx returns a 404 error.</li>
<li>The request for <tt><span>http://ducklington.org/blog/</span></tt> will return the file located at <tt>/srv/www/ducklington.org/public_html/blog/index.html</tt> if it exists. If that file doesn&#8217;t exist, it will fulfill <tt>/srv/www/ducklington.org/public_html/blog/index.htm</tt>. If neither exists, nginx returns a 404 error.</li>
<li>The request for <tt><span>http://ducklington.org/tasks.pl</span></tt> will use the FastCGI handler to execute the file located at <tt>/srv/www/ducklington.org/public_html/tasks.pl</tt> and return the result.</li>
<li>The request for <tt><span>http://ducklington.org/squire/roster.pl</span></tt> will use the FastCGI handler execute the file located at <tt>/srv/www/ducklington.org/public_html/squire/roster.pl</tt> and return the result.</li>
</ul>
</div>
<p>Reference:</p>
<p><a href="http://www.ukoom.com/wp-content/uploads/2010/08/nginx.conf.zip">nginx.conf.zip</a></p>
<p>http://nginx.org/en/docs/http/request_processing.html</p>
<p>http://library.linode.com/web-servers/nginx/configuration/basic#location_configuration</p>
<p>http://articles.slicehost.com/2009/3/5/ubuntu-intrepid-nginx-configuration</p>
<p>http://blog.rackcorp.com/?p=31</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/nginx-configuration-nginx-conf.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux Kill user session or logout users</title>
		<link>http://www.ukoom.com/linux-kill-user-session-or-logout-users.htm</link>
		<comments>http://www.ukoom.com/linux-kill-user-session-or-logout-users.htm#comments</comments>
		<pubDate>Tue, 10 Aug 2010 03:31:33 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1103</guid>
		<description><![CDATA[We can use the command &#8216;skill -KILL -u &#60;username&#62;' to logout users. Reference: http://www.cyberciti.biz/tips/howto-linux-kill-and-logout-users.html]]></description>
			<content:encoded><![CDATA[<p>We can use the command &#8216;<code>skill -KILL -u &lt;username&gt;' to logout users. </code></p>
<p>Reference:</p>
<p>http://www.cyberciti.biz/tips/howto-linux-kill-and-logout-users.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/linux-kill-user-session-or-logout-users.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Platform Status: libjvm.so: cannot open shared object file: No such file or directory</title>
		<link>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm</link>
		<comments>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:46:43 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Documentum]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1034</guid>
		<description><![CDATA[Error &#8221; Generic Status: Library Open failed, Library Name: /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjava.so, Platform Status: libjvm.so: cannot open shared object file: No such file or directory IDQL failed to run.  dmAPIInit() returned a failed status. &#8221; was thrown when executing IDQL command. I came across this issue after I installed one docbase on linux server. It seemed that [...]]]></description>
			<content:encoded><![CDATA[<p>Error &#8221;</p>
<p>Generic Status: Library Open failed, Library Name: /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjava.so, Platform Status: libjvm.so: cannot open shared object file: No such file or directory</p>
<p>IDQL failed to run.  dmAPIInit() returned a failed status.</p>
<p>&#8221; was thrown when executing IDQL command.</p>
<p>I came across this issue after I installed one docbase on linux server.</p>
<p>It seemed that IDQL read the .so file in the wrong place.</p>
<p>I used the link command to resolve this problem:</p>
<p>ln -s /dctm65/shared/java/1.5.0_12/jre/lib/i386/server/libjvm.so /dctm65/shared/java/1.5.0_12/jre/lib/i386/libjvm.so</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/platform-status-libjvm-so-cannot-open-shared-object-file-no-such-file-or-directory.htm/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>chown &#8211; change the owner of a file</title>
		<link>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm</link>
		<comments>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm#comments</comments>
		<pubDate>Thu, 28 Jan 2010 05:34:21 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1031</guid>
		<description><![CDATA[You can change the owner and group of a file or a directory with the chown command. Please, keep in mind you can do this only if you are the root user or the owner of the file. Set the file&#8217;s owner: $ chown username somefile After giving this command, the new owner of a [...]]]></description>
			<content:encoded><![CDATA[<p>You can change the owner  and group of a file or a directory with the <code>chown</code> command.  Please, keep in mind you can do this only if you are the root user or  the owner of the file.</p>
<p>Set the file&#8217;s owner:<br />
<span><code>$ <strong>chown username somefile</strong></code></span><br />
After giving this command, the new owner of a file called <code>somefile</code> will be the user <code>username</code>. The file&#8217;s group owner will not  change. Instead of a user name, you can also give the user&#8217;s numeric ID  here if you want.</p>
<p>You can also set the file&#8217;s group at the same time. If the user  name is followed by a colon and a group name, the file&#8217;s group will be  changed as well.<br />
<span><code>$ <strong>chown username:usergroup  somefile</strong></code></span><br />
After giving this command, <code>somefile</code>&#8216;s new owner would be  user <code>username</code> and the group <code>usergroup</code>.</p>
<p>You can set the owner of a directory exactly the same way you set  the owner of a file:<br />
<span><code>$ <strong>chown username somedir</strong></code></span><br />
Note that after giving this command, only the owner of the <em>directory</em> will change. The owner of the files <em>inside</em> of the directory  won&#8217;t change.</p>
<p>In order to set the ownership of a directory and all the files in  that directory, you&#8217;ll need the <code>-R</code> option:<br />
<span><code>$ <strong>chown -R username somedir</strong></code></span><br />
Here, R stands for <em>recursive</em> because this command will  recursively change the ownership of directories and their contents.  After issuing this example command, the user <code>username</code> will  be the owner of the directory <code>somedir</code>, as well as every  file in that directory.</p>
<p>Tell what happens:</p>
<p><code>$ <strong>chown -v username somefile</strong><br />
changed ownership of 'somefile' to username</code></p>
<p>Here, v stands for <em>verbose</em>. If you use the <code>-v</code> option, <code>chown</code> will list what it did (or didn&#8217;t do) to the  file.</p>
<p>The verbose mode is especially useful if you change the ownership  of several files at once. For example, this could happen when you do it  recursively:</p>
<p><code>$ <strong>chown -Rv username somedir</strong><br />
changed ownership of 'somedir/' to username<br />
changed ownership of 'somedir/boringfile' to username<br />
changed ownership of 'somedir/somefile' to username</code></p>
<p>As you can see, <code>chown</code> nicely reports to you what it  did to each file.</p>
<div>
<div>
<h2>&lt; <strong><span id="chgrp">chgrp  &#8211; change the group ownership of a file</span></strong> &gt;</h2>
<p>In addition to <code>chown</code>, you can also use the <code>chgrp</code> command to change the group of a file or a directory. You must, again,  be either the root user or the owner of the file in order to change the  group ownership.</p>
<p><code>chgrp</code> works pretty much the same way as <code>chown</code> does, except it changes the file&#8217;s user group instead of the owner, of  course.<br />
<span><code>$ <strong>chgrp usergroup somefile</strong></code></span><br />
After issuing this command, the file <code>somefile</code> will be  owned by a user group <code>usergroup</code>. Although the file&#8217;s group  has changed to <code>usergroup</code>, the file&#8217;s owner will still be  the same.</p>
<p>The options of using <code>chgrp</code> are the same as using <code>chown</code>.  So, for example, the <code>-R</code> and <code>-v</code> options will  work with it just like they worked with <code>chown</code>:</p>
<p><code>$ <strong>chgrp -Rv usergroup somedir</strong><br />
changed group of 'somedir/' to usergroup<br />
changed group of 'somedir/boringfile' to usergroup<br />
changed group of 'somedir/somefile' to usergroup</code></p>
<p><code>chown</code> nicely reports to you what it did to each file.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/chown-change-the-owner-of-a-file.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An internal virtual machine error (13) has occurred</title>
		<link>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm</link>
		<comments>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:13:29 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1028</guid>
		<description><![CDATA[when I booted the Red Hat WS 4 image, I received the following error: &#8220;An internal virtual machine error (13) has occurred.  The virtual machine will reset now.&#8221; To resolve this error, first boot in single user mode: In GRUB menu select Red Hat Linux with the version of the kernel that you wish to [...]]]></description>
			<content:encoded><![CDATA[<p>when I booted the Red Hat WS 4 image, I received the following error:  &#8220;An internal virtual machine error (13) has occurred.  The virtual  machine will reset now.&#8221;</p>
<p>To resolve this error, first boot in single user mode:</p>
<ol>
<li>In  GRUB menu select Red Hat Linux with the version of the kernel that you  wish to boot and type <strong>e</strong> for edit. You will be presented  with a list of items in the configuration file for the title you just  selected.</li>
<li>Select the line that starts with kernel and type <strong>e</strong> to edit the line.</li>
<li>Go to the end of the line and type <strong>single</strong> as a separate word. Press enter to exit edit mode.</li>
<li>Back at  the GRUB screen, type <strong>b </strong>to boot into single user mode.</li>
</ol>
<p>Next, edit /etc/X11/xorg.conf and replace set the  Driver to &#8220;vesa&#8221;.  Also, set the DefaultDepth to 16 from 24.  The  implementation of the S3 hardware doesn&#8217;t support a colordepth of 24 and  will cause the error 13.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/an-internal-virtual-machine-error-13-has-occurred.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Find Files Containing Text</title>
		<link>http://www.ukoom.com/linux-find-files-containing-text.htm</link>
		<comments>http://www.ukoom.com/linux-find-files-containing-text.htm#comments</comments>
		<pubDate>Wed, 27 Jan 2010 05:54:48 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=1023</guid>
		<description><![CDATA[Find files that contain a text string: grep -lir &#8220;some text&#8221; * The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.]]></description>
			<content:encoded><![CDATA[<p>Find files that contain a text string:</p>
<p>grep -lir &#8220;some text&#8221; *</p>
<p>The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/linux-find-files-containing-text.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IF Else in bash of linux</title>
		<link>http://www.ukoom.com/if-else-in-bash-of-linux.htm</link>
		<comments>http://www.ukoom.com/if-else-in-bash-of-linux.htm#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:31:16 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=973</guid>
		<description><![CDATA[If/Else In order for a script to be very useful, you will need to be able to test the conditions of variables. Most programming and scripting languages have some sort of if/else expression and so does the bourne shell. Unlike most other languages, spaces are very important when using an if statement. Let&#8217;s do a [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: small;"><strong>If/Else</strong></span></p>
<p>In order for a script to be very useful, you will need to be able to test the conditions of variables. Most programming and scripting languages have some sort of if/else expression and so does the bourne shell. Unlike most other languages, spaces are very important when using an <strong>if</strong> statement.  Let&#8217;s do a simple script that will ask a user for a password before allowing him to continue.  This is obviously 	not how you would implement such security in a real system, but it will make a good example of using <strong>if</strong> and <strong>else</strong> statements.</p>
<pre>#!/bin/sh
# This is some secure program that uses security.

VALID_PASSWORD="secret" #this is our password.

echo "Please enter the password:"
read PASSWORD

if [ "$PASSWORD" == "$VALID_PASSWORD" ]; then
	echo "You have access!"
else
	echo "ACCESS DENIED!"
fi</pre>
<p>Remember that the spacing is very important in the if statement.  Notice that the termination of the if statement is <strong>fi</strong>.  You will need to use 	the <strong>fi</strong> statement to terminate an if whether or not use use an else as well. You can also replace the &#8220;==&#8221; with &#8220;!=&#8221; to test if the variables are NOT equal. There are other tokens that you can put in place of the &#8220;==&#8221; for other types of tests. The following table shows the different expressions allowed.</p>
<p><strong>Comparisons:</strong></p>
<table border="1">
<tbody>
<tr>
<td><strong>-eq</strong></td>
<td>equal to</td>
</tr>
<tr>
<td><strong>-ne</strong></td>
<td>not equal to</td>
</tr>
<tr>
<td><strong>-lt</strong></td>
<td>less than</td>
</tr>
<tr>
<td><strong>-le</strong></td>
<td>less than or equal to</td>
</tr>
<tr>
<td><strong>-gt</strong></td>
<td>greater than</td>
</tr>
<tr>
<td><strong>-ge</strong></td>
<td>greater than or equal to</td>
</tr>
</tbody>
</table>
<p><strong>File Operations:</strong></p>
<table border="1">
<tbody>
<tr>
<td><strong>-s</strong></td>
<td>file exists and is not empty</td>
</tr>
<tr>
<td><strong>-f</strong></td>
<td>file exists and is not a directory</td>
</tr>
<tr>
<td><strong>-d</strong></td>
<td>directory exists</td>
</tr>
<tr>
<td><strong>-x</strong></td>
<td>file is executable</td>
</tr>
<tr>
<td><strong>-w</strong></td>
<td>file is writable</td>
</tr>
<tr>
<td><strong>-r</strong></td>
<td>file is readable</td>
</tr>
</tbody>
</table>
<p>Let&#8217;s try using a couple of these in a script. This next script will ask for a user name, if there is not a file that exists with the name &#8220;username_DAT&#8221;, the script will prompt the user for their age, it will then make sure that they are old enough to use this program and then it will write their age to a file with the name &#8220;username_DAT&#8221;. If the file already exists, it will just display the age of the user.</p>
<pre>#!/bin/sh

# Prompt for a user name...
echo "Please enter your name:"
read USERNAME

# Check for the file.
if [ -s ${USERNAME}_DAT ]; then
        # Read the age from the file.
        AGE=`cat ${USERNAME}_DAT`
        echo "You are $AGE years old!"
else
        # Ask the user for his/her age
        echo "How old are you?"
        read AGE

	if [ "$AGE" -le 2 ]; then
		echo "You are too young!"
	else
		if [ "$AGE" -ge 100 ]; then
			echo "You are too old!"
		else
        		# Write the age to a new file.
        		echo $AGE &gt; ${USERNAME}_DAT
        	fi
        fi
fi</pre>
<p>Run this program a couple of times. First run it and give it the user name of &#8220;john&#8221;. When it asks for an age, enter the age &#8220;1&#8243;. Notice that it will say that you are too you and then exit. Now run the program again with the name &#8220;john&#8221; and the age 200. This time the script will tell you that you are too old and exit. Now run the the script again with the name of &#8220;john&#8221;, enter the age 30. The script exits normally this time, the program created a file called &#8220;john_DAT&#8221; which contains the text &#8220;30&#8243;. Finally run the program one more time and give it the name &#8220;john&#8221;. This time it will not prompt you to enter an age, instead it will read the age from a file and say &#8220;Your are 30 years old!&#8221;.</p>
<p>We introduced something else new in this script.  On line 10 of the file, we see the code:</p>
<pre>	AGE=`cat ${USERNAME}_DAT`</pre>
<p>This is how you execute a command and put the text output from the command into a variable.  The unix command <strong>cat</strong> reads the file 	named <strong>${USERNAME}_DAT</strong> and outputs it to the console.  Instead of putting it to the console in our script, we wrap the command with 	the character <strong>`</strong>, this puts the text into our variable AGE.</p>
<p>You can test multiple expressions at once by using the <strong>||</strong> (or) operator or the <strong>&amp;&amp;</strong> (and) operator. This can save you from writing extra code to nest if statements. The above code has a nested if statement where it checks if the age is greater than or equal to 100. This could be changed as well by using <strong>elif</strong> (else if).  The structure of <strong>elif</strong> is the same as the structure of <strong>if</strong>, we will use it in an example below. In this example, we will check for certain age ranges. If you are less than 20 or greater than 50, you are out of the age range. If you are between 20 and 30 you are in your 20&#8242;s and so on.</p>
<pre>#!/bin/sh

# Prompt for a user name...
echo "Please enter your age:"
read AGE

if [ "$AGE" -lt 20 ] || [ "$AGE" -ge 50 ]; then
	echo "Sorry, you are out of the age range."
elif [ "$AGE" -ge 20 ] &amp;&amp; [ "$AGE" -lt 30 ]; then
	echo "You are in your 20s"
elif [ "$AGE" -ge 30 ] &amp;&amp; [ "$AGE" -lt 40 ]; then
	echo "You are in your 30s"
elif [ "$AGE" -ge 40 ] &amp;&amp; [ "$AGE" -lt 50 ]; then
	echo "You are in your 40s"
fi</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/if-else-in-bash-of-linux.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy and Paste in VI</title>
		<link>http://www.ukoom.com/copy-and-paste-in-vi.htm</link>
		<comments>http://www.ukoom.com/copy-and-paste-in-vi.htm#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:27:04 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=971</guid>
		<description><![CDATA[The command ‘Y’ or ‘yy’ copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively: Y 2Y 10Y yG To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively: P p [...]]]></description>
			<content:encoded><![CDATA[<p>The command ‘Y’ or ‘yy’ copies (yanks) one or more lines. To copy one line, two lines, 10 lines, and all lines to the end of the file, respectively:</p>
<p><code>Y<br />
2Y<br />
10Y<br />
yG</code></p>
<p>To paste the text contained in the buffer above (uppercase P) or below the current cursor position (lowercase p), respectively:</p>
<p><code>P<br />
p</code></p>
<p>It is also possible to yank text within a line. The following commands yank text from the current cursor position to the end of the word and the end of the line, respectively:</p>
<p><code>yw<br />
y$</code></p>
<p>The same commands paste the text within a line.  Lower case p pastes after the cursor position and upper case P pastes before.</p>
<p>Paste will also work with deleted text, either lines or parts of lines. Be careful not to execute any other commands prior to pasting as this will empty the buffer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/copy-and-paste-in-vi.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resource:Linux general command.chm</title>
		<link>http://www.ukoom.com/resourcelinux-general-command-chm.htm</link>
		<comments>http://www.ukoom.com/resourcelinux-general-command-chm.htm#comments</comments>
		<pubDate>Thu, 03 Dec 2009 10:41:38 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=933</guid>
		<description><![CDATA[Linux general commandLinux general command]]></description>
			<content:encoded><![CDATA[<p>Linux general command<a href="http://www.ukoom.com/wp-content/uploads/2009/12/Linux-general-command.zip">Linux general command</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/resourcelinux-general-command-chm.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LS命令按时间排序</title>
		<link>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm</link>
		<comments>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm#comments</comments>
		<pubDate>Wed, 02 Dec 2009 06:57:24 +0000</pubDate>
		<dc:creator>ukoom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ukoom.com/?p=921</guid>
		<description><![CDATA[ls -l -t为按时间排序显示,默认为新的排在前面,可用下面的命令更改升降序: ls -lrt 最新的文件排在后面(升序) ls -lnt 最新的文件排在前面(降序)]]></description>
			<content:encoded><![CDATA[<p>ls -l -t为按时间排序显示,默认为新的排在前面,可用下面的命令更改升降序:<br />
ls -lrt  最新的文件排在后面(升序)<br />
ls -lnt 最新的文件排在前面(降序)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ukoom.com/ls%e5%91%bd%e4%bb%a4%e6%8c%89%e6%97%b6%e9%97%b4%e6%8e%92%e5%ba%8f.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

