Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming.

Similar presentations


Presentation on theme: "Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming."— Presentation transcript:

1

2 Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming Deadlines Lab Assistance, Questions, and Answers

3 Link of the week https://freedom-to-tinker.com/blog/felten/source-code-and-object-code What is object code? http://www.linfo.org/object_code.html Object File Format

4 Link of the week What is object code? An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker, which in turn typically generates an executable or library by combining parts of object files. There are various formats for object files, and the same object code can be packaged in different object files.

5 Link of the week 0000000 7f45 4c46 0102 0100 0000 0000 0000 0000 0000020 0001 0002 0000 0001 0000 0000 0000 0000 0000040 0000 0234 0000 0000 0034 0000 0000 0028 0000060 0008 0001 002e 7368 7374 7274 6162 002e 0000100 7465 7874 002e 726f 6461 7461 002e 7379 0000120 6d74 6162 002e 7374 7274 6162 002e 7265 0000140 6c61 2e74 6578 7400 2e63 6f6d 6d65 6e74 0000160 0000 0000 9de3 bf88 f027 a044 f227 a048

6 Link of the week Object code produced by a compiler Programmers write programs in a high-level language called source code (Java or C Language). The source code consists of instructions in a particular language, like C, C++, or Java. However, computers can only execute instructions written in low-level language called machine language.

7 Link of the week What is Object File Format? An object file format is a computer file format used for the storage of object code and other related data. There are many different object file formats; originally each type of computer had its own unique format, but with the advent of UNIX software portability, some formats, such as COFF and ELF became the de facto standard used on different kinds of operating systems. It is possible for the same file format to be used both as linker input and output, and thus as the library and executable file format.

8 Link of the week

9 Course expected outcome Learning Outcomes (Week four) Write Perl scripts, including variables, control flow, and regular expression syntax

10 UNIX Operating System UNIX file system When we talk about a UNIX file system, we are actually referring to an area of physical memory represented by a single i-list. A UNIX machine may be connected to many different file systems, each with its own i-list. One of those i-lists points to a special storage area, known as the root file system. The root file system contains the files for the operating system itself, and must be available at all times.

11 UNIX Operating System Some file systems are considered removable. A removable file systems can be attached, or mounted, to the root file system. Typically, an empty directory is created on the root file system as a mount point, and a removable file system is attached to that empty directory. When you issue a cd command to access the files and directories of a mounted removable file system, your file operations will be controlled through the i-list of the removable file system.

12 UNIX Operating System The purpose of the i-list is to provide the operating system with a map into the memory of some physical storage device (disk drive). The map is continually being updated, as the files are created and removed, and as they grow and shrink in size. Thus, the mechanism of mapping must be very flexible and robust in order to accommodate drastic changes in the number and size of files. The i-list is stored in a known location, on the same memory storage device that it maps.

13 UNIX Operating System Each entry in an i-list is called an inode. An inode is a data structure that provides the flexibility to track the changing file system. The inodes contain the information necessary to get information from the storage device, which typically communicates in fixed- size disk blocks.

14 UNIX Operating System An inode contains 10 direct pointers, which point to disk blocks on the storage device. In addition, each inode also contains one indirect pointer, one double indirect pointer, and one triple indirect pointer. The indirect pointer points to a block of direct pointers. The double indirect pointer points to a block of indirect pointers, and the triple indirect pointer points to a block of double indirect pointers. By structuring the pointers in a geometric fashion, a single inode can represent a very large file.

15 UNIX Operating System It should make a bit more sense to view a UNIX directory as a list of i-numbers, each i- number referencing a specific inode on a specific i-list. The operating system traces its way through a file path by following the inodes until it reaches the direct pointers that contain the actual location of the file on the storage device.

16 UNIX Operating System UNIX inode attributes The POSIX standard mandates file system behavior that is strongly influenced by traditional UNIX file systems. Regular files must have the following attributes: The size of the file in bytes. Device ID (this identifies the device containing the file). The User ID of the file's owner. The Group ID of the file. The file mode which determines the file type and how the file's owner, its group, and others can access the file.

17 UNIX Operating System Additional system and user flags to further protect the file (limit its use and modification). Timestamps telling when the inode itself was last modified (ctime, inode change time), the file content last modified (mtime, modification time), and last accessed (atime, access time). A link count telling how many hard links point to the inode. Pointers to the disk blocks that store the file's contents (see inode pointer structure).

18 UNIX Operating System The UNIX file system relies on data structures about files, beside the file content. The inode content information is considered metadata data that describes data. Each file has a number associated with it, which is called an inode number.

19 UNIX Operating System

20

21

22

