Вы находитесь на странице: 1из 2

Introduction to UNIX commands

Vi Editor:
It is a screen oriented text editor originally created for UNIX operating system.

Modes of Operation
While working with the vi editor, we usually come across the following three modes

 Command mode − This mode enables you to perform administrative tasks


such as saving the files, executing the commands, moving the cursor, cutting
(yanking) and pasting the lines or words, as well as finding and replacing. In
this mode, whatever you type is interpreted as a command.

 Insert mode − this mode enables you to insert text into the file. Everything
that's typed in this mode is interpreted as input and placed in the file.

 Execution mode- Pressing a ‘:’ in command mode invokes this mode.

vi always starts in the command mode. To enter text, you must be in the insert mode
for which simply type i. To come out of the insert mode, press the Esc key, which
will take you back to the command mode.

Basic Vi Commands:
Sl.no Command Description

1 :q To quit without saving

2 :w To save the file

3 : wq To save and quit the file

4 : q! To force quit
UNIX Commands
Commands Syntax Description
Vi Vi filename.c Used to create a file
cc Cc filename.c Compile the file name and create executable
file a.out. This is executed using ./a.out
command.
cp cp file1 file2 Copy file into directory
rm rm filename Remove or delete file
mv mv file1 file2 Move or rename files
man man Online manual (help) about command
commandname
mkdir mkdir Make a directory
directoryname
cd cd directoryname Change to directory
cd .. Move back to old directory
rmdir rmdir To remove a directory
directoryname
ls Lists files in current directory
Exit To exit the shell

Navigation and editing of text


Sl.no Command Description
1 k Moves the cursor up one line
2 j Moves the cursor down one line
3 h Moves the cursor to the left one character position
4 l Moves the cursor to the right one character position
5 a Inserts text after the current cursor location
6 o Creates a new line for text entry below the cursor location
7 x Deletes the character under the cursor location
8 dd Deletes the line the cursor is on
9 yy Copies the current line.
10 p Puts the copied text after the cursor.
11 $ End of the line
12 u undo
13 e Move forward to end of word
14 w Move forward to beginning of word

Вам также может понравиться