: :

< > 89 89 2

© 3

4...... 1 9...... 2 21 ...... (Troubleshooting ) 3 37 ...... 4 47 ...... Shell Scripting 5 57 ...... (Registry ) 6 67 ...... 7 87 ...... 8 111 ...... 9 125 ...... 10 139 ...... 11 153 ...... Samba 3.0 12 171 ...... 13

© 1

. . . . " " . . . . . . : : Windows • Windows Windows XP : .... Windows 2003 Server Vista ... Virtual Memory MultiTasking Multiuser . AT&T Bell 1968 UIX • . ( Linux ) 5

Multiuser . ... Virtual Memory MultiTasking Apple 1984 MAC Operating System • Macintosh . 1984 Novell Netware • IBM Novell . UNIX Solaris • ... 1

2 . . : : • • • • ... BIOS • • . Sun Virtual Box Virtual PC

1 RealTime 2 Copy Right

© 6

Ubuntu Sun Virtual Box . . . : : • • ...... (2 1 ) . Socket Programming • . • . .

11 . OSLab . [email protected] . . Manual OSLab . . Manual Guide

1 Semaphore 2 Monitor

© 7

. . www.ITVirtualLab .com

12 . : : • . • . . • • . • . • . ... . . • . 2 • . .

© 8

• .

13 . ( ) ( ) . . . .

[email protected] 1389

©

2

21 . . . XP

22 10

23 . 1 . . . : : 1. ( ) 2. . . 3 2 ( ) . . . .

Startup 231 4 Startup . . .

1 Servers 2 CPU 3 RAM 4 Shortcut

© 11

. . . Startup : : 1. 2. Startup Startup . Startup . . 1 : :

System Tray 12

. . Start>Run Statrtup

Run Startup 22

232 ... Visual Studio .NET Adobe Photoshop !

1 System Tray

© 12

( Hard Disk ) . . ( ) . 1 . . . Page File Swap File : . . . . . 3 2 : . (Swap File ) . . : : 1. . 2. . Defragment 3. . .

1 Virtual Memory 2 Minimum 3 Maximum

© 13

. 4. . 5. . .

1 2 3 2 . . . .

1 233 . . Paint . . . . Scan Disk : : Scan Disk 1. Disk Defragment 2. 3.

1 Utilities

© 14

Scan Disk 1 3 3 2 Scan Disk Windows 98 . Error Checking . Scan Disk . : : Right click on one drive  properties  tools tab  errorchecking Disk Defragment 2 3 3 2 ( ) . 1 2 . ( ) . Microsoft Defrag . . 3 . . . 4 . . . . : : Disk Defragment

1 Sectors 2 Fragmented 3 File 4 Front

© 15

• . . . % 15 Defrag • Disk Defragment • . : : Start > Programs > Accessories > System Tools > Disk Defragmenter

Disk Cleanup 3 3 3 2 ( ) Windows . Temp . . . Recycle Bin : : Start > Programs > Accessories > System Tools > Disk Cleanup

234 . . . . .

© 16

. . 1 . 2 . .

24 1. . 2. . . .

25 83. 83. . . . . .

1 Restart 2 Logoff

© 17

26

: : . Registry . .

: 1. Start  run 1 Enter msconfig . . Startup . . ( . . 2 ( ( : : Location ( Start  run  Regedit Enter . . Location

System 3 Setting 2. . General ( RAM ) . : .

ﺩﺭ Start menu ﺑﺮ Setting ﻭ ﺳﭙﺲ ﺑﺮ Control Panel ﻛﻠﻴﻚ ﻛ ﻨﻴﺪ، ﺑﺮ ﺷﻤﺎﻳﻞ٤ System ﻛﻠﻴﻚ ﺩﻭﮔﺎﻧﻪ ﻛﻨﻴﺪ ﺁﻧﮕﺎﻩ ﺳﺮﺑﺮﮒ Advance ﺭﺍ ﺍﻧﺘﺨﺎﺏ

1 Tab 2 Check 3 Icon 4 Icon

© 18

ﻧﻤﺎﻳﻴﺪ ﻭ ﺑﺮ ﮐﻠﻴﺪ ...Performance Option ﻛﻠﻴﻚ ﻛﻨﻴﺪ . ﺩﺭﺍﻳﻮﻱ( ﻳﺎ ﺩﺭﺍﻳﻮﻫﺎﻳﻲ ) ﺭﺍ ﻛﻪ ﻣﺎﻳﻠﻴﺪ ﺣﺎﻓﻈﻪ ﻣﺠﺎﺯﻱ ﺩﺭ ﺁﻥ ﻗﺮﺍﺭ ﮔﻴﺮﺩ، ﻣﺸﺨﺺ ﻛﻨﻴﺪ( ﺍﻃﻤﻴﻨﺎﻥ ﺣﺎﺻﻞ ﻛﻨﻴﺪ ﻛﻪ ﻛﻠﻴﺪ Set ﺭﺍ ﭘﺲ ﺍﺯ ﺗﻌﻴﻴﻦ ﻣﻘﺪﺍﺭ ﺑﺮﺍﻱ ﻫﺮ ﺩﺭﺍﻳﻮ ﺯﺩﻩ ﺑﺎﺷﻴﺪ ). ).

. 1 . . .

Tools Properties C 3. . Check Now… ErrorChecking . Check Disk . . Start . . Disk Cleanup 4. .( ) (Disk Cleanup Disk Defragment Scan Disk ) 5. . Tools . C 6. View Folder Options… Hide protected operating system files (Recommended) Notepad boot.ini . . Restart

1 Hide

© 19 multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=" XP Professional" /fastdetect multi(0)disk(0)rdisk(0)partition( 2)\WINDOWS="Microsoft Windows XP Professional 2" /fastdetect . . boot.ini Freez : . Restart . . Virtual PC

© 20

© 21

( ( Troubleshooting ) 3

31 . 1 ! . .

32

1 Error

© 22

33 . Control Panel Administrative Tools . . Event Viewer . . . 1 . .

331 : : Event Viewer

: (Error ) 1. 2 . .

: (Warning ) 2. (Low Disk Space ) . .

1 Start up 2 ( Background ) : Service . ... . . Control Panel>Administrative Tools>Services

© 23 (Troubleshooting )

1 : (Information ) 3. ( ) . . ( ) : :

. :2 4. .

. :3 5. .

332 : : 4 XP (Application Log ) 1. . . . (Security Log ) 2. ... .

1 Driver 2 Successful Audit 3 Failure Audit 4 Log

© 24

. 1 . . ... (System Log ) 3. . ( ) . . . Event Viewer Event Viewer . ( Administrators ) XP Event Viewer . . .

Event Viewer 13

1 . : Administrator . . Manager

© 25 (Troubleshooting )

Windows 2003 Server . . Directory service log • File Replication service log • DNS server log • ... •

333 1 . . .

23

1 Double Click

© 26

13 Date Time . User . ID Client ID . . . Computer . . Event Viewer . . Description . . Event Viewer 6005 Event . "The Event log service was started." Description Event ID Source ID . . "SQL Server" "Elnkii " . Source . EtherLink II driver : Type . . . Category . . . Description . . Word Byte . Data . .

© 27 (Troubleshooting )

334 . . . Event Viewer Safe Mode . .

Safe Mode 1 4 3 3 . Safe Mode Safe Mode . . . F8 Safe Mode POST . BIOS . Floppy : . . Hard Disk CD ROM Hard Disk Drive Safe Mode . Safe Mode . .

© 28

Safe Mode : : 1. Safe Mode 2. Safe Mode with Networking 3. Safe Mode with Command Prompt 4. Enable Boot Logging 5. Enable VGA Mode 6. Last Known Good Configuration 7. Directory Services Restore Mode 8. Debugging Mode 9. Disable Automatic Restart on System Failure 10. Start Windows Normally 11. Reboot 12. Return to OS Choice Menu Safe Mode Safe Mode with Networking Last Known Good Configuration . . .

BIOS 2 4 3 3 BIOS 1 . ... RAM CPU ( ) . . RAM BIOS . . Motherboard

1 ROM

© 29 (Troubleshooting )

BIOS BIOS . . BIOS RAM . .

335 . . . Event Viewer Description . Description . . . www.EventID.net . Event ID .( 33 ) Source . . Comments and links for event id … from source … . . www.EventID.net

© 30

Google Groups . . .

www.EventID.net 33

Description Source Event ID . .

1 5 3 3 . .

© 31 (Troubleshooting )

. . . . .

2 5 3 3 . . .

3 5 3 3 . . . . .

34 . Event . Viewer . .

© 32

. .

35 Safe Mode 1. : a) Safe Mode with Command Prompt b) Enable Boot Logging c) Enable VGA Mode d) Directory Services Restore Mode e) Debugging Mode f) Disable Automatic Restart on System Failure

