Tuesday, June 29, 2010

Tricks to work with multiple files in Linux using Vi editor

First create the multiple files using touch command and now try to open these files at a time using vi editor as

vi file1 file2

This command will takes you to the first file, i.e. file1, that means you can edit the first file "file1" now. Once done, save the file and now you want to move to the next file, i.e file2.
For that you can use ":n" into your vi editor and press ENTER, then you will move to next file, that is file2.
Now you can do your work with file2 and now you want to come back to file1 again, for that use ":rew" into your vi editor, then you will be at the first file.

This sounds good if you are working with 2 files simultaneously, but what to do if you have number of files as file1, file2, file3, file4, file5,etc

Then for this also use the same command as above for opening the multiple files using vi as

vi file1 file2 file3 file4

Now you can follow the same procedure as mentioned to work with all these files, but one problem will arise this time is that when you are at the fourth file, i.e file4 and you have given ":rew" to come back to previous file, it will directly move to the first file, file1.

What will you do if you want to go to file2 or any particular file, for that you have to use

:e filename

e.g
:e file2 or :e file3

then you can move smoothly to the required files.

From this article, you can edit multiple files using vi editor.

Monday, June 28, 2010

How to recover a root password in Linux using single user mode

Follow the below steps to enter into the single user mode in linux:-

1. use the arrows to select the boot entry you want to modify.
2. press e to edit the entry
3. use the arrows to go to kernel line
4. press e to edit this entry
5. at the end of the line add the word single
6. press ESC to go back to the parent menu
7. press b to boot this kernel

Then your system boots and takes you to the single user mode by providing a console to you.

then you can change your root password using a command as

#passwd root

enter the password of your choice and reboot the system once.
Runlevels in Linux


0 - halt
1 - Single user mode
2 - Multiuser, without networking
3 - Full multiuser mode
4 - unused
5 - X11 (Full multiuser mode with X-based GUI
6 - Reboot

And you can change the the current runlevel by editing the file
/etc/inittab

go to line number 18 showing as below line -

id:3:initdefault:

this means currently you are using the runlevel 3 for your linux operating system. If you want to change it to runlevel 5, then just replace 5 with 3 in above line and save the file & reboot once.
Then you will start with runlevel 5, which is a full GUI mode.

Sunday, June 27, 2010


History of Linux


Linus Torvalds invented Linux itself. In 1991, Torvalds was a student at the University of Helsinki in Finland where he had been using Minix, a non-free Unix-like system, and began writing his own kernel. He started by developing device drivers and hard-drive access, and by September had a basic design that he called Version 0.01. This kernel, which is called Linux, was afterwards combined with the GNU system to produce a complete free operating system.