| Beginning Unix & SSH Tutorial | ||||
|
UNIX is an operating system just like DOS, OS/2, and Macintosh OS are operating systems. UNIX differs from other operating systems in that it is
more efficient at handling multiple users. Unfortunately, UNIX is not quite as user friendly as a Macintosh computer so you have to spend a little time
learning seemingly cryptic commands. Have no worries though, in a matter of hours, after working through this tutorial, you'll be jamming away in UNIX.
Logging into a UNIX machine: First you're going to need to log into one of our machines. To do this you will need an SSH program such as PuTTY if you are using a Windows PC. If you are a Mac OS X user, your OS has a built-in SSH client. Things you are going to need to know
Logging in: Each type of SSH program has their own configuration style. Please consult our other tutorials or your chosen software's help files for inputting your login information to get connected to your server. UNIX Files: Since most of what we do on computers involves working with a computer file we'll spend a minute talking about how UNIX organizes files. The file system is organized in a hierarchical fashion like the branches on an inverted tree. These branches are called directories. Each user has a personal home directory. When you log in to your account you will automatically be in your home directory. You can find out what directory you are in by typing the command pwd. For example type pwd in your shell tool window and you will see something like:
You can use this command to determine what directory you are in. But your prompt 'he:~$' will also notify you of what directory you are working in. If your prompt shows a ~ symbol that means you are somewhere under your home directory tree. ~ = home directory(/home/youraccount/). So ~/public_html = /home/youraccount/public_html. Watching your pathname will aid you in navigating your way around directories in UNIX. The rest of this tutorial is designed to teach you the basic UNIX commands you will need to know in order to survive while working on your account. The best way to learn is by doing so each command will be followed by a short exercise in using it. UNIX CommandsListing the files in a directory: ls If you type ls you will see a list of files in your directory. So, type ls in your shell window and hit return. Chances are you will not see anything since your directory is empty. However, there are some files hidden in your directory that do not appear since they most likely not need to be changed (they are for 'administrative' purposes). Here are a few recommended options you should try with ls:
- shows you all the files in your directory, including hidden ones.
- shows you the files in your directory in long format. Giving you the ability to see file persmissions, owner of file, creation date, and filename.
- combination of the two above.
- lists files in standard format with a number to the left of the name this number is the size of the file in blocks -- 1 block = 1024 bytes. So 28 blocks would equal about 28k. The 'F' in ls -sF allows directorys to be destinguised from files in that they will appear with a slash(/) at the end of their name. It is recommended you try and use ls -l at most times to easily fammiliarize yourself with the files you are working with. Copying a file: cp Here is a quick list of things you will need to do in order to get a quick idea how the cp command works. Once you get to the shell prompt:
you will need to type the following commands in order to create your dummy text file. Enter a return after each line, once you finished typing 'this is a text file' hold down your control key and press c.
Once you have created your file to test with you can start testing the cp command to see how files are copied around.
Once you are finished you will have created a file called test.txt.backup it will be an identical copy of the original file. Looking at a file: more or cat There are two UNIX commands that allow you to look at a file they are:
and
If you want an entire file to dump to your screen at once type:
You can now see what was in the file junk that you copied. Now type:
Now you can see that you successfully copied the file test.txt to the file test.txt.backup. The second way to look at a file, more, is better if a file is longer than the window you are going to look at it in. The more command allows you to scroll down through a document one screen full at a time. You probably do not have a file bigger than one page in your directory so for the time being type:
Removing (deleting) a file: rm This command is used to permanently delete a file. To delete the file you created in the previous command summary for cp type:
To help conserve on disc storage space please be sure to delete files that are unnecessary. Making a directory to organize files: mkdir The command mkdir creates a new directory. You will find it useful to make a new directories to organize your files. So, to make a directory for this tutorial, which you will put some files in later, type:
Now type ls -l and you will see the new directory temp. Now type:
to copy your file test.txt to your new directory named temp. Notice that if you type ls -l, the file test.txt still exists in your home directory. The copy command leaves the original file in intact. Changing directories: cd To change to temp, the directory you just created, type:
Now type ls -l to make sure that your file test.txt was copied to this directory. To move back one directory, to your home directory in this case, type:
Suppose you have created several directories within directories and you want to quickly go back to you home directory without having to type cd .. several times. If you type:
you will automatically move back to your home directory from where ever you are. Moving files from one directory to another: mv You should now be in your home directory. Type pwd to make sure. The mv command has a couple uses. You can move a file from one directory to another (without leaving a copy of the original file in the first directory, like the cp command does) or you can change the name of the file. To use this command to rename your file test.txt to a new name, test.html, type:
Now type ls -l to make sure the file test.txt has been replaced with the file test.html. Also, type 'more test.html' to verify that test.html is the same as test.txt was. To move the file test.html to your new directory temp type:
Go to your directory temp and type ls -l to make sure that test.html is in there. Editing a file: pico If you want to edit a file you need to use the text editor program and load the file into it. To edit the file test.html type:
Now that you have the file test.html in your text editor, make some changes to the file -- add another line with the contents:
Once you are done typing that line you will need to hold down the control key and press O (Control-O to save) and then hold down the control key and press X (Control-X to quit). You should now be out of pico and back at the UNIX prompt. Type:
at your shell prompt to verify that your changes were correctly saved. Changing your password: passwd Odds are that the password you were assigned is rather peculiar and cumbersome. To change your password to something that you can more easily remember type:
and follow the UNIX prompts. Note: security is an important issue on UNIX machines because hackers love to break into systems and crash them. To avoid this problem please take care to do the following with your password:
Sending email: pine Pine is software for sending, receiving, and organizing electronic mail. It is easier to use than the standard UNIX mail reader because it offers on-screen menus and help. This help-file provides basic directions for using Pine. Other advanced features that can be learned through Pine's "Help" menu. Starting Pine
Note: Pine has a menu system to help you with commands. The ^ means "control." Therefore, ^C means you should press control and c together. Sending Email
Reading Email
Marking Messages For Deletion To delete a message you are currently viewing:
To delete a message in the mail index:
In the Mail Index, you will see a D in the left column next to any messages marked for deletion. You can mark more than one message to be deleted. You will be asked to confirm message deletion when you quit Pine. Unmarking Messages For Deletion i to display the Mail Index.
p or n (up or down arrow) to highlight the message you want to unmark.
u to unmark the message for deletion.
The D next to the message in the Mail Index will disappear and a message will be displayed indicating it will no longer be deleted. Postponing a Message
Quitting Pine
UNIX help manual: man The man command calls up the UNIX on line help manual. This command provides a lengthy description of a specified UNIX command. To activate this command type "man Unix_command." For example type:
or to find out more about the man command type:
Logging out of the shell: exit Exit is used to log off the system and end your current session. When you are ready to leave your SSH session type:
Once you're done you should get disconnected and you can now close your SSH program. This completes the beginning UNIX tutorial. Several books are available at the bookstore that provide more in-depth explanations of UNIX and its capabilities. If you are really serious about learning UNIX I suggest picking up a book, or two (for cross referencing), on UNIX so you can use this complicated operating system to your advantage. The book UNIX for Dummies by Levine and Young has been found to be rather useful when learning the basics of Unix. A couple other Unix tutorials on the Web that may be useful are:
|
||||
|
Hurricane Electric 760 Mission Court Fremont, CA 94539 |
FAQ Index
--
Tutorial Index Copyright © 1994 - 2004 Hurricane Electric. All Rights Reserved. |
Voice 510.580.4100 Fax 510.580.4151 Comments? info@he.net |