Tuesday, November 27, 2012

Unix Editor/ vi enlisted commands

Commands used in vi Editor - An Unix Editor

The vi editor is a common editor for unix systems and for the enlisted document in your system find the below command:

man vi

at the unix prompt. 
Starting an Editing Session

vi filename

where filename is the name of the file to be edited. 
Undo Command
undo the last command. 

Screen Commands
CTL/l 
Reprints current screen. 
CTL/L 
Exposes one more line at top of screen. 
CTL/E 
Exposes one more line at bottom of screen. 
CTL/F 
Pages forward one screen. 
CTL/B 
Pages back one screen. 
CTL/D 
Pages down half screen. 
CTL/U 
Pages up half screen. 
Cursor Positioning Commands
Moves cursor down one line, same column. 
Moves cursor up one line, same column. 
Moves cursor back one character. 
Moves cursor forward one character. 
RET
Moves cursor to beginning of next line. 
Moves cursor to beginning of current line. 
Moves cursor to end of current line. 
SPACE 
Moves cursor forward one character. 
n
Moves cursor to beginning of line n. Default is last line of file. 
Moves the cursor to the first character of the line. 
:n 
Moves cursor to beginning of line n
Moves the cursor backward to the beginning of the previous word. 
Moves the cursor backward to the end of the previous word. 
Moves the cursor forward to the next word.
/pattern 
Moves cursor forward to next occurrence of pattern
?pattern 
Moves cursor backward to next occurrence of pattern
Repeats last / or ? pattern search.

Text Insertion Commands
Appends text after cursor. Terminated by escape key. 
Appends text at the end of the line. Terminated the escape key. 
Inserts text before cursor. Terminated by the escape key. 
Inserts text at the beginning of the line. Terminated by the escape key. 
Opens new line below the current line for text insertion. Terminated by the escape key. 
Opens new line above the current line for text insertion. Terminated by the escape key. 
DEL
Overwrites last character during text insertion. 
ESC 
Stops text insertion. The escape key on the DECstations is the F11 key.

Text Deletion Commands
Deletes current character. 
dd 
Deletes current line. 
dw 
Deletes the current word. 
d) 
Deletes the rest of the current sentence. 
D, d$ 
Deletes from cursor to end of line. 
Puts back text from the previous delete.

Changing Commands
cw 
Changes characters of current word until stopped with escape key. 
c$ 
Changes text up to the end of the line. 
C, cc 
Changes remaining text on current line until stopped by pressing the escape key.
Changes case of current character. 
xp 
Transposes current and following characters. 
Joins current line with next line. 
Deletes the current character and goes into the insertion mode. 
rx
Replaces current character with x
Replaces the following characters until terminated with the escape key.




Cut and Paste Commands
yy 
Puts the current line in a buffer. Does not delete the line from its current position. 
Places the line in the buffer after the current position of the cursor.
Appending Files into Current File
:R filename 
Inserts the file filename where the cursor was before the ``:'' was typed. 
Exiting vi
ZZ 
Exits vi and saves changes. 
:wq 
Writes changes to current file and quits edit session. 
:q! 
Quits edit session (no changes made). 

What is Unix?


We have more than thousand of definitions available online but this is one is easy to know and understand.

Unix is multi tasking, multi-user operating system developed by AT&T (Bell Lab) in late 1969. Unix System consist a core kernel which does input output operations and allocate resources to carry out  user defined and system defined tasks.

Unix Filesystem is hierarchal which allows both absolute and relative path naming of file ,thus flexible.

Unix can be simply defines as multiuser,multiprocess and multithreaded.Example: A shell can be access ed by number of users at a time and in the same shell we can run different applications to respective different number of users.

Unix has Parent-Child system for the process.Process can be denoted by process ID (PID). Killing the parent process means all child process in turn dead ,as we can have this child process system so we can define which process to be kill and to save other running process.