Suppose your host file looks like this, and you want to add one route to a new website or domain.
#
Comments in a hosts file are preceeded with a hash '#' mark.
127.0.0.1 localhost loopback
::1 localhost
You want it to look like this.
# Comments in a hosts file are preceeded with a hash '#' mark.
127.0.0.1 localhost loopback
::1 localhost
135.1.2.3 www.SpiffyNewWeb.com
Chances are you are in a user subdirectory and you will need to move up a couple levels believe it or not the old dos command ' cd .. [ crlf ] ' will get you
there. Where cd is litterally the character c followed by d. The double dots are
literally a space followed by two periods, and I elected to type [ crlf ] as a
way of saying , 'Carriage Return & Line Feed' or the Enter key.
Yes that is really how you move from directory to directory when you don't use
GUI.
Let's list some commands and what they do first. Remember children, VI, CP/M, UNIX all are not that playful friendly operating system we have come to know and love called Windows.
Every command IS CASE SENSITIVE!
Upon the first opening of a file in VI the editor is by default in the 'Command Mode' meaning it expects you to tell the VI editor program what to do
next. The VI editor is not expecting you to just start randomly typing in new text strings.
Either one of these takes you from Command mode into an edit mode.
-
Lower Case - i - = enables insert will insert what you type before the cursor position.
-
Lower Case - a - = enables append will append what you type after the cursor position.
-
cd .. [crlf] == Will move you up one directory path
-
cd etc[crlf] == will move you down into that directory path.
-
sudu vi hosts == Will tell the OS to use the Super User account, use the VI editor and open hosts.
-
' i ' == insert command in VI data will be inserted before the point of cursor, also changes the VI editor from the command mode into the insert mode.
-
' a ' == Append command in VI will append any data entered behind the point of the cursor, also changes the VI editor from the command mode into the insert mode.
-
' x ' == While in command mode it will delete a character, just incase your backspace key goes on strike.
-
' dd ' == While in command mode it will delete an entire line, I can just see a picket line forming around the backspace key now.
-
' q ' == While in command mode it's the command to the VI editor to Quit.
-
' w ' == While in command mode it's the command to the VI editor to WRITE or save this file.
-
' : ' == Not really a command but an indicator that the VI editor is in fact in Command mode, and ready to receive and process commands.
-
' esc ' == the Escape key, this key tells the VI editor to change from either 'Insert' or 'Append' mode back to the command mode
-
' ! ' == Sometimes called 'Bang' in command mode it's sometimes need in combination with other commands to get the VI editor to process the request.
-
Example :w![ crlf ] will write the file but not exit.
-
Yet if you use :w then [ crlf ] VI pitches you an error.
-
Some single character commands require the bang.
How do you save these changes? A simple escape or quit won't do, and threatening the computer with a loaded .38 doesn't work either, I have tired.
You must first use the esc key. This will tell the VI editor that you want to go back to Command Mode from edit mode.
THEN you must enter the correct exit command string of characters after the Colon.
Usually a lower case letter 'w' then 'q' to write and quit the VI editor and save your file.
In a nut shell your string of command will probably look like this.
* sudo vi hosts [ crlf ]
* i
* enter new hosts entry
* esc
* wq [ crlf ]
I hope this helps you. I have tried to write in a humors fashion in the hope that you remember some of these archaic dry commands. The truth is when these commands and VI was thought up back in 1976 it was certainly cutting edge stuff.