creating an .htaccess file

I don't know anything about Unix but I have to create a htaccess file and a htpasswd file. I have instructions that tell me to "create an htaccess file using the vi editor" How do I get into the directory that should be password protected and how do I start creating the htaccess file? If I can get these two things answered, I think I will be okay, but if there is anyone who wants to offer more info, that would be great too!

Sorry, I'm such a dummy - but I hope someone can help me.

Thanks so much!

The "pico" editor would be easier to use if it is available on your system.

cd <directory_name>
pico .htaccess

If you do not have pico, then:
vi .htaccess

Once in vi, hit "i" to enter insert mode. type your text.
Hit the escape key to leave insert mode, then ":wq!" to write to disk and exit. If you prefer to quit without saving, it would just be ":q!"

Create the .htpasswd file with something like:
htpasswd -c /your/home/directory/.htpasswd username

[Edited by PxT on 02-06-2001 at 05:29 PM]

Another good option to set for the vi newbie is showmode. This will show you whether you are in insetr mode etc. To do this, type
:set showmode
once you open vi.

Thanks to both of you for your help. I was able to create the .htaccess file just fine. Now, when I'm trying to create the htpasswd file, I type this:

/usr/sbin/htpasswd -c .htpasswd whitney

and I get this message:
usr/sbin/htpasswd: cannot open file .htpasswd for write access
fopen: Permission denied

What the heck? Any suggestions?

Thanks again!

Sounds like your user does not have write permissions to the directory (or to the .htpasswd file if it exists). From the directory where the .htaccess file exists, type;
ls -ld .

You are looking for either group or user write permissions;

If there is no w in the third or sixth position, type;
chmod ug+w .

If that checks out type this from within the directory that the .htaccess exists;
ls -la .htpasswd

If it exists, examine the permission and correct as above.

Well, the w's were there and it looked good so I logged out and logged back in and it let me do it!

Go figure!

Anyway, thank you so much for your help - you're a life saver.