OpenSolaris  
 Open Source Software for Solaris
An OpenSolaris Community Site
 Current Software Packages
Open Bug Tracking
   

         : Action to Take : sorry but we need to use vi as the root user to fix this. Read below


image 152
click image for full size

 • An Apology for vi :
    I don't have a soft and gentle way to introduce you to vi. It is not user friendly. It may actually be the most user hostile editor in the world with the exception of front panel binary toggle switches, which I hope you have never had to experience. The vi editor, if you know it, you generally love it. In the UNIX world the vi editor is a rite of passage and you will need to know it with a reasonable degree of fluency in order to function. What I will do here is give you the absolute minimal that you need to get the job done and then hope that you survive. If you come from the Microsoft Windows world then I suggest you brace yourself for a terrible shock to the senses. There is no other way to put it. I'm sorry.

 • vi gets the job done - every time
    Regardless of the fancy looking graphical user environment you need to know that you are in UNIX land now and you will do things in a UNIX way. That means you will edit files with the vi editor and you will discover that it gets the job done every time without fail. When you really need to edit a file and you have nothing but an old DEC VT220 terminal ( the best ever! ) hooked to the serial console of a server then vi will work. If you have to telnet or ssh into a server half way around the world with nothing but a 9600 baud modem link then vi will work. So welcome to UNIX and let's get the job done. Let me walk you through the steps simply and then I will explain more below.

    The issue on the table right now is name resolution. Every server and web site on the internet has a specific ( and hopefully unique ) network address. We call that the ip ( internet protocol ) address and you generally see it described as a sequence of four decimal numbers separated by dots. Like 192.168.35.44 for example. Every server and every website has at least one of these addresses but no one really uses them much unless forced to. If we want to go to a website we simply give the browser an address of www.sun.com or maybe just sun.com. Somehow your browser needs to convert that name over to an address like 72.5.124.61. That process is called name resolution in that the URL ( uniform resource locator address ) www.sun.com must be resolved to the address 72.5.124.61 without the user doing anything special. There are special purpose network services called name servers or Domain Name Servers that do the hard work for us. The internet is always in a state of change so we need some special servers to track those changes and provide name resolution for us. We call these servers our DNS servers and you need at least one of them.

    You need to ask your network admin for the ip addresses of your DNS servers. Hopefully you have a few of them. Once you have these ip addresses you then put that information into a special configuration file called /etc/inet/resolv.conf which is located in a special area where nearly all network config information resides. That file needs to be created with the vi editor. Even more important is the fact that no one can simply do this without special security clearance. You will need to be the root user in order to get the job done.

    Follow these instructions carefully.

You will need to become the superuser or root level user with the command su. Generally it is wise to type this command in as su followed by a single space and a dash. That means that you want to become the root user as well as have the correct environment variables in place as if you actually logged in just like the root user from the very beginning. You will need to then enter the root user password. bash-3.00$ su - Password: Sun Microsystems Inc. SunOS 5.10 Generic January 2005 #

    We now need to start the vi editor and create our new file called /etc/inet/resolv.conf thus :

# vi /etc/inet/resolv.conf Your terminal window should instantly change into the editor window for this new file. You will see a series of squiggly tilde characters ( ~ ) along the left margin as well as the status line at the bottom. The status line will tell you that this is a New File like so : ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "/etc/inet/resolv.conf" [New file] If you see that on your terminal window then all is perfect. Do not just start typing or banging away at the keyboard !

    The vi editor is now waiting for you to tell it what to do with some really simple commands. The only one that you need to know right now is the insert mode command. The vi editor may look like it is ready to receive the contents of the file from your keyboard but don't be fooled. Its just waiting for a command actually. So press the letter i ( lowercase i as in india ) and then you will see nothing happen. That's right. Nothing. The vi editor shows you that it is ready to receive input with no indication at all. User friendly eh?

    Suffice it to say that you may now type in the following strings precisely as described below. Where I show you <tab> I mean that you press the tab key. Where I show you <cr> I mean that you press the enter key. Where I show you <ESC> then you press the ESC ( escape ) key. Got that? Now do this exactly as I show you :

