<?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>Admin&#039;s Choice &#187; unix</title>
	<atom:link href="http://adminschoice.com/tag/unix/feed" rel="self" type="application/rss+xml" />
	<link>http://adminschoice.com</link>
	<description>Unix adminstrators documents , tip and more</description>
	<lastBuildDate>Fri, 03 Jun 2011 17:27:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>vi editor Quick Reference</title>
		<link>http://adminschoice.com/vi-editor-quick-reference</link>
		<comments>http://adminschoice.com/vi-editor-quick-reference#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:22:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[linux vi editor]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://adminschoice.com/wp28/?p=31</guid>
		<description><![CDATA[vi  is a unix editor available on almost all the unix  operating systems like  solaris , bsd ,aix , hpux etc.
This document is a quick reference to vi editor and will be of help if your are new to unix , learning unix  or just looking for some vi commands]]></description>
			<content:encoded><![CDATA[<p><strong> Introduction</strong><br />
vi  pronounced as &#8221; vee eye &#8221; is a unix editor available on almost all the unix  operating systems , solaris , bsd ,aix , hpux etc.<br />
This document is a quick reference to vi editor and will be of help if your are new to unix , learning unix  or just refreshing your vi knowledge after a few years.</p>
<p><strong>Requirements:</strong><br />
In order to work correctly the vi need  correct terminal type (TERM) setting  .The TERM setting depends on the   type of terminal you have . Commonly used TERM types are vt100 , vt220 and  ansi .  In most cases vt100 will  work  fine . In case  vi is not able to understand the TERM you have given, it starts in open mode   giving you a line by line display .<br />
Generally TERM is taken from .profile or  /etc/profile  but can be set at the command line as :<br />
$TERM=vt100<br />
$export TERM</p>
<p>echo $TERM will display the current TERM set.</p>
<p><strong>Create new file or  Open existing file in vi</strong><br />
vi without any file name will open a   new file where you can enter the text and edit but while coming out you will  be asked to enter a valid file name to save the text.  vi with a  file name as argument will  open that file for editing  if the file already exists it opens it  otherwise it creates a new file by the argument.<br />
Example :  $vi  testfile<br />
Creates or opens the existing file called testfile</p>
<p><strong>Modes in vi</strong></p>
<p>vi operates in following  two modes :<br />
i. ) <strong>Command Mode</strong> : After a file is opened it is opened  in command<br />
mode ,that is , input from the keyboard will be treated as vi commands<br />
and you will not see the words you are typing on the screen .</p>
<p><strong>ii.) Insert Mode</strong>: To enter the  text you have to put vi in insert  by pressing &#8216;i&#8217; or &#8216;a&#8217;  after  which you can add the text and whatever is being type will be seen on the  screen. . To switch between these mode Esc key is used .   Esc i<br />
(text mode)  Esc (command mode)</p>
<p><strong>Saving  &amp; Exiting  vi editor</strong><br />
You can exit vi in different ways :</p>
<p><em>1.) Quit without saving</em> : If you don&#8217;t  want to save the work :q  will take you out without saving  your editing in vi.<br />
<em>2.) Write &amp; quit</em> : . Simple :w  saves the current file but don&#8217;t exit. For save and quit  :wq is  used in vi.<br />
<em>3.) Forced Quite </em>: An ! (Exclamation  sign at the end of  exit commands ( :q! , :wq! )  causes a forced  quit from vi  after ignoring editing (for :q!)  or writing (for :wq!)  all the change</p>
<table border="0"><span style="font-size: medium; font-family: Times New Roman;"> </span></table>
<table id="AutoNumber2" style="border-collapse: collapse; height: 1786px;" border="1" cellspacing="0" cellpadding="3" width="392" bordercolor="#ffffff">
<tbody>
<tr>
<td><strong>Vi Commands &#8211; Reference</strong></td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#c0c0c0"><strong> Moving Cursor in File</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Left</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">h</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Right</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">l</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Up</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">k</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Down</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">j</td>
</tr>
<tr>
<td colspan="2" width="528" height="13" align="left" bgcolor="#ffffff"><strong>Line</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Beginning</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">^ or B</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">end</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">$</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Sentence</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Next          sentance</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">)</td>
</tr>
<tr>
<td width="231" height="23" align="left" valign="top" bgcolor="#e4e4e4">Previous sentance</td>
<td width="297" height="23" align="left" valign="top" bgcolor="#e4e4e4">(</td>
</tr>
<tr>
<td colspan="2" width="528" height="21" align="left" bgcolor="#ffffff"><strong>Paragraph</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Next</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">}</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Previous</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">{</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>file</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Go to end of file</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">:$</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">on chacter forword</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">:w</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">One word forword</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">:W</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">go to a line number</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">:line_number</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">display file info          .</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">^g</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Inserting and appending text </strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">inserts text to the left of  cursor</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">i</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">nserts in the beginning of line</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">I</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">appends text to right of cursor</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">a</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">appends to the end of line</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">A</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Adding new line</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">add a new line below the current line</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">o</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">adds a new line above the current line.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">O</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Deleting the text :</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">deletes text above the text</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">x</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">deletes text character on  right of cursor</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">X</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">deletes line 20</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">20d</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">deletes current line</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">dd</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">delete          till end of current line.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">D</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Replacing a character &amp; word</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">replace          the character above the cursor.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">r</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">replces characters until Esc is pressed.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">R</td>
</tr>
<tr>
<td width="231" height="57" align="left" bgcolor="#e4e4e4">replaces the word from cursor to the end indicated by $ sign .</td>
<td width="297" height="57" align="left" bgcolor="#e4e4e4">cw</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">replaces          till end of line.</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">C</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Substitute</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">subistutes current    charcater.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">s</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">substitutes entire line.</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">S</td>
</tr>
<tr>
<td colspan="2" width="528" height="16" align="left" bgcolor="#ffffff"><strong>Undo last changes</strong></td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">undo last change.</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">u</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">undo changes to the current line.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">U</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Copy and pasting lines</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">copys the current line into buffer.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">yy</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">copies 5 lines from the current line.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">5yy</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">pastes the current buffer.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">p</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Searching</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">Searches for the word name in    the file</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">:/name</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">n continues search forward.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">n</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">N searches backwards</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">N</td>
</tr>
<tr>
<td colspan="2" width="528" height="19" align="left" bgcolor="#ffffff"><strong>Saving</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">saves the text does not quit.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">:w</td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">saves          &amp; quit the editor .</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">:wq!</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">save</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">ZZ</td>
</tr>
<tr>
<td width="231" height="23" align="left" bgcolor="#e4e4e4">Quit without saving</td>
<td width="297" height="23" align="left" bgcolor="#e4e4e4">q!</td>
</tr>
<tr>
<td width="231" height="19" align="left" bgcolor="#e4e4e4"></td>
<td width="297" height="19" align="left" bgcolor="#e4e4e4"></td>
</tr>
<tr>
<td width="231" height="19" align="left" bgcolor="#e4e4e4">Search &amp; Replace</td>
<td width="297" height="19" align="left" bgcolor="#e4e4e4"><strong> s/&lt;search&gt;/&lt;replace&gt;/g .</strong></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">Repeating  last command</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4"><span style="font-size: large;">.</span></td>
</tr>
<tr>
<td width="231" height="38" align="left" bgcolor="#e4e4e4">Recovering a unsaved vi file.</td>
<td width="297" height="38" align="left" bgcolor="#e4e4e4">
<dl>
<dt><strong>vi -r  filename</strong> </dt>
</dl>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://adminschoice.com/vi-editor-quick-reference/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Checking and Repairing Unix File system with fsck</title>
		<link>http://adminschoice.com/repairing-unix-file-system-fsck</link>
		<comments>http://adminschoice.com/repairing-unix-file-system-fsck#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:20:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[File system]]></category>
		<category><![CDATA[fsck]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://adminschoice.com/wp28/?p=135</guid>
		<description><![CDATA[fsck is a Unix utility for checking and repairing  file system  inconsistencies. Learn about syntax running phases and troubleshooting with fsck.]]></description>
			<content:encoded><![CDATA[<p>fsck is a Unix utility for checking and repairing  file system  inconsistencies . File system can become inconsistent due to several reasons and the most common is abnormal shutdown due to hardware failure , power failure or switching off the system without proper shutdown. Due to these reasons the superblock in a file system is not updated and has mismatched information  relating to system data blocks, free blocks and inodes .</p>
<p><strong>fsck &#8211; Modes of operation</strong> :</p>
<p>fsck operates in two modes interactive and non interactive :</p>
<p><strong>Interactive </strong> &#8211;  fsck examines the file system and stops at each error it finds in the file system and gives the problem description and ask for user response whether to correct the problem or continue without making any change to the file system. </p>
<p><strong>Non interactive  </strong>:fsck tries to repair all the problems it finds in a file system without stopping for user response useful in case of a large number of inconsistencies  in a  file system but has the disadvantage of removing  some useful files which are detected to be corrupt .</p>
<p>If file system is found to have problem at the booting time non interactive fsck is run and all errors which are considered safe to correct are corrected. But if still file system has problems the  system boots in single user mode asking for user to manually run the fsck to correct the problems in file system</p>
<p><strong>Running fsck</strong> :<br />
fsck should always be run in a single  user mode which ensures proper repair of file system . If it is run in a busy system where the file system is changing constantly fsck may see the changes as inconsistencies  and may corrupt the file system .</p>
<p>If the system can not be brought in a single user mode  fsck should be run on the partitions ,other than root &#038; usr , after unmounting them . Root &#038; usr partitions can not be unmounted . If the system fails to come up due to root/usr files system corruption the system can be booted with CD and root/usr partitions can be repaired using fsck. </p>
<p><strong>command syntax</strong>  </p>
<p>fsck  [ -F fstype]  [-V]    [-yY]    [-o options]  special</p>
<p>-F fstype     type of file system to be repaired ( ufs , vxfs etc)</p>
<p>-V verify the command line syntax but do not run the command </p>
<p>-y or -Y  Run the command in non interactive mode &#8211; repair all errors encountered without waiting for user response.</p>
<p>-o options  Three options can be  specified with -o flag</p>
<p>b=n   where n is the number of next super block  if primary super block is corrupted in a file system .</p>
<p>p option used to make safe repair options during the  booting process.</p>
<p>f    force the file system check regardless of its clean flag.</p>
<p>special &#8211;  Block or character device name of the file system to be                 checked/repaired &#8211; for example /dev/rdsk/c0t3d0s4 .Character device should be used for consistencies check &#038; repair</p>
<p><strong>fsck phases</strong><br />
fsck checks the file system in a series of 5 pages and checks a specific functionality of file system in each phase.</p>
<p>** phase 1 &#8211; Check Blocks and Sizes<br />
** phase 2 &#8211; Check Pathnames<br />
** phase 3 &#8211; Check Connectivity<br />
** phase 4 &#8211; Check Reference Counts<br />
** phase 5 &#8211; Check Cylinder Groups</p>
<p><strong>fsck error messages &#038; Corrective action</strong> :</p>
<p><strong>1. Corrupted superblock &#8211; fsck fails to run </strong><br />
If the superblock is corrupted the file system still can be repaired using alternate superblock which are formed while making new file system .</p>
<p>the first alternate superblock number is 32 and others superblock numbers can be found using the following command :</p>
<p>newfs -N /dev/rdsk/c0t0d0s6</p>
<p>for example to run fsck using first alternate superblock following command is used </p>
<p>fsck -F ufs -o b=32 /dev/rdsk/c0t0d0s6</p>
<p><strong>2. Link counter adjustment</strong><br />
fsck finds mismatch between directory inode link counts and actual directory links and prompts for adjustment in case of interactive operation. Link count adjustments are considered to be a safe operation in a file system and should be repaired by giving &#8216;y&#8217; response to the adjust ? prompt during fsck.</p>
<p><strong>3. Free Block count  salvage </strong><br />
During fsck the number of free blocks listed in a superblock  and actual unallocated free blocks count does not match. fsck inform this mismatch and asks to salvage free block count to synchronize the superblock count. This error can be corrected without any potential problem to the file system or  files.</p>
<p><strong>4. Unreferenced file reconnection </strong><br />
While checking connectivity fsck finds some inodes which are allocated but not referenced &#8211; not attached to any directory . Answering y to reconnect message by fsck links these files to the lost+found directory with their inode number as their name . </p>
<p>To get more info about the files in lost+found &#8216;file&#8217; command can be used to see the type of files and subsequently they can be opened in their applications or text editors to find out about  their contents. If the file is found to be correct it can be used after copying to some other directory and renaming it. </p>
]]></content:encoded>
			<wfw:commentRss>http://adminschoice.com/repairing-unix-file-system-fsck/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

