Sponsoring website: Emergency Boot CD

An Introduction to
Linux Console Commands:
Using the "vi" Text Editor and Mounting Floppy Diskettes

Copyright © 2003 by Daniel B. Sedory

You may copy this page for Personal use only!
Any other use must have the author's permission!

[ Note: This series usestomsrtbt  Boot Disk " ]

( Although this page was created mainly for those unfamiliar with UNIX/Linux commands, some of the
examples here examine the inner workings of "tomsrtbt" boot disk; which may interest even an expert. )


     I started editing computer text files way back under MS-DOS 3.30 with a program called EDLIN; which seemed like a horrible little thing, especially since I had already used an editor made by another software company. Later on, Microsoft finally came out with their EDIT.com program which was a vast improvement using thoughtful menus and even mouse functions. But, there are some important things that EDLIN can do when run from Batch files that EDIT can't, so EDLIN is still found today in Windows NT and even Windows 2000 installations!

    At first, the Linux vi text editor reminded me a bit of the old EDLIN; with its difficult to remember keyboard commands, but long before vi, UNIX had something similar to MS-DOS's EDLIN known simply as ed (which could edit files only one line at a time)! Well vi is much better than ed ever was! And unlike the old DOS installs, tomsrtbt comes with some help files; including one for vi: Enter the command: man vi to read it... pressing the ENTER key to move line-by-line or the SPACE BAR for a whole page, and "q" to quit reading. Much of this file may not be very useful to you at this time, however sections "7.0 - Alphabetical vi quick reference" (for the Visual Command Mode commands) and "7.1 - Command mode input options" (for the ": ex" commands) are good references. In this file, you'll find out that tomsrtbt actually uses a program called "Elvis" (in place of the real vi). Anyway, this editor could 'save you a lot of grief' some day (especially on a Linux box), so you really should know how to use some of it at least....

There are three different modes of operation under vi (or Elvis):

1. Visual Command Mode -- the default when you first start vi without any filename. You can see in the lower right-hand corner of the display that the word "Command" is highlighted, and the numbers to the left of that show which LINE and COLUMN the cursor is located at. As you enter various commands, vi will often display notes or errors

in the lower left-hand corner of the screen... such as the one above which informs you there's "[NO FILE]" to edit. The "~" symbols along the left side let you know that there are NO LINES there! Anything above those symbols are blank (but real) lines. Obviously, there's not much you can do in this mode without any text in the editor, so let's open a text file using the command:
vi /usr/man/fstab
Although you may have guessed that /usr/man is where the manual pages are located, this file shows that an entry for a manual page can be something other than an executable file. Here's how some of it appears in the vi display:

Now you know that a file opened in vi will show you how many lines it has (the "62 lines," above) and the total number of characters it contains (the "2218 chars") after the filename ("/usr/man/fstab"). Note: the cursor was moved to line 23, column 6. You can move the cursor in the Visual Command Mode using the Left-, Down-, Up- and Right-Arrow Keys (or the h, j, k and l keys respectively), plus the PageUp, PageDown, Home and End Keys.

2. Insert Text Mode -- this mode is activated by pressing various keys under the Visual Command Mode. In order to begin inserting text at a particular column (in front of the character that you place the cursor underneath) you would simply move the cursor to that position, then press the "i" key. For example, after placing the cursor on line 43, column 7 and pressing the " i " key, the word "local" and all the text following it on line 43 would move to the right of any characters you type:

Pressing the ESCAPE Key while in the Insert Mode, will return you to the Visual Command Mode. Other common commands used to enter the Insert Mode are:

a - Insert text  after the character above the cursor.
i - Insert text before the character above the cursor.
A - Insert text at the end of the current line.
I - Insert text at the beginning of a line.

Sorry, but I have to go on to something else now...
Will get back to this when I can!

Oh, two very important commands:
1)
To exit the vi text editor without saving changes:
Press the
Escape key to make sure you're not in an Insert Text Mode, then type a colon (:) symbol, followed by the "q" key and "!" symbol. If you forget the '!' symbol, you'll see this error message:
"
Use q! to abort changes, or wq to save changes "
2) And typing "
:wq" and the ENTER key saves them.



Mounting an MS-DOS/Windows9x (FAT12) Floppy Diskette under tomsrtbt Linux in your A: drive:        mount -t vfat /dev/fd0 /fl

This will allow you to both read from and write files to the floppy disk through the /fl directory. After using any mounted filesystem, you should get into the practice of always unmounting them with the  umount command (note: this is not a typo error! There never was an 'n' between the "u" and "m" of the "umount" command!)

 


OK, I'm very sorry for not having had the time to get back to this page in months now; I've not only become involved in other projects, but disliked some of the quirky behaviour of BOCHS while running it under Windows! As usual, Apps. originally made for Linux work better there!!

Since you've made it this far, I felt you at least deserved some links to other resources (and most likely you'll be wanting to install a full-sized Linux OS on your HDD now anyway). Here are some of the best I could find:

Floppix (Linux on Two Foppy Disks) -- See the "Labs" Pages for an Introduction to Command-Line Linux using the diskettes; with Exercises!


Linux for Newbies
-- 25 Easy Reading Pages about Linux by Gene Wilburn. Getting rather out-of-date now (from RedHat 6.x to 7.1 days; RH 9 has already been made... so many links on these pages may no longer work or be as useful!), but once you read through them you'll have a very good idea of the major topics in Linux. You could also skim through some of his other Linux pages here: LinuX Inside!


The RUTE Book -- Rute (root) User's Tutorial and Exposition. DOWNLOAD the whole thing as a .PDF file which makes a good searchable Reference Source! (NOTE: The download is actually a 3.17MB .bz2 file which turns into the .PDF file if you have a .BZ2 decompressor: WinRAR or bunzip2 will do this for you.) Personally, I think the HTML version is better for normal reading, but you might not be able to D/L it as a single file; the link didn't work for me!

"This book covers GNU/LINUX system administration, for popular distributions like RedHat and Debian, as a tutorial for new users and a reference for advanced administrators. It aims to give concise, thorough explanations and practical examples of each aspect of a UNIX system."

This thing has just about everything you'll need and then some, but may still have some 'typo' errors and difficult to comprehend passages. As I've always told students: "Don't depend upon only one resource for anything you really need to understand completely! Consult at least three or more sources on the same topic to be sure you understand things correctly."


Next Session:

Not sure if there will ever be another one!

 

Last Updated: 12 APR 2003.


 

The Starman's Index Page