D:\JavaFrameworks\InsuranceFramework\src\java\unix_code\Start_Unix.properties |
1 LOGON
2
3 Unix is a multiuser system.
4 There are 3 ways to connect to Unix:
5
6 1. Turn on a permanently connected workstation.
7 2. Using a network & enter the name of Unix system (access Unix)
8 3. Dial into Unix system using telephone system and a modem attached to PC terminal.
9
10 Unix shells
11 Much of UNIX's awesome strength comes from its shell.
12 A shell is a program which handles your interactions with the computer system.
13 The UNIX shell play two roles.First, it acts as a command interpreter.
14 Second , it is a programming language.
15 Nowdays, with Release 4 of UNIX System v, we have choice of shell programs:
16
17 Bourne(sh)
18 Korn(ksh)
19 Bash(bash)
20 C-Shell(csh)
21 Z-Shell(zsh)
22
23 Most Unix systems permit only authorized users to logon.
24 Logon = using or getting access to Unix.
25
26 Each authorized user is issued an account or a permission.
27 You have two things.
28
29 1. ID 2. Password
30
31 ID: is usually your last name.
32 Password: is to insure that only authorized person(s) is using this account.
33
34 Login: enter name <CR>
35 Password: enter password <CR>
36
37 Note:
38 The password is not echoed to the screen.
39
40 If both the Login name and the password are correct Unix will give you access to the system.
41
42 Once you login, you are in shell and "$" is a prompt to enter a Unix command.
43
44 $
45 ========================================================
46 ========================================================
47
48 LOGGING OFF
49
50 To log off or exit, you can enter at the shell prompt one of several commands that may or may not work on your system.
51
52 1. Exit 2. Bye 3. Finish
53
54 Sometimes if there is no usage of the system for a number of minutes, the system log you off automatically.
55
56
57 File, Filing System & Directories
58
59 A file in Unix is a sequence of bytes. The KERNEL does not impose any structure on files.
60
61 Files are organized in tree-structured directories.
62 Directories are themselves files that contains information on how to find other files.
63
64 A pathname to a file is a string that identifies a file by specifying a path through the directories to the file.
65
66 Example:
67 /usr/local/my_prog.c
68
69 / = Root
70 /usr = user directory
71 /usr/local = local directory within usr directory
72 /usr/local/my_file.c = is the file name in local directory
73
74 Absolute pathname = /usr/local/my_file.C
75 Relative Pathname = local/my_file.C
76
77 Absolute PATHNAME indicates the path from the root to the file.
78
79 Relative PATHNAME is relative to the local directory which is or should be the current directory.
80
81 ========================================================
82 ========================================================
83
84 LINK
85
86 Link is a pointer to a file.
87
88 Hard Link:
89
90 A link that is absolute pathname to a file.
91 A hard link must include all the paths from the root to the file.
92
93 Soft Link:
94
95 It is a relative link and not hard one, it may or may not include all the paths.
96
97 A soft link is an indirect pointer to a file.
98
99
100 Example:
101
102 "." this file is in current directory and it is a soft link to the current directory.
103
104 ".." this file is a soft link to parent directory.
105
106
107 UNIX DIRECTORIES
108
109 There is no distinction between plain files & directories.
110
111 The I-node type field distinguishes between files & directories.
112
113 Plain files are not assumed to have a structure however directories have a specific structure.
114
115 There are two implementations:
116
117 1. File name is limited to 14 characters.
118 Directory is a list of 16 Byte entries
119 A) 2 Bytes for I number
120 B) 14 Bytes for file name
121
122 2. File name is a string of 255 Byte
123 A) Length of entry
124 B) I number
125 C) Filename
126
127 The directory entry varies in length
128 entry length = size of entry length + size of I number +
129
130
131
132
133 The first two files in every directory are "." and ".."
134
135 "." contains information about the current directory
136
137 ".." contains information about the parent directory
138
139 ========================================================
140 ========================================================
141 SETTING UP TERMINAL
142
143 Every time you login, the shell automatically looks in your home directory for a file called ".profile". The shell will execute that file.
144
145 ".profile" file contains all the information the shell needs to run your account and set up your terminal. The purpose and the contents of the ".profile" is to guide the system what is needed to be done to set your environment. The ".profile" is the equivalent of the autoexec.bat for the PC. Experienced users would change the ".profile" file to set some of their needs or execute certain commands for their convenience.
146
147 AT&T SYSTEM V:
148 There are two files that are named ".profile". The first one is located in the root directory and the second is located in the HOME directory. Another file named "profile" is located in the etc directory.
149
150 BERKELEY Unix:
151 C shell does not have a ".profile" file, but has ".login" file as well as ".cshrc" file. They are equivalent to AT&T System V ".profile" file. The ".login" and "cshrc" file serve the same purpose as of the ".profile". There are two files that are named ".login". The first one is located in the root directory and the second is located in the HOME directory. Another file named "login" is located in the etc directory.
152
153 System V Berkeley
154
155 1) Root .profile .login
156 2) /etc/profile /etc/login
157 3) /usr/logname/.profile /usr/logname/.profile
158
159 There is no formate for the contents of the ".profile" file. Each system may contains its own unique setting.
160
161 /etc/profile:
162 The etc directory has a file named "profile" without the dot. The permission on that file is as follows:
163
164 -rw-r--r-- 1 root sys 1503 Dec 23 1991 profile
165
166 When the user logon to the system, the user first shell (Bourne and Korn) will execute the commands to set the environment. The system finds these commands in the /etc/profile or login. These commands allow the administrator to establish system-wide parameters. The user can override these setting by modifying the commands in the user own ".profile" file which is located in the user HOME directory.
167
168 /HOME/.profile:
169 The ".profile" file which is located in the user HOME directory is for the user to change or modify as the user wishes. The system looks for this file to run the user's account (set prompts, MAILCHECK, terminal and so forth). An experienced user usually customizes this file for the user's needs and convenience.
170
171 Example:
172 lst() { cls; ls -al *.$*; }
173
174 $ lst c /* list all the files with c extension */
175
176 By placing the above command in your ".profile" file, then you will have created a new command that will clear the screen and list all the files (long format) with the extension passed to the lst command.
177
178 ========================================================
179 ========================================================
180
181 SHELL VARIABLES:
182
183 $ set
184
185 .profile VARIABLES:
186
187 HOME:
188 Is a variable that stores the path to your working directory.
189 Home is your working directory.
190
191 HOME =/usr/faculty/noureld
192 =/usr/csc211/joe_banana
193
194 PATH:
195 Path variable directs the system for the path to find system programs (executable files) in certain directories. The Path variable controls the search path
196
197 PATH = /bin:/usr/bin:/urs/faculty/bin
198
199 If the file is not executable or does not exist within the listed directory (PATH), the shell will prompt
200
201 "CAN not find filename" or "Not executable file"
202
203
204 MAIL:
205 Mail variable contains the path for mail to be directed to where the mail should be directed
206
207 /usr/mail/name.
208
209 ========================================================
210 ========================================================
211
212 MAILCHECK:
213
214 MAILCHECK=600
215
216 This variable specifies how often in seconds the shell checks for new mail.
217 The default is 600 second (10 minutes).
218 Changing the MAILCHECK variable to zero as follows:
219
220 MAILCHECK=0
221
222 The shell will check for mail before each prompt.
223
224 PS1:
225 Is a variable that stores the prompt as a string. You can change the prompt by assigning a different string to the PS1 variable:
226
227 $ PS1="UNIX -$LOGNAME - enter A command ==>"
228
229 This will set the prompt from $ to the above string & the prompt will be
230
231 UNIX - unoureld - enter A command ==>
232
233 Note:
234 You must export this string to set PS1 for it to make available to other parts of the system (shell). To change it permanently, the PS1 variable in your .profile file at the HOME directory must be changed to the new prompt.
235
236 $PS1=" "
237 $ export PS1
238
239
240 PS2:
241 ">" is prompt indicates that the shell is waiting for a second command or continue entering commands to change it.
242
243 $ PS2="second command:"
244 $ export PS2
245
246
247
248
249 TERM:
250 Setting up the terminal type getting the correct terminal driver
251
252 TERM=vt100
253
254
255 tty=Terminal
256 is a historical name for terminal it is derived from the brand name teletype.
257
258 IFS:
259 Internal - Field Separator
260
261 When entering a commands, you separate them with blocks or tabs.
262 If you set IFS to different character as a field separator, then the system will use the new setting as a field separator.
263
264 example:
265
266 $ Cat a:b:c:d
267 Cat: can not open a:b:c:d
268
269 Note:
270 The a:b:e:d was treated as string and interpreted as a file name.
271
272 If you do the following:
273
274 $ IFS=:
275 $ Export IFS
276 $ CAT a:b:c:d
277 CAT: can not open a
278 CAT: can not open b
279 CAT: can not open c
280 CAT: can not open d
281
282 Here ":" was used as separate and the a:b:c:d string was interpreted as 4 different file names.
283
284 TZ = Time Zone:
285
286 TZ = CST 6 CDT
287
288 1. CST = Local time zone
289 2. 6 = # of hours that local zone defers form greenwich mean time (GMT)
290 3. CDT = Local daylight saving time zone
291
292 ========================================================
293 ========================================================
294
295 SHELL:
296 Is a variable that set the path to shell program
297
298 /usr/sh
299
300 By change shell name you can use only different shell
301
302 /usr/csh
303
304 /usr/ksh
305
306 Not if you did not export PSI or PS2 it will be lost.
307
308 VI editor:
309
310 $ man vi
311 you can exit to shell while using vi as follows:
312
313 :sh
314
315 to return to vi use exit command as follows:
316
317 $ exit
318
319 ========================================================
320 ========================================================
321
322 File & Directory Permission
323
324 File security has to do with
325 1. Who can access a file
326 2. What they can do with this file
327
328 Unix system allows you to change to access Permissions of a file or a directory.
329
330 The permissions are
331
332 1. Read 2. Write 3. Execute
333
334 Every file has three permissions associated with it
335
336 1. owner 2. Group 3. Others
337
338 When list the files using the command
339
340 $ ls -al
341
342 You get the following list - take one
343
344 1. 2. 3. 4. 5. 6. 7.
345 -rwxrwxrwx link owner group size last-update name
346 -rwxrwxrwx 1 joe csc211 375 Feb.21:23:12 my_file.c
347
348 1. TYPE PERMISSION:
349 A) Type of file-directory:
350 This indicates if the list a file or directory
351 Note the type might also be other as follows:
352 C = Character specified file
353 B = Block specified file
354 P = FIFO specified file
355 also called named pipe
356
357 B) Permission - Protection mode
358 This is subdivided into 3 groups
359
360 1. Owner 2. Group 3. Others
361
362 owner group other
363 r w x r w x r w x
364
365 r = Read
366 w = Write
367 x = Execute
368
369 2. Link
370 This is the number of links that files has.
371
372 3. Owner
373 The name of the owner
374 4. Group
375 Name of the group
376
377 5. Size of file
378 The size of the file in Bytes
379
380 6. Dates Time
381 Date & time of the last time this file was modified
382
383 7. file name
384 The file name
385
386 Changing File Permission
387 Permission for owner, group & other to read, write and execute can change by the following commands:
388
389 $ chmod U+rwx filename
390 $ chmod g+rwx filename
391 $ chmod o+rwx filename
392 OR
393 $ chmod 700 filename
394 $ chmod 050 filename
395 $ chmod 005 filename
396
397 $ chmod 755 filename
398
399 Change Group + Owner Names
400 You can change the group + owner names associated with that file
401
402 $ chown new_owner_name filename # must be known onwer
403 $ chgrp new_group_name filename # known group
404
405 Note:
406 * present wild card matches any string character
407 Example:
408 $ rm *.c
409 ? matches any single chareacter
410
411 $ rm joe.?as
412
413 [..] matches a character in a list or range of character
414
415 $ ls [abcd]*
416
417 Massages & Mail
418
419 $ write legnone
420
421 $ wall message
422 $ mesg n
423
424 $ mesg y
425 $ mail logname < file_name
426 $ mailx
427
428