Sunday, October 18, 2009

VI Improved - Tutorial

Share Orkut

How many people using unix like system do you think, have atleast a basic knowledge of using one of the most powerful editors of the platform? There are many who don't like to use VIM, purely due to its 'UN-GUI'ishness; they tend to go in for other simple to use and comparatively less geeky alternatives like 'nano'. What will you do when you are faced with a scnerio where there are no options other than using it ?

This tutorial aims to let you understand the extremely basic stuff you should know about VIM; bewarned that this is not even worthy of being mentioned as the 'Tip of the Iceberg'. VIM is an extensive tool which might take months to master.

To start VIM & open a file, say 'new.txt'; we type the following at the terminal,

'vim new.txt'

now you will see the contents of the file new.txt on your screen, at the last line will be written, "new.txt" 9L, 45C; this means that the filename is "new.txt" having 9 lines of data & size 45bytes (1 char {C}= 1 byte). This mode is called normal mode or command mode.

Now you want to edit the file, go to the character from where you would like to 'insert' text and press either 'a' or 'i'. If you press 'a' the cursor will advance 1 character forward and start inserting and if you type 'i' the cursor will start inserting at the current position. This mode when you insert data or text is called as 'insert' mode, to come out of the insert mode to the command mode, press 'Esc' key.

If you wish to delete some text then follow the same steps for editing to enter the 'insert' mode and use 'Backspace' key to delete charecters, again using 'Esc' key to exit the 'insert' mode and enter the 'command' mode.

Now that you have edited the file, you have to options; either save the changes done to the file or discard the changes and quit VIM.

To save a file type ':wq' in the 'command mode', (Note: - ':wq' will not work in the insert mode), if you want to save the file with another name use ':W FILENAME' in the 'command' mode, but in this option VIM will save the file with the name you specified and continue to edit the old file, and another command is ':saveas FILENAME' which is the same as ':w FILENAME' but it will now edit the new file after saving.

To quit the VIM editor use the command ':q', which is only allowed if the file has not been modified. If you wish to discard the changes and quit type ':q!'.

These are just 'dirt basic' that you need to know if you are going to use a Unix machine, VIM is too extensive to be covered in a few blog posts. Hope it helps even if its a bit. If you have any queries, feel free to post them as comments and I will surely try to clarify them.

Saturday, October 17, 2009

pppoe configuration in Ubuntu Linux

Share Orkut

Yesterday after getting irritated with the '$ sudo pon dsl-provider' command for my pppoe connection, I decided to shorten the length or atleast make it simpler, something like '$ sudo pon bsnl' or simply '$ sudo pon'.

According to the MAN pages on pon it requires a parameter to specify the provider which has to be dialed, on absence of provider it executes the file '/etc/ppp/pppoe_on_boot', if it is existing and executable.

Again on lack of arguments to the '$ sudo pon' and absense of the '/etc/ppp/pppoe_on_boot' file (which is created when you specify that the connection be automatically dialed up at startup), in such a case the '/etc/ppp/peers/provider' file is executed' which is often the cause of error to most people.

If you have a look at the file '/etc/ppp/peers/dsl-provider' you'll realise that copying the contents to a new file will enable you to use a command such as '$ sudo pon isp'

Steps for '$ sudo pon isp' - Run the following commands in a terminal:
  • $ sudo cp /etc/ppp/peers/dsl-provider /etc/ppp/peers/dsl-provider.bak (optional)
  • $ sudo cp /etc/ppp/peers/dsl-provider /etc/ppp/peers/isp
Now a command like '$ sudo pon isp' will dial your pppoe connection.

Steps for '$ sudo pon' - Run the following commands in a terminal:
  • $ sudo cp /etc/ppp/ppp_on_boot /etc/ppp/ppp_on_boot.bak
  • $ sudo cp /etc/ppp/peers/dsl-provider /etc/ppp/ppp_on_boot
Now a command like '$ sudo pon' is sufficient for conecting to the internet.