Advance System administrations commands

This tutorial explains vi command and its parameters in details with examples.

In our last section your have learnt about cat command. cat is a very basic command you cannot depend on cat command in exam to create files as cat is a very essential command.

Before we go further just learn how to create a hidden file in linux and see it.

$cat > [.name of file]

A single dot in front of the file will make it hidden. For example to make a file named secret to hidden use this command

$cat > .secret This is a secret file

Now normal ls command will not list this file. Do a ls form current directory


As you can see in output .secret file is not shown here. But can see hidden file with –a switch.

$ls –a .secret

Now rename and make it unhidden. Use mv command to rename the file

$mv .secret test $ls test

vi editior

If we want to change the matter of file cat will not do it for us. So we will use vi editor to change matter of file.

$vi test

This will open a window with bilking cursor. vi editor work in three different mode.

Esc Command mode [press Esc key before giving any command]
Insert Insert mode [ to start editing use press Insert key ]
Exit Exit mode [ Exit mode can be access via press Ecs key and :]

Beside it there are various command which can be used to control the behavior of vi editor, some of them most command are there to remember

Esc +:+w+q      save and exit form file
Esc+:+q+!       exit without saving
Esc+:+set nu    to show hidden line
Esc+:+/test     to find test word in forward directions
Esc+:+21        to move cursor in line number 21
Esc+:+2+yy      to copy 2 line form cursor
Esc+:+p         to paste the copied line below the crusor
Esc+:+dd        to remove the entire line
Esc+:+4+dd      to remove 4 line below of cursor
Esc+:+x         to remove single character
Esc+:+e         to go to end of the word
Esc+:+h         to go one character back