nameserver<tab>192.168.35.1<cr> nameserver<tab>192.168.35.254<cr><ESC>

    Everything that you type will go straight into the file up until you hit <ESC>. When you press the <ESC> key you are telling the vi editor to stop with the input of data and to switch back into command mode. By command mode I mean that vi will not enter data anymore but will sit there waiting for a command. Like the letter i that tells it we are going to insert text into the file. The vi editor is really simple when it comes to input. Just press the letter i and it starts taking in data and shoving it into where the cursor happens to be. Hit <ESC> and it stops. Moving the cursor around after you hit <ESC> should be dead easy. Just use the arrow keys on your keyboard. If you don't have those arrow keys ( and who doesn't these days ? ) then there happens to be the ultimate in geeky cursor navigation commands for vi. These are the trademark geek squad little things that separate the UNIX people from the get-a-real-computer types. For your further edification here they are :

the vi navigation keys are h j k l k ^ | up | h <— left — • — right —> l | down | j

    Most people, with enough experience in UNIX, will never touch the arrow keys at all. This page was written entirely with vi as were all the rest. It simply becomes second nature. For now we will concentrate on getting your name resolution information set correctly and leave further vi gymnastics for some other day. I do need you to know that there is a fantastic vi tutorial at the Purdue University website. You will be able to read it from your new Solaris 10 machine when we get your DNS data entered! Here is the tutorial address :


    If you followed my instructions carefully then you most likely have a file with two nameserver lines in it and they are both wrong for you. That is fine. I just wanted you to edit a file. Now I want you to enter the correct data and you will do that by going into insert mode again. Just hit the letter i and then the enter key. Type in the keyword nameserver followed by a <tab> as well as the ip address of your first DNS server. At the end of the line you hit the <ESC> key to stop data entry.

    Since we know that both of the top lines are wrong we can just delete them. How? Well you press the k key a few times to move up the file to the top line. Then press the d key twice ( dd ) to delete the entire line. That line will vanish and the rest of the file will move upwards. These are little things that we take for granted with modern big bloated word processing software. Remember that vi was written such that it will run in the smallest of systems with little or no graphics, bandwidth, or memory.

    At some point you may wonder if we will ever actually write this file out to the disk. Thus far everything that you have done is in memory and thus you have done no damage and no change to the system. That is good to know. If you want to write out this data as a file onto the filesystem then you do the following :
To write out the file just hit <ESC> once in order to ensure we are not in input mode or edit mode. Then press the colon key : followed by a letter w ( w as in write ) and then hit enter. What you will see on the terminal screen will look like so : nameserver 192.168.35.245 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ :w and then after you hit enter you see this nameserver 192.168.35.245 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "/etc/inet/resolv.conf" [New file] 1 line, 26 characters

    You may have written two lines of data to that new file or just one. It really depends on if you have one or two DNS Servers. I only entered one for this example.

    Note that vi is still running and that just because you wrote the file out to disk does not mean that you can not keep making changes. The file that you are working with within vi is really just a buffer in memory and thus the file on disk will not change until you actually issue a write command to vi. Therefore I want you to now modify this such that we have your domain name as well as one more DNS server if you have it. I want you to open up a new blank line above the uppermost line of this file. You do that by simply hitting the k key to position your cursor on the top line and then hit the capital letter O ( O as in Open ) to open up a new line. Then type in the keyword domain followed by <tab> and then the name of your internet domain if you know it. If your new system is inside a network with the domain name sun.com then you may enter sun.com. If the name is wikipedia.org then please enter that after the <tab>. If you ever make a mistake then just hit <ESC> and then use the letter x to delete characters one at a time. Or use dw to delete a word. Or use dd to delete the whole line. Use the capital letter O to open up a new line above the current cursor location. Hit the <ESC> key anytime you think you are in the wrong place and then navigate around with those h j k l keys. Or the arrow keys if you need to. What I am saying here is just get your domain name and nameserver data into that file just like what you will see on the next page. :-)





<< previous     next >>


  ©2002-2007 blastwave.org.    OpenSolaris and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.     UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd.      All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the United States and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc.      All other logos and trademarks are registered through their respective owners.      ©2002-2007 blastwave.org™      See “Terms of Use”      Sun™ Logo and OpenSolaris™ Published with Permission from Sun Microsystems, Inc. Valid HTML 4.01!
Valid CSS