home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / a_m / hnet01.03 < prev    next >
Encoding:
Text File  |  2003-06-11  |  12.6 KB  |  266 lines

  1.                 H-NET H-NET H-NET H-NET H-NET H-NET H-NET H 
  2.                 N                                         N 
  3.                 E          ** H-Net Magazine **           E 
  4.                 T                                         T 
  5.                 H   Volume One, Issue 1, File #03 of 20   H 
  6.                 N                                         N 
  7.                 E  An Introduction to UNIX, by MINOTAUR.  E 
  8.                 T                                         T 
  9.                 H-NET H-NET H-NET H-NET H-NET H-NET H-NET H 
  10.  
  11.  
  12. UNIX is widely-touted as 'the operating sustem of the future', though in fact 
  13. it dates from 1969 (it was developed originally by Bell Laboratories, which 
  14. runs most of the telephone systems in the USA).  Since then it's been under 
  15. continuous development; so it's not so much an old operating system as a fairly 
  16. mature one, if you see what I mean. Hackernet BBS has many unix files for you.
  17.  
  18. Unix gets brownie points straight off because it was conceived by a user of 
  19. computers rather than a software specialist or some other sort of software 
  20. designer.  So it is relatively easy to use; which nearly all other software the 
  21. prime goal often seems to be to make money, or to sell more hardware and 
  22. software, or whatever. 
  23.  
  24. In brief, UNIX is a general-purpose, multi-user operarting system with a clever 
  25. method of holding files.  It's a complex system, which means both that it is 
  26. rich in facilities and difficult to get to grip with - until now!..... 
  27.  
  28. BEGINNER'S GUIDE TO THE WONDERFUL WORLD OF UNIX 
  29. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  30.  
  31. The aim of this first textfile is to give an insight into the fundamentals of 
  32. UNIX.  Subsequent textfiles will delve into all areas of UNIX in greater depth. 
  33.  
  34. WHAT IS UNIX? 
  35. ~~~~~~~~~~~~~ 
  36.  
  37. The UNIX operating system can be divided into a number of distinct parts. First 
  38. there is the part of the system which performs all of the interface to the 
  39. hardware, scheduling disks, managing memory, handling terminal I/O and 
  40. generallu handling any requests to and from the devices on the system.  This 
  41. part of UNIX is called the UNIX Kernel.  It is in fact one large, compiled 'C' 
  42. program which is kept on the hard disk and loaded into memory when the system 
  43. is booted up.  The UNIX Kernel is always kept in memory because practically 
  44. everything that is done on UNIX uses the Kernel.  Buts on its own, it is of 
  45. little use.  There is no point in just having an interface to the hardware - an 
  46. itnerface to the user is also required.  This is provided by the UNIX shell. 
  47.  
  48. The shell is another name for a TIP (Terminal Interface Program) or a JCL (Job 
  49. Control Language).  Its job is to read input from the terminal and execute the 
  50. right programs, depending on the input.  A program which is executing in UNIX 
  51. is called a process.  In fact, the shell is also a 'C' program which is 
  52. executing for each terminal which is logged on.  It reads input from the 
  53. terminal, interprets the input in various ways and starts the appropriate 
  54. processes.   
  55.  
  56. As well as interpreting input and executing processes, the shell has its own 
  57. control-flow constructs and it can therefore be used as a programming language. 
  58. It also handles pipes and redirection of I/O which will be the subject of a 
  59. later textfile. 
  60.  
  61. The way the UNIX shell works is much the same as other operating systems. It 
  62. displays a prompt, normally '$' the user types in the command to execute and 
  63. the shell reads the command, searches for the program which is the same name as 
  64. the command typed in and it then executes this file, if it found it.  When the 
  65. program finishes executing, the shell redisplays the prompt to the terminal. 
  66.  
  67. OK, so we have a Kernel to handle the devices and a Shell to interpret input 
  68. form the users terminal.  The final and by far the largest part of UNIX is the 
  69. Programs.  There are many Programs in UNIX which form a part of the operating 
  70. system.  In UNIX jargon, these are called Utilities.   
  71.  
  72. There are Utilities to look at directories, edit files, semd files to the line 
  73. printer, perform backups, look at files, delete files, the list is endless. 
  74. These Utilities are, to the user, commands which are typed in at the terminal 
  75. prompt.  For example; 'ls' is the UNIX Utility to list the directory; 'cd' is 
  76. the Utility to change directory.  In some systems the Utilities form a part of 
  77. the terminal interface program which interacts with the user.  In UNIX, very 
  78. few Utilities are a part of the Shell, the majority of them are external to the 
  79. Shell and are called up whenever they are needed.   
  80.  
  81. This is because there are 200-300 UNIX Utilities, and including all of them in 
  82. the shell would obviously increase the size of the Shell to an unreasonable 
  83. level.  It is much neater to keep them on the disk to be called as and when 
  84. they are needed.   
  85.  
  86. On a typical UNIX system, as well as the operating system, there would also be 
  87. some other packages, word processing, spreadsheets, etc.  These are necessary 
  88. because UNIX does not include any of these - UNIX is only an  Operating System. 
  89.  
  90.  
  91. THE UNIX FILE STRUCTURE 
  92. ~~~~~~~~~~~~~~~~~~~~~~~ 
  93.  
  94. The above description of UNIX is very conceptual.  You never actually se the 
  95. UNIX Kernel, excpept perhaps as a process on the system.  The Shell too, is 
  96. just always there when you login.  The file structure, however, has to be 
  97. manipulated and managed by the user all the time.  The UNIX file structure is 
  98. hierarchical.   
  99.  
  100. Within the file structure there are files and there are directories - as shown 
  101. in the diagram below :- 
  102.  
  103.                               /(root) 
  104.  
  105.                                  |  
  106.         _________________________________________________ 
  107.         |       |       |       |       |       |       | 
  108.         bin     dev     etc     lib     tmp     unix    usr 
  109.         |       |       |       |       |       |       | 
  110.       -----   -----   -----   -----   -----   -----   ----- 
  111.       | | |   | | |   | | |   | | |   | | |   | | |   | | | 
  112.                                                      --- --- 
  113.                                                      ||| ||| 
  114.  
  115. Files contain data and directories contain either files and/or directories. At 
  116. the top of the hierarchy is the ROOT directory, this is sometimes referred to 
  117. as /(slash).  Below the root directory are the system files and directories. 
  118.  
  119. When a user logs into the system, he logs into his HOME directory. Every user 
  120. of the system has a HOME directory where he can create and delete files and 
  121. directories.  This part of the system belongs to him. User directories are 
  122. usually kept in the directory 'usr' which is directly below the root directory. 
  123. For example, say the user Fred has the directory structure as shown below :- 
  124.  
  125.  
  126.  
  127.  
  128.   
  129.   
  130.  
  131.  
  132.  
  133.                        /(root) 
  134.                           | 
  135.                          usr
  136.                           | 
  137.                         fred
  138.                           | 
  139.           ---------------------------------- 
  140.           |       |       |        |       | 
  141.         cprogs  memos   wpfles  sprdsht pending 
  142.           |       |       |        |       | 
  143.         -----   -----   -----    -----   ----- 
  144.         | | |   | | |   | | |    | | |   | | | 
  145.                                1990 
  146.  
  147. When Fred logs on he will automatically go to the directory 'fred'.  If 
  148. however, Fred wants to examine his spreadsheets, he may want to go to the 
  149. spreadsheet directory.  He would do this by using the 'cd' command to change 
  150. directory, i.e: 
  151.  
  152. $cd sprdsht 
  153.  
  154. This command would make his CURRENT DIRECTORY the spreadsheets directory but 
  155. his HOME directory wouls remain the same.  If he wanted to move to his 1988 
  156. directory from his home directory the command would be : 
  157.  
  158. $cd sprdsht/1990 
  159.  
  160. The '/' between the two directory names is the delimiter. 
  161.  
  162. The construct 'sprdsht/1990' is called a Pathname.  Infact this particular type 
  163. of Pathname is called a Relative Pathname because it is relative to the 
  164. directory the user is currently in.  That is, the path 'sprdsht/1990' would be 
  165. meaningless if the users current directory was 'wpfls'. 
  166.  
  167. Another type of pathname is an Absolute Pathname.  This, as the name suggests, 
  168. is a path from the root directory and is therefore independent of the user's 
  169. current directory.  Absolute pathnames are represented by using a '/' as the 
  170. first character of a path.  For example, the Absolute Pathname of the directory 
  171. mentioned would be '/usr/fred/sprdsht/1990'. 
  172.  
  173. The command :- 
  174.  
  175. $cd /usr/fred/sprdsht/1990 
  176.  
  177. would take Fred right to the directory regardless of his current directory. the 
  178. command to find the Absolute Directory is :- 
  179.  
  180. $pwd 
  181.  
  182. The stands for 'print working directory'.  As mentioned above, the command to 
  183. look at the contents of a directory is 'ls'.  By simply typing :- 
  184.  
  185. $ls 
  186.  
  187. a list of filenames is output.  This looks like :- 
  188.  
  189. cprogs 
  190. memos 
  191. wpfls 
  192. sprdsht 
  193. pending 
  194.  
  195. This is fine if just the names is required but, it is impossible to tell from 
  196. this information which are files and which are directories.  As with a lot of 
  197. UNIX commands, the 'ls' command performs a mimimum function.   
  198.  
  199. UNIX commands, generally speaking, have a number of options which can be used 
  200. with them, depending on exactly what the user wants.  For example the 'ls' 
  201. command just lists directories, if you want extra information, you have to ask 
  202. for it. UNIX must have either been written by a mimimalist or someone who 
  203. didn't like typing!!!  It does no more and no less than it is asked to, this is 
  204. something that users find quite difficult to understand. 
  205.  
  206. The 'ls' command is the perfect example of this.  In most other systems it 
  207. would be called 'dir' or 'list'.  The most commonly used option with 'ls' is 
  208. 'ls -l'.  In this case the 'l' stands for 'long'.  The command therefore 
  209. produces a long listing of the current directory.  The output looks soemthing 
  210. like that shown below :- 
  211.  
  212. drwxr_xr_x 4 Fred  96 Jun  1 10:00 cprogs 
  213. drwxr_xr_x 4 Fred 195 Jul 25 09:34 memos 
  214. drwxr-xr_x 2 Fred 167 Aug 14 17:29 wpfls 
  215. drwxr_xr_x 2 Fred  84 May  7 07:56 sprdsht 
  216. drwxr_xr_x 2 Fred 952 Jun 16 13:51 pending 
  217.  
  218. This will tell you whether the entry is a file or a directory. The permissions 
  219. (r is for read, w is for write, x is for execute), the number of links to the 
  220. file, the owner, the size (in bytes), the date it was last modified, and the 
  221. name of the entry.  Options for the commands are sometimes (not always) 
  222. preceeded with a minus sign and they usually consist of a letter which usually 
  223. stands for something.  The reason for this vagueness in the format of UNIX is 
  224. that UNIX has evolved through time and commands have been written by a variety 
  225. of people from a variety of places so there are no hard and fast rules - this 
  226. is another thing that newcomers to UNIX find frustrating.  It would be true to 
  227. say that for each one of the 'rules' mentioned above, there are exceptions. 
  228. There are also special commands for adding and removing directories from the 
  229. directory structure.  They are 'rmdir' for removing directories and 'mkdir' for 
  230. making directories.  They both expect a Pathname as a parameter which is the 
  231. name of the directory to be created or removed. For example, to create the 
  232. directory 'letters' below the directory 'wpfls' from Fred's HOME directory :- 
  233.  
  234. $mkdir wpfls/letters 
  235.  
  236. To remove this directory :- 
  237.  
  238. $rmdir wpfls/letters 
  239.  
  240. The command 'rmdir' will only remove empty directories, that is directories 
  241. which do not contain files or sub-directories. 
  242.  
  243. Every directory in UNIX has two hidden entries, these are '.'(dot) and '..' 
  244. (dot-dot).  These are created when the directory is created.  '.' references 
  245. the current directory and '..' references the directory above the current 
  246. directory (called the Parent directory).  These two directories are in fact the 
  247. key to the way the whole file system is put together.  They can be seen by 
  248. using the '-a' option in the 'ls' command (i.e. 'ls -al') and they can also be 
  249. used in relative pathnames.  For example :-  
  250.  
  251. $cd ../wpfls 
  252.  
  253. from the directory 'sprdsht' in Fred's HOME directory is a perfectly acceptable 
  254. command. 
  255.  
  256. With these commands many generations of UNIX users have had their first 
  257. foot-hold on UNIX.  If you have any UNIX problems or comments to make then 
  258. please leave me (MINOTAUR) a message on the Hackernet BBS. 
  259.  
  260.                               Minotaur. 
  261.  
  262. =============================================================================== 
  263. [Hackernet BBS,LEEDS,UK(0532)557739, 24hrs. Home of H-Net Hacking magazine] 
  264.  
  265. Downloaded From P-80 International Information Systems 304-744-2253
  266.