23 UNIX directory  In UNIX, directories are files which contain information about other files. A UNIX directory is a file whose data is an array or list of (filename, i- node#) pairs. – It has an owner, group owner, size, access permissions, etc. – Many file operations can be used on directories – As a file, a directory has an i-node type structure. – A flag in the structure indicates its type.

24 UNIX Operating System UNIX directory Unlike other files, the kernel imposes a structure on directory files using the UNIX command mkdir. A directory is a sequence of lines, a sequence of directory entries of variable length where each line contains an inode number and a file name mapping:

25 UNIX Operating System UNIX command mkdir sub_dir The creation of a sub_dir directory file and an inode for it An inode number and name are added to the parent directory file Directory sub_dir 133. 23145.. 9645 dump 45270 script

26 UNIX Operating System 133. 23145.. 9645dump 45270script 9645. 133.. 635core1 2022core2 45270. 133.. 7467ksh 2324csh

27 UNIX Operating System Dot and dot-dot files “.” and “..” are stored as ordinary file names with inode numbers pointing to the correct directory files.

28 UNIX Operating System File system directory structure  The file system directory structure is a link between the inode hash list and the directory files.  The root “/” inode is always number 2. The root “/” directory file data block is located thru inode number 2.  Directory file entries include each entry. Where file name is the local (unqualified) directory or regular file name within the directory and inode number is an index into the inode hash array.  The (inode number) inode in the hash list entry has pointer to the data block of the subsequent regular file or directory file data block.

29 UNIX Operating System File system directory structure  If it is a directory file, the directory data blocks are read for the next, and the process repeats.

30 UNIX Operating System File system directory structure If it is a regular file, the data blocks are located and read. This process also explains the difference between hard links and soft links. A hard link directory entry is a direct pointer to a file inode. A soft link is a pointer to another directory entry. In a link, rm clears the directory record. Usually, this means that the inode number is set to 0 but the file may not be affected. The file inode is only deleted when the last link to it is removed; the data block for the file is also deleted (reclaimed).

31 UNIX Operating System Disk drive

32 UNIX Operating System File system data structure Disk drive File system inode...inode Boot Block Super Block I-List Data blocks for files, and directories. Partition

33 UNIX Operating System Hard link

34 UNIX Operating System Soft link

35 UNIX Operating System Link (ln) command The ln command is used to create a hard and soft link. Hard link (physical): ln original_file.txt hard_link.txt Soft link (symbolic): ln –s original_file.txt soft_link.txt

36 UNIX Operating System UNIX directory  Directory data is stored as binary, and cannot be displayed using the cat command. But some older versions of UNIX allow: od -c dir-name.  Although directories are files, UNIX permissions – rwx- have slightly different meanings: - r, lists directory contents - w, add a file to the directory - x, cd to the directory

37 UNIX Operating System User process accessing data  Given the file name. To get to the file’s control block (FCB), use the file system catalog (Open, Close, Set_Attribute)  The catalog maps a file name to the file control block – Checks permissions  file_handle=open(file_name): – Search the catalog and bring file control block into the memory – UNIX: in-memory file control block: in-core i- node

38 UNIX Operating System User process accessing data  Use the file control block to get to the desired offset within the file data: (CREATE, DELETE, SEEK, TRUNCATE)  close(file_handle): release file control block from memory

39 UNIX Operating System What is a filter? A UNIX filter command performs an operation or manipulation of the input text from a file. Standard in and out are typically used during this operation. UNIX Command Line Filters awk, cat, cut, expand, compress, fold, grep, head, nl, perl, pr, sed, sh, sort, split, strings, tail, tac, tee, tr, uniq, and wc

40 UNIX Operating System File System Filters cat, cd, chmod, chown, chgrp, cksum, cmp, cp, dd, du, df, fsck, fuser, ln, ls, lsattr, lsof, mkdir, mount, mv, pwd, rm, rmdir, split, touch, umask Processes Filters at, chroot, cron, exit, kill, killall, nice, pgrep, pidof, pkill, ps, pstree, sleep, time, top, and wait

41 UNIX Operating System Test Command A common way to set up a condition for the if command is with the test command. test condition or [ condition ] The test command evaluates the condition and returns 0 or 1, depending on the results of the test. The brackets work exactly like the test condition. The open bracket is a link to test.

42 UNIX Operating System Constructing Conditions -s file-r file-w file -S file -x file-f file-d file Examples: if [ ! –f /etc/quotatab ] Does the plain file named /etc/quotatab not exist? If [ -d /etc/rc0.d ] Is the /etc/rc0.d name a directory?

43 UNIX Operating System Constructing Conditions -S file = True if the file exists and its size is greater than zero. -s file = True if the file exists and is a socket. -w file = True if the file exists and is writable. -x file = True if the file exists and is executable. -f file = True if the file exists and is a regular file -d file = True if the file exists and is a directory.

44 UNIX Operating System Perl and Shell Similarities Perl scalar@ARGV ~ Shell $# Perl $ARGV[0] ~ Shell $1 Perl $ARGV[1] ~ Shell $2 Perl unless(scalar(@ARGV)==2) ~ Shell if [ $# != 2] All Perl statements are terminated with a “;” Perl exit 0 is returned if execution was successful. Perl exit 1 is returned if execution fails.

45 UNIX Operating System Perl syntax $? - this variable contains the return value # - precedes a comment statement in Perl \n - new line syntax “ …” $strexp = “This text is considered as a string”; ‘ …’ $charexp = ‘a’; ` …` $cmdexp = `ls –l`; @ARGV – array containing command line arguments $_ - default implied scalar

46 UNIX Operating System Relational operators There are two types of relational operators. One class operates on numeric values, the other on string values. Relational operators Numeric String Meaning > gtGreater than >= ge Greater than or equal < lt Less than <= leLess than or equal

47 UNIX Operating System Equality Operators Numeric String Meaning == eq Equal to != ne Not equal to  cmp Comparison, sign results -1 if the left operand is less than right operand 0 If both operands equal to right operand 1 If the left operand is greater right operand

48 UNIX Operating System Equality Operators if ( $count != 5 ) { print "The counter is NOT equal to 5.\n"; } if ( $response eq 'YES‘ ) { print "You said YES"; } else { print "I don't know what you said, but it wasn't YES"; }

49 UNIX Operating System Initial Perl design Perl is designed to - Process text data - Perform pattern matching - Utilize string handling tasks Perl is available on many platforms - UNIX - Linux - HP-UX - Red Hat Linux Enterprise

50 UNIX Operating System Perl utilizes two types of categories Singular variables that represent a single-value. The variable prefix symbol for a scalar is the $. Plural variables are ones that contain multiple- values. Arrays and hashes are two multi-valued variables. The variable prefix symbol for an array and hash are @ and %, respectively.

51 UNIX Operating System Perl data types $answer = 42; (an integer) $pi = 3.14159265; (a “real” number) $animal = “horse”; (string) $statement = “I exercise my $animal”; (string with interpolation) $amount = ‘It cost me $5.00’; (string without interpolation) $cwd = `pwd`; (string output from a command)

52 UNIX Operating System Initialize Perl array Definition: An array is an ordered list of scalars, accessed by the scalar’s position in the list. @garage = (“car”, “mower”, “broom”); @persons = (“Will”, “Karim”, “Asma”, “Jay”); $count = @persons;

53 UNIX Operating System Perl Formats if ( … ) { … } while ( … ) { … }

54 UNIX Operating System Perl Formats for ( initialize variable, test variable, increment variable) { … }

55 UNIX Operating System Perl formats if ($append) { open(MYOUTFILE, ">filename.out"); #open for write, overwrite } else { open(MYOUTFILE, ">> filename.out"); #open for write, append }

56 UNIX Operating System Points of interest UNIX uses a hierarchical file system for storing files. This system consists of a "root" directory which is made up of sub-directories which in turn are made up of sub-directories. All UNIX directories contain a dot (.) and dot- dot (..) files.

57 UNIX Operating System Demonstrate Perl script:./week_four.pl

58 UNIX Operating System Moving Around in UNIX pwd rmdir telnet sftp talk passwd w finger write

59 Break-out problems $strexp = “This text is considered as a string”; $intexp = 10; $floatptexp = 2.54; $charexp = ‘a’; $cmdexp = `ls –l`; $argexp = (“two”, “four”, “six”); @array_exp = (“Jackie”, “Vicki”, “Alex”); $array [0] = “new value”; $a = $b + 5; $container = @container; ($map{blue}, $map{orange}, $map{jade}) = (0xff0000, 0x00ff00, 0x0000ff0);

60 Hands-On-Information Lab Assignment 3-1, Advanced Scripting, due February 1, 2015. Lab Assignment 4-1, Simple Perl Exercise, due February 8, 2015. Read Chapters 1 and 2 in Essential System Administration text. Read Module Two listed under the course Web site. Everyone should have received a Perl Quick Reference document and script logic for Lab Assignment 4-1.

61 After class assistance Questions? Comments? Concerns? After each Franklin Live session, I will remain on the session to provide assistance unless otherwise indicated.

62 Lab Assistance available by phone and/or email


Download ppt "Agenda Administrative Issues Link of the Week Review Week Two Information This Week’s Expected Outcomes Next Lab Assignment Break-Out Problems Upcoming."

Similar presentations


Ads by Google