Tony's Very Basic Unix Guide: ============================= Files, and what to do with them: -------------------------------- The basic command for listing what files you have is ls A couple of options for it: ls -l Lists the size and date of files as well as their names. ls -a Lists all files, even hidden files. Hidden files are files you don't see when you do a regular ls. There files have a . as the fist letter of their name. For example, there's sometimes a .mail in your directory. The files are arranged in directories. This is there so you can organize your stuff. For example, you may want to put all the files for a class in one direcory. You can make a directory with mkdir directory_name and you can go to that directory with cd directory_name change to directory directory_name You can erase or remove files with rm file_name You can erase an entire directory and everything in it with rm -r directory_name be carefull with this one. You'll be in you "home" directory when you log in. If you change to some other directories and want to get back to your home directory, just type cd This will put you back to the beginning. How do you know what directory you're in? type pwd Print working directory Editing and Viewing Files: ========================= Viewing files: ------------- An easy way to look at a file is using the 'cat' program. For example, you can cat file_name which will show you the file 'file_name'. The problem is that it runs off the top of the screen before you can read all of it. Try this with your mbox file: cat mbox A better way is to use the 'more' command. This shows one page of the file, and asks you to press a key to show the next page. Press space to see the next page, or q to stop looking at the file. Try more mbox There's also another program called 'less', which is a bit better than 'more'. Try less mbox Editing files: -------------- The basic editor is 'vi'. It's real old, and an incredible pain in the butt. Most systems these days let you use 'pico', which is the same editor you use in the 'pine' mail program. If you're a beginner I recommend staying away from 'vi'. Still, here's some info on how to use it. vi has two basic 'modes'. In one mode you're actuall entering text, and in the other (the 'command' mode) you're playing with the text. You start in the command mode. Try the following: start vi on a new file, with vi junk Edit the file junk Now you want to enter text. You can do this by pressing 'i' on the keyboard. By the way, if I put quotes around the letters, you don't need to actually type those in; just type the letters. Also, vi, and unix in general, care whether you use upper case or lower case letters. Make sure you use the correct case. Once you press 'i', you can enter text. Try it; put some lines in, erase some, see how it works. Note that you can't erase things on the previous line; to do this you need to get into the 'command' mode. To get into command mode, press the ESCAPE key. This is usually on the upper left side of the keyboard. Now you're in command mode, and the letters you press correspond to commands. Moving around: vi has a particularly stupid way of letting you move around in the file. It uses the 'h', 'j', 'k', and 'l' keys. This is just because vi is a real old and stupid program. Try the cursor keys if your keyboard has them. Sometimes those work also. Move around in the file and see what each key does. Some commands: dd (press d twice) deletes a line. Go over a line, and press 'dd'. The line will be deleted. i Put you in 'insert' mode. You can enter text from here. ESCAPE puts you back in command mode. h, j, k, and l: go left, down,up, and right How do you know if you're in command mode or edit mode? Type 'h', 'j', 'k', or 'l', and see if you move around or if the letters show up. If you move around, your're in command mode. If not, press ESCAPE to get into command mode. Saving the file and Exiting vi: vi has yet another way of doing things. When in command mode, press ':'. You will see a : on the bottom left of the screen. Now you can type some commands. Some of these are: :w write the file to disk; i.e. save it. :q quit vi :wq save the file and quit :q! Definitely quit! vi will tell you if you try to quit without saving the file you're editing. This command tells vi to quit without saving the changes. These should do for now. Note that you only need one ':'. For example, to save the file, type ':w', not '::w'.