Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, November 7, 2011

VI editor (visual editor)

8:44 AM
VI editor (visual editor)
I would like to share my knowledge in different areas so this is about the VI editor. The VI editor I frequently used to edit files on Linux environments. , as I read this is available on many other operating systems, even on MS-DOS, Windows and the Macintosh as well.
I am experienced with VI editor in my tasks. Here I show very essentials details about VI editor that are very important to me.
This is somewhat a huge topic to be learnt and there are many details about VI editor. I also don't know many of VI editor features but I always search for them via internet, using these commands and get experience about VI editor and also try to learn from your experience as well.
VI is a powerful text editor which is most popular amongst Linux users in the world wide. The VI editor is a screen-based editor used by many Unix/Linux users. This is used as a powerful text manipulation and quick movement using only a keyboard.
The VI editor has powerful features to aid programmers, but many beginning users avoid using VI because the different features overwhelm them.
The first thing most users learn about the VI editor is that it has two modes:
1. Command
2. Insert
The command mode allows the entry of commands to manipulate text. These commands are usually one or two characters long, and can be entered with few keystrokes.
The insert mode puts anything typed on the keyboard into the current file.
Getting around VI
Open the Linux terminal.
We can start up vi by typing
vi
To edit one or more files:
vi filename1 filename2
To quit for now, press the Escape key (the editor should beep), then enter the three characters :q! and press Return:
:q!



Command will be categorized into several sections.
More around VI
Adding, Changing, and Deleting Text
Unlike normal editors we cannot replace or delete text by highlighting it with the mouse. Instead use the commands following.
Inserting or adding text to a file
Backspace - Delete the character before the cursor.
Del - Delete the character under the cursor
i - insert text before cursor, until hit
I - insert text at beginning of current line, until hit
a - append text after cursor, until hit
A- append text to end of current line, until hit
o - open and put text in a new line below current line, until hit
O- open and put text in a new line above current line, until hit
Changing text
These commands are allow modifying text
r replace single character under cursor (no needed)
R replace characters, starting with current cursor position, until hit
cw change the current word with new text, starting with the character under cursor, until hit
C change (replace) the characters in the current line, until hit
cc change (replace) the entire current line, stopping when is hit



Deleting text
These commands are allow deleting text
x delete single character under cursor
Nx delete N characters, starting with character under cursor
dw delete the single word beginning with character under cursor
dNw delete N words beginning with character under cursor; e.g., d5w deletes 5 words
D delete the remainder of the line, starting with current cursor position
dd delete entire current line
Ndd or dNd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines

Cutting and pasting text
yy copy (yank, cut) the current line into the buffer
Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer
p put (paste) the line(s) in the buffer into the text after the current line

To exit from VI
:x quit vi, writing out modified file to file named in original invocation
:wq quit vi, writing out modified file to file named in original invocation
:q quit (or exit) vi
:q! quit vi even though latest changes have not been saved for this vi call

linux commands for working with files and directories

8:39 AM
linux commands for working with files and directories
I am bit familiar with linux environments (redhat, Fedora), when I am working with linux environment, use essential commands which are very useful any time for anyhttp://www.blogger.com/img/blank.gif developers. Each commands definitions and functions are described step by step. Here I will describe simply not in comprehensive manner.

By typing man command on linux command line we can view more information about specific command. Also entering on 'q' can quit from the man view.

To be log into linux servers use puTTy and ssh clients applications which are free clients to log into linux. There are plenty of linux client programme available in the web.

cd - change directory
When people work on linux or windows mostly familiar with this is command
The cd is a command line command to change the current working directory.
xiscom@comitg20# cd pradeep
xiscom@comitg20#

pwd - display the name of current working directory
if someone want to find current working directory path. Do this command on command line.

ls – Listing files
The ls command for listing files and directories of the current working location.

man ls and info ls provide more information about this command.

There are many options can be found related with this command.

Ls -l – gives long listing showing the file size and permissions.
ls -la – Gives a long listing of all files in the current directory including “hidden” files with names staring with a dot
ls a* – Lists all files in the current directory whose names start with a
ls -l *.doc – Gives a long listing of all files in the current directory whose names end with .doc
ls -h – prints sizses in human readable format.


mkdir - create a new directory
this command I use for creating new directory.

mv - move or rename a currently existing disk-file/directory
To move or rename a file ore directory use this command. If I want to copy a file one server to another then scp command must be used.

rm-delete one or more disk-files
If I want to remove file from the disk, using this rm command

rmdir - delete a directory
In this command remove a directory from the disk. Before remove aware of the data of directory. After removing we cannot restore the data.

cat – concatenates files
This command can be used to join multiple files together and print the result on screen.
xiscom@comitg20# cat struts-config.xml

If we run the cat command for both files, we can print together the result on screen.
xiscom@comitg20# cat struts-config.xml web.xml


cp- copy a disk file/directory to a new location
Copy one or more files to another location

Copy a file in the same server
cp filename tolocation

Copy a directory in the same server
cp -r directoryname tolocation


Copy file one ftp server to another
first ensure that two servers communication availability and check user privileges
First you must login to server1 where file is located.
where server2 can be IP or server name.

Filename: test.html
Path to copy : /root/test/
ftp user name : user

[server1]$ scp test.html user@server2:/root/test/
Password: 'provide the destination servers user password'

Example
scp test.xml xis211@192.165.1.211:/opt/xway/xid211/xid/test
xis211@192.165.1.211's password: xis211

copy an directory one server to another
scp -r INSTALLATION xis211@192.165.1.211:/xiscom/data