Source: Norton Antivirus Event ID: 22 2. . ( ) . 3.

36 1. C. Wolf, Troubleshooting Microsoft Technologies: The Ultimate Administrator's Repair Manual , AddisonWesley Pub., 2003.

© 33 (Troubleshooting )

37

. . :

Control Panel Administrative Tools Event Viewer 1. . Clear All Events System DNS Control Panel Administrative Tools Services . Restart Client . Event Viewer System . .

. OK gpedit.msc Run Start 2. Security Settings Windows Settings Computer Configuration Audit Policy Local Policies . Audit logon events . . Failure Success Logoff . Event Viewer ( . . ( : : Login . . Switch User Logoff

. Find… View Event Viewer 3. Application Event Source

© 34

Category . Category

System Security Application 4. . ( Description) Source Event ID .

Event Viewer 5. : Source Disk Type Error Description The device, , has a bad block. : : www.EventID.net Event ID: 7 Source Disk Type Error Description The device, , has a bad block. English Request a translation of the event description in plain English! An example of please! "English please" is available here . Comments Mihai Andrei (Last update 2/28/2006): This event might be logged when you format a logical disk on an extended partition on an ATAPI hard disk drive on a Microsoft Windows NT 4.0based computer. See M817755 for a hotfix applicable to Microsoft Windows NT.

See MSW2KDB and "Lacie Support FAQ" for additional information about this event.

Ionut Marin (Last update 10/6/2004): As per Microsoft: "The device has a bad block of memory, which Windows attempted to read. The data might be missing or corrupted". See the link to "EventID 7 from source Cdrom" for details on this event.

Adrian Grigorof According to Microsoft: "From the command prompt, run the Chkdsk utility with the /r option on the named partition. If Chkdsk reports no errors but you continue to receive this message, run hardware diagnostics on the disk drive named in the message and on its controller. You might need to contact the vendor of the device for technical support, and you might have to replace the controller, the disk drive, or both."

© 35 (Troubleshooting )

Fibtech According to Microsoft you need to translate the hard disk number to a physical drive on the system. You can determine the hard disk number by looking in the registry, but you need to know if you are using IDE drives, SCSI drives or a combination of the two. Disk Administrator will display the drives in the order they are enumerated on each controller and in the order that the controller device drivers are loaded. If you are using multiple controllers, the order in which they are identified is based on I/O port and controller BIOS address assignments. See M159865 for more details. Links M159865 , M817755 , EventID 7 from source Cdrom , Lacie Support FAQ ,

MSW2KDB Search Google Web Microsoft Support Microsoft Search Google

Microsoft EventID.Net Queue More links... Various Send comments Notify me when updated . .

Restart . 6 ( boot ( . . ( . . Numlock

© 36

©

4

41 . . . . .

42

© 38

43 . Page Fault . . .

Performance Monitor 431 Performance Monitor Performance . : : Monitor System Monitor 1. Performance Log and Alert 2.

© 39

. . Performance Log and Alerts Alerts . 50 1 . . : Performance Monitor . : (Object ) 1. ( CPU ) Object . (thread process ) ( disk volume ) . : ( Instance ) 2. instance . Network interface . :( Counter ) 3. Processor User Privilege mode . .

: . : : Physical Disk\Disk Write Time

1 CPU Load

© 40

Packet . ... Mode CPU

System Monitor 432 Performance Monitor : : Graph 1. . : Histogram 2. CPU . Server : Report 3. . . : :

433 : : Memory 1. Disk Subsystem 2. etwork card and software 3. Processor 4.

© 41

Performance Monitor Processor . . CPU User Time % 75 ( CPU Time )CPU Server ( Interrupt Time ) . ) . . ( ...

1 434 ( ) Server Performance . . Performance Log and Alert Monitor log . 2 Excel . Tab Microsoft SQL . . : Log Performance Log and Alert Counter Log 1. Trace Log 2. Alert Log 3.

: : Counter Log ) Service 4 3 . . ( :Trace Log

1 Logging Performance Data 2 Log File 3 local 4 remote

© 42

page Fault I/O . 1 . . . Log : : Alert Log Alert Log . .% .% 90 CPU

44 M. Minasi, C. Anderson, M. Beverridge, C. A. Callahan, L. Justice. Mastering 2003, Sybex Pub., April 2003.

1 Event

© 43

45

: : . .

. Enter perfmon Run Start 1. Add Counters ( ( Performance Objects ) Performance Object 1 . . Explain Processor Time ( Counter ) Processor ( CPU . . . Explain ( : : Privileged Time • User Time • Interrupts/sec ( System Monitor Add System . . Monitor

Process explorer ( Threads ) ( 2. . .

1 Drop Down

© 44

. . . ( instance ) ( ( . .

System Monitor 3. System Monitor : . . System Log Performance Logs and Alerts Counter Log 4. : Overview Log ( Log File ( Log ( Log Files ( Binary ) Log File ( . . 2 . . Schedule ( . . ( Log )

System Overview : . . 5 Log

10 Counter Log 5. . 1 Log / / .

© 45

Trace Log 6. 3 . Trace Log : . . : Event Viewer . . . . ( Log (

CPU 3 alert 7. Event Log 50 . .

© 46

©

Shell Scripting 5

51 ) dir . ( . Shell Scripting . . . . . Shell Scripting Shell Scripting : ! !

52 Shell Scripting

© 48

53 Shell Script . . . Script Shell Script ( ) Shell . . Scripting . .cmd .bat . Windows Shell Script . . 15 10 Shell Script . Windows Shell Script . . : : Windows Shell Script • • . . • . . •

© 49 Shell Scripting

. . Disk Defragmenter Windows Shell Script . .

531 Windows Shell Script : : Windows NT 4.0 Windows2000 Windows XP Windows2003, , Windows 7 Shell (. Windows Power Shell ) : : . Windows Notepad Text Editor . . . Windows Shell Script . Windows Shell Script . Windows Shell . Shell Script . . . Windows Shell . . . (CMD )

© 50

Shell Script 532 : : (Sequence ) 1 ( ( Condition ) 2 ( ( Iteration ) 3 Shell Script . . .

: : : : 1 Set name=value : : Set msg1= Hello

: : Echo %msg1% > test.txt : : . Echo %msg1% > test.txt Enter Shell . @echo on . @echo off . . msg1 . . msg2 @echo off Set msg1= Hello

1 String

© 51 Shell Scripting

Set msg2= There! Echo %msg1% %msg2% off echo set : : : '..... ' is not recognized as an internal or external command, operable program or batch file.

1 533 . . .cpp C++ .c C . .bat Windows Shell Script . Batch Files . . .bat Directory make directory md : : first . Md first 1 first 0 md . . 2 Shell Script % . . echo %1%

1 Batch Files

© 52

54

1. J. L. Ford, Microsoft Windows Shell Script Programming for the Absolute Beginner , Premier Press, Nov 2003.

© 53 Shell Scripting

55

. : . . : : D . .

: : . 1 Start > Run D Enter d: . Enter cmd . . Help . . . ( ( Dir > test.txt . test.txt d test.txt : : >> > ( Tree >> test.txt

: . 2 @echo off Set msg1=one Set msg2=%msg1% two Set msg3= %msg2% three Echo %msg3%

. . . 3 @echo off Echo set msg=Hello World! > hello.bat Echo echo %msg% >> Hello.bat

© 54

: : . 4 %0 %1 %2 %3 %4 %5 %6

: : If [not] string1= =string2 command

: test.bat bat cls @echo off If “%1”== “1” echo First Number If “%1”== “2” echo Second Number If “%1”== “3” echo Third Number If “%1”== “” echo no Number Second Number First Number 355

5. If [not] exist filename command

test.bat bat text.txt text.txt

@echo off If exist text.txt ( Echo removing text.txt Del text.txt Echo text.txt Removed )

: : . 6 For %%variable in (set) do command For /L %%variable in (start step end) do command

© 55 Shell Scripting

100 0 .

. 7 . bigtxt.txt . .

. 8 . . :END 1

:LOOP

GOTO LOOP :ED

5 . . : rem A Bang Counter @echo off set n=%1 set i= : loop set i=%i%! echo Bang! if %i%= =%n % goto end goto loop :end

1 Lable

© 56

©

( ( Registry ) 6

61 . Windows 1 Registry . . . 3 2 Registry . . ( 4 )

62 1

1 Hacking 2 Tuning 3 Troubleshooting 4 Backup

© 58

63 Win.ini ( Windows 3.0 ) .( ) . . .

631 ) ( . . Registry . Registry . . 2 Desktop Log in .( .( Desktop ) 3 windows ) Registry shell 4 .( ... Rename Edit open . . Registry

1 Backup 2 Customized User Interface 3 windows Explorer 4 Pop_up Menu

© 59

Registry 632 . Regedit Registry . . Registry Registry Windows Regedit Registry Registry . ( Files ) ( Folders ) ( Value ) ( Key ) . . .

1 6

: ( Value ) . .( .( ) ( Icon ) : : : • Regedit . ( Hexadecimal )

© 60

) .( .( • . . . ...

. .

Registry 633 Windows Registry ( ( ) ) ....( ....( Windows XP Professional Advanced Server

Registry 634 Registry : :

HKEY_LOCAL_MACHIE HKLM . . ...

HKEY_CLASSES_ROOT HKCR . HKEY_LOCAL_MACHINE

© 61

2 1 . . ...

HKEY_USERS Log ) HKU . (on . . . 3

HKEY_ CURRET_COFIG HKCC . .

HKEY_CURRET_USER HKey_Users HKCU . .

1 Shell Interface 2 Shortcut 3 Desktop

© 62

64

: : ( Undo ) Registry • . .

1 1. . Export Key New HKEY_CURRENT_USER . . in1 Test . test Export Test . . Work D Backup . in2 Test Import File Registry in1 Test Work D Backup . . In2 Test ( Backup ( ( ( Notepad ) Backup ( In3 Backup ( Test My Registry Editor ( D:\Work Export Computer . Registry

1 Backup

© 63

. ( ( ) Backup : .

. HKEY_CLASSES_ROOT . RUN Regedit . 2 ( File Format ) . . . . ( File Tools > Folder Option Windows Explorer ( ( ( File Extension ) ZWQ . Types Regedit . 1 ZWQ ) Zwq Refresh ( highlight . Default . Default ft000002 Default .zwq : . .

D:\Work . . 3 . . st.zwq Folder Option Windows Explorer . Advanced zwq . File Types Tools ( ( Notepad.exe ) Simple Edit ( Action ) New . ( cmd.exe ) Advanced Edit

1 Associate

© 64

D:\Work ft000001 Shell .( Context Menu ) . Microsoft Word Advanced Edit

st.zwq . 4 .( shell ) Shell default . Notepad . .( logoff ) : : : HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts

: : . 5 Desktop ( WallPaper ) . . : . . Reset Add\Remove Programs . . Install\Uninstall

: : . 6 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

© 65

. Run MRUList ( Most Recently Used MRU ) HKEY_CLASSES_ROOT\CLSID\{20D04FE03AEA1069A2D808002B30309D}\shell . . My Computer . "find " default . . :

( Prefetching ) ( . 7 C:\WINDOWS\Prefetch ( ( HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\ Memory Management\PrefetchParameters\EnablePrefetcher . 2 . Restart C:\WINDOWS\Prefetch . . . . 3

8.

: : " " Recycle Bin My Computer Registry . 9 " "

© 66

©

7

71 1 . . . 2 : : FAT, NTFS, HPFS, Netware Fs, Linux Ext2, Linux Ext3, Linux Swap . 3 . .

72 . . . .

1 or Filesystem 2 Folder 3 Format

© 68

73 . . Special Purpose File System Network File System Disk File System . Disk File System . .

731 : : 1 . 2 :  100 32 4 . . 3 . ( ) :  4 . :  . 512 4096 32 : : ( ) :  . ( ) (: )  . 5 :  .

1 Track 2 Platter 3 Spindle 4 Sector 5 Cluster

© 69

. . 64 ... 4 2 1 1 0 ) 2 . . ( . .

[1] 1 7

732 . 1 . Abstract Data Type 3 2 .

1 Abstract 2 Text 3 Executable programs

© 70

FAT . ... 1 . .

733 . . NTFS exFAT (FAT64) FAT32 FAT16 FAT12 : exFAT FAT12 ) .( .( Vista SP1 2008 7

2FAT 7331 . FAT FAT 1 . .

FAT12 : : Fat12 1   

= 16 = 4096 4 =

1 Graphic image 2

© 71

[3] 1 7 ( ( ) ( ) FAT 16,736,256 B 16 MB 4 KB 512 B 4,096 12 bits 1977 FAT12

2,147,123,200 B 2 GB 32 KB 2 KB 65,536 16 bits 1987 FAT16 B 2 TB 4 KB 32 KB 268,435,456 28 bits 1996 FAT32 512 TB 32 MB 512 B 4294967295 64 bits 2006,2009 exFAT Root Directory FAT 2( ) .( Root Directory ) 2 . . . FAT 2 1224 ( 4 ) 2048 Root Directory Data Area ( 1256 ) Root Directory 2 . 32 Root Directory . . 1224 + 32 = 1256 :

[3] 2 7

[3] – 2 7 ( ) Boot Sector 0x00000x01FF 0 File Allocation Table (Primary) 0x02000x13FF 19 File Allocation Table (Secondary) 0x14000x25FF 1018 Root Directory 0x26000x41FF 1932 File Storage Space 0x42000x167FFF 332879

© 72

Root Directory Boot Sector Boot Sector FAT Boot Sector . . Boot Sector 4 3 . . . [3] FAT32 FAT16 FAT12 Boot Sector 35 0 3 7 Assembly code instructions to jump to boot code 02 (mandatory in bootable partition) OEM name in ASCII 310 Bytes per sector (512, 1024, 2048, or 4096) 1112 Sectors per cluster (Must be a power of 2 and cluster size must be <=32 KB) 13 Size of reserved area, in sectors 1415 umber of FATs (usually 2) 16 Maximum number of files in the root directory (FAT12/16; 0 for FAT32) 1718 umber of sectors in the file system; if 2 Byte is not large enough, set to 0 and use 1920 4 B value in bytes 3235 below Media type (0xf0=removable disk, 0xf8=fixed disk) 21 Size of each FAT, in sectors, for FAT12/16; 0 for FAT32 2223 Sectors per track in storage device 2425 umber of heads in storage device 2627 umber of sectors before the start partition 2831 umber of sectors in the file system; this field will be 0 if the 2B field above 3235 (bytes 1920) is nonzero [3] FAT16 FAT12 Boot Sector 4 7 3 3 035 BIOS INT 13h (low level disk services) drive number 36 Not used 37 Extended boot signature to validate next three fields (0x29) 38 Volume serial number 3942 Volume label, in ASCII 4353 File system type level, in ASCII. 5461 (Generally "FAT", "FAT12", or "FAT16")

© 73

Not used 62509 Signature value (0xaa55) 510511

. . . . Dos : 1SF . . THISIS~1.txt ٢ Unicode : LF This is test 1.txt

... Root Directory : : Root Directory . FAT

[3] Root Directory Entry Format 3 7

1 Long File Name 2 Short File Name

© 74

Root Directory Boot Sector : : 980 mes.doc 1400 tyui.jpg 4 . 512 . 136 4 3 2 tyui.jpeg ١ .( 1400 = 512 × 3 + 136 ) 4 . 6 5 mes.doc . ( ) .( 2 ) Root . tyui.jpg 2 Directory "FAT 3 FAT . " FAT 3 . x FAT ( ) 0xFFF 4 4 . tyui.jpg 4 . .

1 Slack Space 2 First Fit

© 75

[3] FAT – 4 7

: : FAT

Internal 1 • External Fragmentation Fragmentation . . . FAT • 11 ( FAT 32 ) FAT • .( 3 )8 2 VFAT FAT . 255 • . .

1 Fragmentation 2 Virtual FAT

© 76

: : TFS 1 7332 ) Windows NT NTFS . ( 2000 . FAT . . : NTFS 2 : • . 3 NTFS NTFS . NTFS : • 4 . . 5 : • . . ( EFS ) 6 NTFS : • . . Unicode NTFS :Unicode • .

1 New Technology File System 2 Data Recoverability 3 Consistency 4 Duplicate 5 Data security 6 Encrypted File System

© 77

. : 1 • NTFS . . . NTFS NTFS (Main, Unnamed Stream) NTFS . 2 . (Named Stream) .

5 7 3 NTFS : • . . .4 5 : • .

1 Multiple file stream 2 Convert 3 Compression 4 Decompression 5 Disk Quotas

© 78

1 : • NTFS . ( ) . . 4 . .

6 7

2 : • 3 NTFS . . NTFS : CRC • . CRC

.

1 Sparse files 2 3 Attributes

© 79

:WinHex 74 XWays Software Technology AG . . 15.2 SR . .

Directory Browser

Details Panel

Component WinHex 7 7

© 80

Boot Sector 8 7

Root Directory 9 7

© 81

: : . .

75 Bootable DiskPart . .

76 1. Silberschatz A., Galvin P.B., Gagne G., Instructor's manual for Operating system concepts , 8’th Ed., Wiley Publishing, Inc., 2005. 2. Tanenbaum, Modern Operating Systems , 2’nd Ed., Prentice Hall Publishing, Inc., 2006. FAT . ، . ، . 3 . . . 1388 . . TFS . . 4 .1385 .

© 82

77 1: 1: WinHex . . . Refresh 2: 2: Format . .

. . DiskPart Enter DiskPart Run . 1 . 3 Help ( . . . List ( VDisk . [Type] (List Disk ) List [Type] ( . VDisk, Partition, Disk, Volume Select [Type] . ( ) . . Select Volume [Your Disk Volume Number] ( ) FILESYSTEMS ( Allocation Unit Size . Format . Help Format ( “OSLab” ( Label ) FAT32

© 83

. . . .

. WinHex . 2 Tools Open Disk . . Directory Browser ( Directory Browser : ) ( ( Directory Browser Show View : . . . . Root Directory ( ( ( (

st ( ) 1 sector . 3 . FAT : ) (. (. Boot Sector Length = Byte Per Sector × Boot Sector Number

© 84

WinHex Decimal Hex Offset FAT1 ) Decimal Hex . ( F8

. 4 . ( )

( ( ) . . . 6 6 ) Boot Sector ( .( . 2KB . ( 4 ) . . (

© 85

7(. 7(. ) Root Directory . 5 . 0 Record ( 3 ) 0 .( ) (! ) .( Test Windows Explorer ) WinHex .(! . Refresh View Refresh View ( 4 Attribute Root Directory ( BAT ) Test ( .( Ctrl + S) . . Test ( : ) .(! . . (

) . 6 .( Test1 ( . txt ReadOnly

© 86

txt ( . . .

. . FAT1 Directory Browser . 7 Root Directory )( ( ( Test ( ) 5 ( . . : : Refresh Root Directory ( a Test ( b . . ( c Root Directory )(

Refresh Test 5 KB . 8 : : ( Test FAT ( . .

©

8

81 Open Source . . . . . . . . .

© 88

82 : : . • • • • •

83

831 Trovalds . 1991 Unix Unix Minix . Minix . Server Trovalds . Linux Kernel . ) Usenet Minix ( Free Software FSF . Foundation GPL Trovalds . (GNU Software ) General Public License 1 .

1 Distribution

© 89

( RedHat, SUSE, Ubuntu ) % 90 . .

832

Red Hat 1 2 3 8 Data . Center . Red Hat . Red Hat . . RHEL . Red Hat . Desktop Server Red Hat Enterprise Linux . Open Source . . RedHat Fedora . Fedora Open Source Red Hat Fedora RHEL Fedora . REHL . . www.redhat.com/fedora RHEL ( Community ENTerprise Operating System ) CentOS . RHEL . . www .centos .org

© 90

SUSE 2 2 3 8 1 SUSE . Novell . 2 SUSE 1994 . . RedHat SUSE Linux Enterprise SUSE SUSE Linux Enterprise Desktop 3 . . www .novell .com /downloads . 4 OpenSUSE SUSE 5 . . www .opensuse .com .

Ubuntu 3 2 3 8 6 CD . Desktop . www .ubuntu .com . Ubuntu Server Canonical Ubuntu . Ubuntu .

1 Demo 2 Enterprise 3 RealTime 4 Open Source 5 Stable 6 Desktop

© 91

833

1 3 3 8 . . . : • C . . . 1 . 2 : • . . 3 : • .

834 ( ) .

1 Driver 2 Multiuser 3 Multitasking

© 92

. . . . /dev/hda . . . /dev/hdb . 1 Directory . . Folder . : : • . / • . \ Backslash . Root • etc . ls /etc . etc

1 4 3 8 . . : : . /boot •

1 Directories

© 93

. /dev • USB . . /etc • . ali . /home • /home/ali . Login /proc • . . . . 2 1 /tmp • . . . 3 /usr • : . . /user/bin o ls Firefox

1 User Root 2 Super User 3 library files . . DLL .

© 94

. . . /user/sbin o /user/bin . . /user/local o . . . /var • . . /var/spool . .

2 4 3 8 . . ... : :

cd path cd .. cd ~user ~ ls path mv path/filename newpath cp sourcefile targetfile

© 95

rmdir directoryname mkdir directoryname find path –name filename –print cat path/filename rm path/filename more path/filename Pwd who Log in

: ls /home

: : –l ls –l : :

© 96

) ( ) ( Write ) (Read ) (eXecute ) 1 – d . . . 2 l . chmod . root . ( Other ) ( Group ) ( Owner or User ) . chmod 2 Write 4 Read . . 1 eXecute . . chmod

: : Chmod 755 /somefile ( ) . .

chmod chmod . + . o g u : . x wr – . . o gu

: : Chmod +x somefile . .

1 Permission 2 Shortcut

© 97

3 4 3 8 . . 1 . . . . tty6 tty1 . 6 . Ctrl+Alt+ Function Key . Ctrl . Ctrl+Alt+ F4 . . Ctrl+Alt+ F7 : : . root : root root . . . root IP root . substitute user su : : su user . user su . . . root sudo . su Ubuntu 1: su . root : : Ubuntu sudo su

1 Virtual Console

© 98

. sudo root 2: ls / –l sudo ls / l . .

: : : root adduser cat filename.exension . : cat : : $ cat /etc/hosts : : man Passwd . . : : tab . .

835 : : man • –help •

© 99

Bash 1 • . Bash 2 help

man 1 5 3 8 manual man man . DOS . . . ) man passwd passwd : : (

. Synopsis . .

1 Shell 2 Builtin

© 100

. Unix man . . man . . 8 5 1 man –a 1 man man : : man 5 passwd man . 5 –k man man –k . Pipe and Redirection . . 1 Man –k time | grep 1 . grep grep 10001 zipcodes.txt . "10001" zipcodes.txt

© 101

help 2 5 3 8 . . . less . : : ls –help | less

© 102

836 . . . . Visual Vi Vim Vi . Improve Vi . : : Vi . • . Ubuntu Emacs • . Emacs • vosudo sudo .

Vi 1 6 3 8 : : Vi . 1 Vi 2 : • : 3 • . . . Vi . 4 : :

1 Modes 2 Command Mode 3 Insert Mode 4 Cursor

© 103

i • a • o • 0 • . Esc . . Vi . . :wq . copy cut, paste cut d v delete . paste p . : : x • . dw • . dd • g . G . ! . . :q!

© 104

837 . C C C C . Prolog Perl Lisp JavaScript Java Icon Fortran Forth Eifell C++ Ada : . . ... Smalltalk Ruby PHP Python Pascal

: : : :

© 105

: : . hello.c Vi 1. . link compile 2. $ gcc –o hello hello.c . . 3. $ ./hello

Piping and Redirection 1 7 3 8 Piping . Redirection Piping Redirection . . . Piping . Piping : :

. . less : : ls –r / |less . redirection < > Shell Scripting >> >

© 106

. . 2> . .

84 1. Neil Matthew and Richard Stones, Beginning Linux Programming, 4'th Ed., Wiley Publishing, Inc., 2007. 2. Keir Thomas, Beginning Ubuntu Linux From ovice to Professional , Apress, 2006. 3. Sander van Vugt, Beginning the Linux Command Line , Apress, 2009. 4. Paul G. Sery, Ubuntu Linux For Dummies , John Wiley & Sons, 2007. 5. Matthias Kalle Dalheimer, Terry Dawson, Lar Kaufman and Matt Welsh, Running Linux , 4'th Ed., O'Reilly, 2002. . . 6. . . 1377 .

© 107

85

. Linux Accessories Application . . Terminal : : . l a : ls 1. . . . mkdir 2. . cp 3. . . . rmdir 4. . man man 5. . . ls 6. . . . . ) ( 7. ( $ find . -name '*.jpg'

. hosts ( . .

© 108

. 8. . C Vi 9. first.c . . firstexe . . . . file $ file first.c $ file firstexe 9 10. . . . ( . . first ( . ps 11. . . Vi first 12. . ps . . . sample.c 13. ) file.txt . redirect .( Redirection Sample.c

#include #include #include int main() { int ch; while((ch = getchar()) != EOF) { putchar(toupper(ch)); } exit(0); } file.txt

© 109

This is a file, file.txt, it is all lower case.

top 14. . 123 user2 15. . who Log in ( (

©

9

91 : : 1 • • •

92 . . .

1 Process

© 112

21 9 . 1 . . init init mingetty . 2 bash mingetty . 3 Init . . mingetty bash mingetty . . bash . nice . . . . . . Zombie . . 4 Zombie . Zombie . . . ps aux

1 Kernel 2 Child 3 Login shell 4 Restart

© 113

22 9 . ps Stat ps –al : : . (Running ) : R • (Waited ) : S • (Zombie ) : Z • ) ( Trace ) ( stopped ) : T • ( . 1 : D • W . . ( Swap ) N . ) ( Nice Value ) .( .( . 9 . . .

1 9

1 . 2 3

1 Preemption

© 114

( Sleep ) 4 5 4 6 ( Preempted ) 7 8 pid ) . ( ) exit ( Zombie ) 9 . ( . . ... . . exit code ( ) waitpid wait . . . ( ) . ( orphan ) . .

fork 1 . 5 3 . 3

1 . . .

© 115

. fork . . 1 ) 2 .( . . . 7 . 2 . 4 3 . . .

1 1 2 9

© 116

) 1 5 5 ( . ( 4 ) . . . 9

23 9 fork . fork ( PID ) . ( ) pid_t fork fork . . . . . . .( PPID ) ( PID ) : : Pid_t child_id; child_id = fork(); printf("forked\n"); . fork 2 . fork . . C pid_t : ( PID ) . . .

1 Swapper 2 Program Counter

© 117

24 9

1 :system : : . int system(const char *string) . .

) exec :exec exec . ( . file path . . DOS DOS exec exec main ) exec . : : exec . ( exec

#include int execl(const char *path, const char *arg0, ..., (char *)0); int execlp(const char *file, const char *arg0, ..., (char *)0); int execle(const char *path, const char *arg0, ..., (char *)0, char *const envp[]); int execv(const char *path, char *const argv[]); int execvp(const char *file, char *const argv[]); int execve(const char *path, char *const argv[], char *const envp[]);

C : :

1 Library function

© 118

/* Example of an argument list */ /* Note that we need a program name for argv[0] */ char *const ps_argv[] = {“ps”, “ax”, 0}; /* Example environment, not terribly useful */ char *const ps_envp[] = {“PATH=/bin:/usr/bin”, “TERM=console”, 0}; /* Possible calls to exec functions */ execl(“/bin/ps”, “ps”, “ax”, 0); /* assumes ps is in /bin */ execlp(“ps”, “ps”, “ax”, 0); /* assumes /bin is in PATH */ execle(“/bin/ps”, “ps”, “ax”, 0, ps_envp); /* passes own environment */ execv(“/bin/ps”, ps_argv); execvp(“ps”, ps_argv); execve(“/bin/ps”, ps_argv, ps_envp);

exec . 2( ) exec fork .( .( printf ) fork child_id child_id=fork() . ( ) . . . child_id 1 fork . . child_id

© 119

fork ( ) ( ) 1 9

: : fork child_id = fork(); if (child_id = = 1) { : ﺧﻄﺎ ﺩﺭ ﺍﻳﺠﺎﺩ ﻓﺮﺍﻳﻨﺪ ﻓﺮﺯﻧﺪ */ /* ﻣﻌﻤﻮﻻ ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ، ﺗﺎﺑﻊ ﺑﺎ ﻳﮏ ﮐﺪ ﺧﻄﺎ ﺗﺮﮎ ﻣﻲ .ﺷﻮﺩ } if (child_id = = 0) { : ﻗﺴﻤﺖ ﺍﺧﺘﺼﺎﺻﻲ ﻓﺮﺯﻧﺪ */ ﮐﺎﺭﻫﺎﻱ ﻣﺮﺑﻮﻁ ﺑﻪ ﻓﺮﺍﻳﻨﺪ ﻓﺮﺯﻧﺪ ﺩﺭ ﺍ ﻳﻦ ﻗﺴﻤﺖ ﺍﻧﺠﺎﻡ ﻣﻲ .ﺷﻮﺩ ﺍﻳﻦ ﺑﺨﺶ ﺑﺎ ﺍﻳﻨﮑﻪ ﺩﺭ ﻓﺮﺍﻳﻨﺪ ﭘﺪﺭ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﺩ، ﻫﺮﮔﺰ ﺩﺭ ﻓﺮﺍﻳﻨﺪ ﭘﺪﺭ ﺍﺟﺮﺍ ﻧﻤﻲ ﺷﻮﺩ . ﺑﻪ ﺍﻳﻦ ﻋﻠﺖ ﮐﻪ ﺩﺭ ﺻﻮﺭﺕ ﻣﻮﻓﻘﻴﺖ child_id ، fork ﺩﺭ ﻓﺮﺍﻳﻨﺪ ﭘﺪﺭ، ﻣﻘــﺪﺍﺭ ﺑﺰﺭﮔﺘﺮ ﺍﺯ ﺻﻔﺮ ﺑﻪ ﺧﻮﺩ ﻣﻲ ﮔﻴﺮﺩ. */ } else { : ﻗﺴﻤﺖ ﺍﺧﺘﺼﺎﺻﻲ ﭘﺪﺭ */ ﮐﺎﺭﻫﺎﻱ ﺍﺧﺘﺼ ﺎﺻﻲ ﻓﺮﺍﻳﻨﺪ ﭘﺪﺭ ﻧﻴﺰ ﺩﺭ ﺍﻳﻦ ﻗﺴﻤﺖ ﺍﻧﺠﺎﻡ ﻣﻲ ﮔﻴﺮﺩ . ﺯﻳﺮﺍ ﺩﺭ ﺻﻮﺭﺕ ﻣﻮﻓﻘﻴ ﺖ child_id ، fork ﺩﺭ ﻓﺮﺍﻳﻨﺪ ﻓﺮﺯﻧﺪ ﻣﺨﺎﻟﻒ ﺻﻔﺮ ﺧﻮﺍﻫﺪ ﺷﺪ . . */

© 120

1 fork . . : : child_pid = fork (); switch (child_pid) { case 1: /* */ case 0: /* */ default: /* */ }

25 9 . fork . . : : . wait int wait (int* status) ) PID .( status . . . waitpid . . . waitpid

1 26 9 . &

1 Background

© 121

.( ) . : : ls –l &

93 7. Neil Matthew and Richard Stones, Beginning Linux Programming , 4'th Ed., Wiley Publishing, Inc., 2007. 8. Keir Thomas, Beginning Ubuntu Linux From ovice to Professional , Apress, 2006. 9. Sander van Vugt, Beginning the Linux Command Line , Apress, 2009. 10. Matthias Kalle Dalheimer, Terry Dawson, Lar Kaufman and Matt Welsh, Running Linux , 4'th Ed., O'Reilly, 2002. . . 11. . . 1377 .

© 122

94

Accessories Text Editor : . . Application

. Linux Accessories Application . . Terminal : :

pstree 1. .

. kill 2. . kill

. first.c 3. . #include #include int main() { pid_t pid; char *message; int n;

printf(“fork program starting\n”); pid = fork(); switch(pid) { case 1: perror(“fork failed”); exit(1); case 0:

© 123

message = “This is the child”; n = 5; break; default: message = “This is the parent”; n = 3; break; }

for(; n > 0; n) { puts(message); sleep(1); } exit(0); }

execp.c 4. printf(“Done.\n”); #include #include int main() { printf(“Running ps with execlp\n”); execlp(“ps”, “ps”, “ax”, 0); printf(“Done.\n”); exit(0); }

execlp(“ps”, “ps”, “ax”, 0); system 5. system .

sleep(i) & 6. i 2 First Program Finished 12.c 11.c Second Program running 11 .

© 124

. 12 .

. 3 7. ps –al . (S)

©

10

101 . 1 IPC . 2IPC . IPC . . . 3

102 : : • Signal Pipe • fork •

1 Kernel 2 InterProcess Communication 3 Latency

© 126

103 : : • • 1 • • ... • . . . IPC (Pipe ) IPC unix System V IPC . : : Semaphore • . 2 3 4 . Semaphore . ) . . ( Message Queue •

1 Modularity 2 Critical region 3 Time Slice 4 Exception

© 127

. . 1 Message Shared memory • . .

2 104 3 . 4 . . signal .h . SIG . : : 101 Signal Name Description SIGCHLD Child process has stopped or exited SIGCONT Continue executing, if stopped SIGSTOP Stop executing. Can’t be caught or ignored SIGTSTP Stop signal for Terminal SIGTTIN Background process trying to read SIGTTOU Background process trying to write

SIGSTOP stop . SIGCONT .

1 Asynchronous 2 Signals 3 Raise a signal 4 Signal Handler

© 128

. . SIGINT . CTRL+C . . SIGINT ! . SIGSTOP SIGKILL . . : : SIGKILL KILL -9 nnnn . SIGKILL 9 1 nnnn 9 SIGTERM . . . . : . : : . SIGUSR2 SIGUSR1 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ

1 Process ID

© 129

26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR

105 . signal.h signal() integer . : : signal 1 void *signal(int sig, void *func (int)) SIGSTOP : : signal(SIGSTOP , user_defined_function); user_defined_function : : . SIGSTOP signal(SIGSTOP,user_defined_function ()); // this is an ERROR ! ctrl+z SIGSTOP : .

raise kill 106 integer : 2 kill () . : : . kill(3582,SIGSTOP); . 3582 SIGSTOP . kill

1 Prototype 2 System Call

© 130

. raise () . .

fork () 107 . fork () . . . IPC . fork () . . 1init . ) SIGCLD ( defunct : : . #include main() { Signal (SIGCLD,SIG_IGN); //Now my child don’t have to wait. . fork() ; . . } 2 SIG_IGN . .

1 1 1 PID 2 Ignore

© 131

wait . init defunct : . defunct init • . Init • loop 2 . . 1 defunct exit () exit () . wexitstatus () . integer wexitstatus () . wait . . 2

Pipes 108 IPC . : : pipe .

< ال ن داد يا از ا ا د >

. shell 3 : : .

1 Reboot 2 . . wait () 3 '|' Pipe character

© 132 cmd1|cmd2 : : shell . cmd1 1. . cmd2 cmd1 2. . cmd2 3. : :

110

fork () PIPES . PIPES IPC . 1 . IPC C stdio.h fwrite () fclose () fopen () . write () close () open () . stdout "0" stdin . stdio.h fopen () . "2" stderr "1" . . pipe () pipe . 3 2 pipe .

1 File Descriptors 2 Write end 3 Read end

© 133

. pipe . 10kb . : : pipe

pfd[1] fork () . : :

. pipe write read eof write pipe . read : :

© 134

109 1. Neil matthew and Richard stones,Beginning Linux ProgrammingT 4'th ed.,wiley Publishing, Inc., 2007. 2. Beej's Guide to Unix Interprocess Communication by Brian "Beej" Hall: http://www.ecst.csuchico.edu/~beej/guide/ipc/ 3. Workshop on Inter Process CommunicationIVEtsing YIDepartment of Information Communication Technology 4. The Linux Programmer's GuideBY : Sven Goldt,Sven van der Meer,Scott Burkett,Matt Welsh Version 0.4 ., March 1995 5. CprE 308 Lab 5: Inter Process Communication in Unix Department of Electrical and Computer Engineering Iowa State University Spring 2006

© 135

10 10

. 1. #include #include int main() { while (1) { getchar(); } return 0; }

. ctrl+c . ( ctrl+c ipc (

. 2. #include #include #include void func( int ); int main () { if (signal(SIGINT,func)==SIG_ERR) { perror( "Signal Error"); exit(1); }

while (1) { getchar(); } return 0; } void func ( int sig)

© 136

{ printf( "\nYou are not able to stop this yet !\n" ); } ctrl+c ( ( . ctrl+c (

. 3. void func ( int sig) { signal (SIGINT,func); printf( "\nyou are not able to stop this yet !\n" ); }

ctrl+c ( SIGQUIT . ctrl+\ ( . . . SIG_IGN ( ) ( ctrl+c ( . . . ( ( : )

. SIGFPE 4. . ( "WARNING: This is a division by zero " . . (

© 137

enter 5. I " kill "q" . "like linux Operating System Laboratory . . getpid() :

. 6. . ps –al

. 6 7. signal (SIGCLD , SIG_IGN) ; . . ps –al

: 8. #include #include #include #include int main() { int pfds[2]; char buf[30]; if (pipe(pfds) == -1) { perror( "pipe" ); exit(1); } printf( "writing to file descriptor #%d\n" , pfds[1]); write(pfds[1], "test" , 5); printf( "reading from file descriptor #%d\n" , pfds[0]); read(pfds[0], buf, 5); printf( "read \"%s\"\n" , buf); return 0; }

© 138

. ( . pfds pipe ( write read (

: 9. #include #include #include int main(){ int pfds[2]; char buf[30]; pipe(pfds);

if (!fork()) { printf( " CHILD: writing to the pipe\n" ); write(pfds[1], "test" , 5); printf( " CHILD: exiting\n" ); exit(0); } else { printf( "PARENT: reading from pipe\n" ); read(pfds[0], buf, 5); printf( "PARENT: read \"%s\"\n" , buf); wait(NULL); } } . . ( . . if ( pipe fork (

©

11

111 1 . . 2 . . .

112 . .

1 Shell 2 Back up

© 140

113 .

1131 . . Kernel . . ) . . . .(

1 11

: : 1 2 3 1 4 5

1 Files

© 141 –

1 1132 . 1 0 . . . . ، . . :

1 11 Shell Name Developed by Where Remark BASH(BourneAgain Brian Fox and Chet Free Software Most common shell in Shell) Ramey Foundation Linux .It’s Freeware Shell. CSH(C shell) Bill Joy University of The C shell’s syntax and California(For usage are very similar to BSD) the C programming language KSH(Korn Shell) David Korn AT&T Bell Labs TCSH See the man page TCSH is an enhanced but Type $ man tcsh completely compatible version of the Berkeley UNIX C shell(CSH)

. 2 : :

$ cat /etc/shells

DOS Command.com ( ) . .

1 Shell 2 Syntax

© 142

Shell Scripting 1133 20 . . Shell . Shell Scripting Batch Scripting . . Shell Scripting . Shell Scripting

114 : : Applications/Accessories/Terminal

VI . . .sh . .sh . . Shell Script

1141 first . .

© 143 –

$ vi first # # First shell script # clear echo “Hello Shell Scripting”

'#' . Comment . clear first . . . echo . . ./first vi Permission denied : : . chmod +x first . . ./first : : \ • : echo \ "Salam" : : . ; • if true if true; then echo "Condition is true"; fi then echo "Condition is true" fi

1142 : 2 .

© 144

1 . UDV : : . $variable name=value . variable name value . $ Shell Scripting $no=10 . . 10 no : : '_' 1. . . ( Space ) 2. : $ no =10 $no= 10 $10 = no : : $no=10 . 3. . (null ) 4. $ ver="" . ? * 5. . 6. declare –i a=5

echo : : echo [option] [string,variable]

1 User Defined Variable

© 145 –

. . . . .... $echo –e "\033[34m Hello OSLab!" \033 . ANSI echo [34m . Hello OSLab! \033[ ANSI ... . m,q,s,u

echo 2 11 Character or Use in CSI Example Letter h Set the ANSI mode Echo –e”\033[h” l Clear the ANSI mode Echo –e “\033[l” m Useful to show characters in different Echo –e “\033[35m Hello” colors or effects such as BOLD and Blink q Turns keyboard num lock,caps Echo –e”\033[2q” lock,scroll lock LED on or off s Store the current cursor x,y Echo –e “\033[7s” position(col,row position) and attributes u Restore cursor position and Echo –e “\033[8u” attributes

1143 : : expr op1 mathoperator op2 : : $ expr 1 + 2 $ expr 10 \* 3 $echo `expr 6 + 3` . \* .

© 146

. ' ` . ! ! Tab ` 0 . 1 : : . . $echo $?

read : : . read variable1, variable2,…, variable : : $ vi getname # get user name echo “Please Enter Your Name:” read name echo “hello $name”

if : if if condition then commands elif condition then commands else commands fi

else elif . commands condition . .

1 Exit Status

© 147 –

test . : : . test expression : : if test 5 gt 0 then echo "first number is greater" fi . [ ] test : : if [ 5 gt 0 ] then echo "first number is greater" fi . test : : ( )

test 3 11 ( not ) exp !exp ( and ) exp2 exp1 exp1 a exp2 ( or ) exp2 exp1 exp1 o exp2 str2 str1 str1 = str2 str2 str1 str1 != str2 int2 int1 int1 eq int2 int2 int1 int1 nq int2 int2 int1 int1 gt int2

int2 int1 int1 ge int2 int2 int1 int1lt int2 int2 int1 int1 le int2 file e file

© 148

True ( ) False C . . False True Shell Scripting ( )

115 : : : : : for loop for ((expr1;expr2;expr3)) do …………… done

: : while : While loop while [ condition ] do command1 command2 …. done continue continue break break . . continue break . * for . . for fn in *; do echo "$fn" done 6 1 while : : n=1 while [ $n –le 6 ]; do echo $n

© 149 –

let n++ done . let . . test [ ]

116 1. Quigley, Ellie, Linux Shells by example , PrenticeHall Inc., 2000. 2. Vivek G. Gite, Linux shell scripting tutorial ver.1.0 , http://edoc.huberlin.de/oa/articles/reiP8SRiytnBs/PDF/21bUc8YeDzZpE.pdf

© 150

117

: : . 10 myno . 1 $echo myno ( . . . 10 (

) . 2 :( ( ( (

. . . . 3 $m =8 $a?=2 if test $m gt a? then echo “first number is greater”

: : . 4 whoami ( date ( cd ~ ( cd ~ : . . pwd $ cd / $ pwd $ cd ~ $ pwd echo {a..z} (

© 151 –

. n $n ( . 5 . 2 . . . . ( . .

: : . 6

$ x=`/sbin/ifconfig` $ echo $x . . .

. . 7. s=”Linux OS” for ((i=8 ;i>0 ;i)) do s=${s:0:i} echo $s>>1.txt done

: : . 8 function_name() { command1; command2; .. commandN; } : : function_name

© 152

0 0 id u ( user is root id root Shut Down Sun Virtual Box ( : : settings… Storage>IDE Controller >Host Drive CD–ROM Attributes . . cd.sh . start function lscd () {

DEVICE=$1 mount $DEVICE ls l $DEVICE umount $DEVICE eject $DEVICE } : : while . 9

C printf : : : printf "\n" $y

©

Samba Server 3.0 12

11 Samba Samba . Samba . : : Samba 2 1 • (.... ) 3 • 4 •

. . 3.0 Samab Server

1 Server 2 Clients 3 Domain controller 4 Validation

© 154

12 Samba . : : • Samba Server • File Server • Samba Smbclient • SWAT Samba •

13 2Smb 1 Samba . .

131 Samba . AndrewTridgel l 1992 Samba Samba . . . SMB

Samba 2 3 1 Samba 3 Samba Windows clinet

1 Deamons 2 Server massage block 3 Platform

© 155 Samba Server 3.0 –

. . 1 ( SMB ) CIFS . . . Samba . CIFS Samba SMB OS/2 . . Samba . Samba . Nmbd Smbd : : CIFS File and printer services • Authentication and authorization • Name resolution • Service amnouncement (browsing) •

CIFS File and printer services User mode Share mode . SMB Daemon Smbd . Authentication and authorization . . : : Samba . FTP : Smbclinet • NetBIOS name service : Nmblookup • . IP NetBIOS

• Swat : اد از ان Samba Web Administrator Tool ﺕان اد از ور وب ، رار samba را ﺕ ﻥد.

1 Common Internet File System

© 156

SWAT 1 12

swat 2 12

Samba 1 133 . smb.conf Samba . Samba : : 1. 2. . Samba ( )# 2 . /etc/samba/smb.conf

1 Directory 2 Comments

© 157 Samba Server 3.0 –

1 [ ] . ( ); . . No Yes 2 : : smb.conf : Global Key/Value Workgroup = . . . . Security = user : :

[share] comment = Ubuntu File Server Share path = browseable = yes guest ok = yes read only = no create mask = 0755 : : . : Comment • . : Path • : Browseable • . Windows Explorer client : Guest ok • . . : Read only • 3 . : Create mask •

1 2 Boolean 3 Permissions

© 158

: sudo mkdir p sudo chown nobody.nogroup : : Samba sudo /etc/init.d/samba restart . .

SWAT 134 . Command Shell Linux Windows . Web

Ubuntu SWAT 3 12

© 159 Samba Server 3.0 –

1 Web Samba Swat Linux Swat . . . Swat Samba .. . bin /usr/local/samba/ /etc Swat tcp 901/Swat Gedit Services 2 Swat . . . TCP 901 3 etc/xinetd.d/ . Xinetd : : swat # description: swat is the Samba Web Administration Tool, which # allows an administrator to configure Samba using a web # browser interface, with the URL http://localhost:901 service swat. } socket_type = stream wait = no protocol = tcp only_from = localhost user = root log_on_failure += USERID server = /usr/local/samba/bin/swat port = 901 disable = no {

. : : . # bin/kill HUP a xinetd TCP . . 901

1 Samba Web Administration Tools 2 Port 3 inted xinetd Internet super Daemons

© 160

http //: server IP address :901 . Samba http :// localhost :901 . . 1 Swat . . Swat Global Swat 3 2 . . . TCP/IP : Base Options  : Security Options  . 0 log level : Logging Options  . 1 . TCP/IP : Tuning Options 

1 Root 2 Logging 3 Tuning

© 161 Samba Server 3.0 –

SWAT 4 12

© 162

Global 5 12

Share Swat . smb.conf . .

© 163 Samba Server 3.0 –

Swat Share 6 12

© 164

14 . . Firewall 1. Global Swat 2. . WINS Options Browse Options . .

15

1. Using Samba , 2nd Edition,By Jay Ts, Robert Eckstein, and David Collier Brown,2nd Edition, February 2003 ,O'Reilly & Associates, ISBN: 059600256 4, www.oreilly.com/catalog/samba2/ 2. Samba3 by Example Practical Exercises in Successful Samba Deployment, John H. Samba Team Terpstra ,http://www.samba.org/samba/docs/man/Samba Guide/ 3. The Official Samba 3.5.x HOWTO and Reference Guide , http://samba.org/samba/docs/man/SambaHOWTOCollection/

© 165 Samba Server 3.0 –

16 ) Ubuntu . XP ( . . . Virtual Box Client Linux Server Linux ::: . . virtual box . Virtual Box Virtual Box . Host – only adapter (Attached to :) . Virtual Box DHCP .) . 192,168,56,0 : : File > Preferences > Network

ipconfig XP ( 1. .

System > Preferences >Network Connections . ifconfig ( . ( ) . . . ( .

© 166

. . : etc/sysconfig/… (

. ping IP ( 2. . . ) Ping ( . 1 . . Ping 2 Ping ( . . . Ping

Samba : : : $ smbd –v . . Samba : : Virtual Box Settings>Shared Folders Samba Samba utility ). ( (

1 man 2 Options

© 167 Samba Server 3.0 –

Places etc/samba Network cd : : $ tar xvfz samba3.5.2.tar.gz Extract . here Samba . Samba 1 . Source3 ): ( ( $ cd /etc/samba/samba3.5.2/source3 $ sudo su # ./configure # make 2>&1 | tee make.log # make install /usr/local/samba . . : : : # autoconf # makeclean # rm config.cache . Samba ( 3. /etc/samba .

. samba ( Samba Server Samba : : root

1 Source Code

© 168 root@PC : aptget install samba smbclient . ( share this . Sharing option .. guest account folder My Network Places IP . .

Gedit smb.conf ( 4. . . . . Sudo gedit /etc/samba/smb.conf . ( sudo chown . . ( : : . sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orginal

/srv/samba/sharegroup Share directory ( . xp ( ( ( Write Protected ). (

( 5. . Example.txt Place>Network>Windows .

© 169 Samba Server 3.0 –

Network . . ( Example.txt smb:/// . . : : Samba Client 6. root@PC : aptget install smbf Samba smbclient L //server U user prompt smbclient //server/share U user ( ( user .) SMB:/> Help ( . . FTP . smbclient.txt ( . . .

SWAT 7. Swat SwatShare Share . . .

©

13

131 . . . . . . . . . . .

©