Useful UNIX
********************************************************************************************************
********************************************************************************************************
UNIX is an extremely straight-forward computer language. There are several commands		       |
that act like acronymns. Lets get started!							       |
********************************************************************************************************
********************************************************************************************************
                                                                                                       |
#1. Open a terminal window by clicking on its icon below.                                              |
                                                                                                       | 
--------------------------------------------------------------------------------------------------------
                                                                                                       |
                                                                                                       |
#2. type the following:  									       |
												       |	
%pwd               (present work directory) -> you will see /homes/metogra1/username                   | 
%ls                (list)                   -> your files/folders will appear, there may not be any    |
%ls -l             (list long)              -> your files will have detailed info (may say o total)    |
%mkdir worddocs    (make directory)         -> you will create a directory called worddocs             |
%ls -l                                      -> there will appear your new directory                    |
%cd worddocs       (change directory)       -> you will now be in worddocs                             |
%cd ..             (go back to previous)    -> you will go back to home directory                      |
%ls -l                                                                                                 |
                                                                                                       |
So lets pause and explain what this means:                                                             |
       												       |
												       |
--------------------------------------------------------------------------------------------------------
                                                                                                       |
												       |
#3. You will probably see the following, 							       |
												       |	
drwxr-xr-x   1   username     meto      1245 Sept 5 11:10  worddocs			               | 
												       |
the, d ,means it is a directory								               |
when there is a, - ,this means it is a file              					       |
												       |	
There are then three place holders: 							               |
												       |	
rwx 												       |
												       |	
r means read  											       | 
w means write											       |	
x means execute										               |	
												       |	
the first three rwx are for the user, the second is for the group, and third is for others,	       |
these are called permissions and they may be changed to allow others access or not!		       |
												       |
Consider the numbers 4 2 1, these can be added together to change permissions.			       |	
												       |	
4= read								                                       |
2= write     										               |
1= execute                                                                                             |
 												       |
The command, chmod, allows you to change modes, or permissions, to the user, group, or others          |
												       |	
example %chmod xyz filename					                                       | 	
                                                                                                       |
x=user												       |
y=group												       |
z=others											       |
											               |
%chmod 777 worddocs gives rwxrwxrwx permissions							       |	
%chmod 751 worddocs gives rwxr-x--x permissions							       |
%chmod 711 worddocs gives rwx--x--x permissions						               | 	
%chmod 755 worddocs gives rwxr-xr-x permissions							       |
												       |
												       |
-Username is of course you								               | 
	  											       |	
-Meto is your server										       |
												       |
-1245 is the size of the file									       |
												       |
-then follow the date, time, and filename							       |
											               |	
												       |
												       |
--------------------------------------------------------------------------------------------------------
												       |
											               |	
												       |	
#4. There is a manual available in UNIX that can be used for any command.		               |
												       |
%man passwd										               |
												       |	
Scroll to the end by pressing -enter- until finished or -shift G and enter-			       |
												       |			
*Note: When changing passwd in Linux type:							       |
											               |
%yp passwd 											       |
 												       |	
then follow steps										       |
												       |	
*Note: When changing passd in Windows type:							       |
												       |	
Ctl+Alt+Del then click change passwd								       |
												       |	
												       |			
--------------------------------------------------------------------------------------------------------
												       |
												       |
											               |	
#5. The next step is to learn copying, renaming, and removing files:				       |
												       |
%cp     (copy)                     -> will copy a specified filename				       |
%mv     (renames or moves)         -> will rename or move a spedified file			       |
%rm     (remove)                   -> will remove filename specified				       |	
												       |
												       |
There are also tags in UNIX that allow you to use more command options.            		       | 
												       |
a few are:											       |
												       |
-l (long format)										       |	
-r (recursive)											       |	
-i (prompt before operation)									       |
-a (all hidden files)										       |
-f (force it with no prompts: useful for a long set of files)					       |	
												       |	
an example of this was										       |	
%ls -l												       |	
												       |
Exercise:											       |
												       |
%mkdir powerpoint										       |	
%mv powerpoint power										       |
%rm -ri power											       |	
												       |
Use of Wildcards:                                                                                      |
%mkdir testdir											       |
%cp -r testdir test2dir										       |
%ls test*											       |
%rm -r test*                                                                                           |
********************************************************************************************************
												       |
#6 When Good Processes Go Bad									       |
                                                                                                       |
Sometimes a program will "hang up" and you have to kill it.                                            |
We will mimic this by looking up the manual entry for the 'kill' command, and then stop it without     |
removing the process from the computer's event manager.  Issue the following commands:                 |
                                                                                                       |
% man kill                                                                                             |
% ctrl-z    (this is the 'stop' command)                                                               |
                                                                                                       |
The computer will respond with 'PROCESS ##### SUSPENDED'.                                                |
Where ##### is the process number.  We will use this to kill the process:                              |
                                                                                                       |
% kill #####                                                                                           |
                                                                                                       |
Unless you had removed this process, you would not be able to log out.  In cases where you have        |
accidently created an infinite loop, you could open another terminal window and issue the 'ps'         |
(process show) command, then get the process number and issue the 'kill' command.                      |
                                                                                                       |
*******************************************************************************************************
The UNIX text that I recommend the most because of its excellent presentation		               |
is:												       |
												       |
Ray, Deborah S., and Eric J. Ray. UNIX: A Visual Quickstart Guide. Peachpit Press, 		       |	
Berkeley, CA, 1998.										       |
												       |
********************************************************************************************************