|
Unit [01] Introduction to UNIX
- Objectives:
- Select statements which describe the philosophy of the UNIX
system:
- The Operating Systems power comes from the relationship between programs not from the programs themselves.
- Small is beautiful, do whatever is simpler, programs should do one task and do it well, solve the problem once but at the right level.
- Select key features of the UNIX operating system:
- General-purpose (equally capable of word processing, database, networking, program development, etc.),
- Interactive (user is in control of task),
- Multi-user (designed to support a group of simultaneous users),
- Multitasking (user can start more than one program at a time),
- Portable (runs on a variety of machines C compiler)
- Identified the basic components of the UNIX operating system and state the function of each:
- Hardware configuration running UNIX 2 MB of RAM for operating system, 5 MB of RAM for
each user, typical system configuration 8 MB of RAM-64 MB RAM
- Kernel is the main component of UNIX and consist of;
- System call interface (allows interface to the operating system and provide system
services to programs such as opening the file, giving day or time, etc.)
- Process control subsystem (largest part of the kernel and provides process
resources management, interprocess communication, memory management)
- Device drivers (programs provide interface with hardware peripherals installed on the
computer)
- File systems are used to store data in an organized and efficient manner. Features include:
- hierarchical organization (inverted tree structure)
- dynamic file size (this space is automatically allocated
),
- file security (read, write, execute permission set
),
- uniform I/O (most utilities in programs read and write files)
- Shell is often called a command interpreter and provides user input and output. The shell
provides; command interpretation, filename expansions, I/O redirection, establishes and maintains the users environment, programming language
- Evolution of the operating system: dedicated, batch processing, multitasking, multi-user,
hardware independent.
- Evolution of the UNIX operating system: AT&T system V, Berkeley UNIX, XENIX, SCO UNIX,
Solaris
- Operating systems are made up of several components:
- Scheduler, the systems traffic cop (not used in single-user single-task OS)
- Device drivers, provide main interface with hardware devices
- File manager, provides access to data stored on mass storage devices (hard disk)
- System utilities, programs that provide access to other operating system components (Called from applications)
- UNIX architecture: hardware, kernel, file systems, shell
[ top ]
Unit [02] Using UNIX
- Objectives:
- Login to a UNIX system using your user name and password. Log On to local machine: [user01 user01] or [root area51] Log Off local
machine: Make yourself su, then /usr/sbin/shutdown -g0 -y -i0, then power down when prompted.
- Use the UNIX users reference manual to locate and you selected
commands with and without options and arguments. Section 1 (commands) section 2 (system calls) section 3 (library routine) section 4 (file formats) section 5 (miscellaneous) section 6 (games)
section 7 (special files) section 1M (system administration)
- man page: name of command and section found, short description of command, synopsis of
command and options and arguments.
- Perform system status inquiries using the, who, date, ps commands
- Send and receive electronic mail and communicate with other users via the write command
- UNIX documentation: guides (provides step-by-step instructions and procedural guidelines)
manuals (provide detailed reference on command syntax, and other pertinent information)
- UID = user ID, PID = process ID, PPID = parent process ID, C = processor utilization for scheduling,
STIME = process start time, TTY = terminal process is connected to, TIME = amount of CPU time consumed by the process, COMD = command.
[ top ]
Unit [03] Using UNIX:
- File system layout:
- Boot block (contains the information needed to boot the operating
system from the disk. Only the boot block from the root file system is use)
- Super block (contains information about the file system such as a
number of data blocks, the number of inodes, size of the file system, file system state, number of free data blocks, number of free inodes, the super block describes the file system)
- I-list (contains the list of inodes which are used to store information about the files and directories
on the disk. There is one inode assigned to each file and directory on the disk.)
- Data blocks (contains the actual data stored on the disk. A file or directory may have more than
one data block. Each physical block holds 512 bytes of data.)
- Access permissions: three levels of user types associated with each file or directory;
user, group, others. Access can be set to read, write, execute (for files), search (for directories)
- Suppressed files: the file or directory name which begins with dot (.) is normally suppressed when listing
the files and directories requested.
- Accessing files and directories: The directory is opened and then searched for a file of the name
specified, the I-number for the file is read from the directory, the I-number is used to locate the inode in the I-list, the inode is opened and the inode information is used to ascertain if the user as the correct
permissions to access the file based on permissions, user ID group ID, if the permissions are correct the data block addresses are used to physically locate the information on the hard disk, the access times are
updated in the inode if the file was modified, the modified time is also updated in the inode.
- Access permissions for symbolic link files: the access permissions shown on symbolic link file
pertaining to the symbolic link file itself, and not to the file which is referenced by the symbolic link. Use the ls -L command to learn actual file permissions.
- Linking files: the link command allows you to create a reference to a single file from another directory
entry. There are two types of links.
- The hard link means that there are two or more directory entries which have the same inode
number for the file (although file names may be different and the files may reside in different directories) the data can be accessed by either filename. You cannot perform a hard link of a file
across file systems. This is because link uses the inode to locate the file and inodes are different for files on separate file systems. However, files may be linked across to file systems using symbolic links.
- The symbolic link is simply a file which contains the pathname of another file (usually, it is best to
specify the full pathname of the reference file) Symbolic links can be used to reference entire directory structures. When files are recreated in the link directory the actual data is stored in the target directory.
- Notes about hard links, the link simply allows a single file to be reference by more than one
filename. Removing the original file does not remove the data from the hard disk. The file is removed only when the link count in the inode goes to 0, editing any of the linked files will change
the contents of all files linked to the original file. Link files should only be writeable by the owner, you cannot create hard links across file systems.
- Notes about symbolic links, the -s option must be specified to create a symbolic link, if the file a
symbolic file references is removed, the symbolic link file will still indicate your reference to the removed file, but you will not be able to access the file data, absolute pathnames should be used
for both the source and target file names when creating symbolic link files this practice prevents the possibility of creating a self referencing file.
- Unit [03] review questions:
- Name of three types of UNIX files?
- Directory files (contain the structure specific to the operating system, directories can grow
but do not shrink when a file is removed the inode is set to zero, the directory contains entries of [i-number , filename] pairs, the inode contains information which describes the file
including the location of the data.)
- Ordinary files (sequential file, no structure imposed by the operating system, contains ascii
text, data, programs, the symbolic link information),
- Special files (interface to peripheral devices, read / write like ordinary file, organized under
/dev directory, special devices may be
- block (two types of data blocks;. physical
(segments on the disk drive) and logical (a number of physical blocks) or
- character (read / write one byte at a time. Example terminals, printers, tape drive))
- Block devices are referred to as
cooked devices and character devices are referred to as raw devices.
- Where is the name of a file stored? The directory contains [i-number, filename] pairs the name is
contained within the pair. Where is the directory located? Super block or I-list?
- On UNIX system 5 release 4, what is the maximum length for a filename? 255 filename length
kept in directory.
- If you wanted to create files and directories with the default permission that allow access for only
the owner what would you do? umask 077
- List two advantages of linking files rather than copying files. Linking files provides an efficient method of referencing the same information. Linking is much more practical than copying when the
file size is large. Additionally, when the files modified the links will point to the modified file, and allows access to the file contents from multiple directories.
- What does the -f option do to the mv command? mv -f will move the file(s) without prompting
even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal. If you move a file within the same file system it is simply renamed, when you move a file
to another file system it is first copied and then the original is deleted, after a move. The new file has all of the attributes (permission, ownership, and group ID) as the original file.
- What information is contained in the inode for a file/directory? The I-number contained in the directory refers to inode address. The inode contains all the information about a file. The
information contained in the inode is: permissions (a file or directory access permissions) link count (the number of links to file or directory) user ID (the ID it of the person who owns file or
directory) group ID (the ID of the group which the file belongs to) date and time information (this field contains three time stamps: date inode changed, date file was modified-written, date
and time file was last access-read) size (file size in bytes) data block addresses (location of the data on the physical disk)
- What is the difference between the "x" bit set are on a file and the "x" bit set on a directory? The "x" bit set on a file allows the file to be executed. The "x" bit set on a directory allows the directory to be modified.
- What option would you set in the ls command to show each files Inode number? ls -i
- What precautions must you be aware of for directors which have the right permission set? Any
user can remove files or create files in the directory.
- If you want to use 16 lines per page using the pg command, what option would you enter? pg -16
filename
- Name the commands that'll allow you to read a directory? ls
- Name the commands that'll allow you to write a directory? cp, mv, ln, rm
- Name the commands that'll allow it you allow you to search the directory? ls -l, cd
- You try to copy a file and it fails. However you can link to the file. What do you deduce? The file does not have read permission but the directory in which the file is located does have read permissions.
- Describe a situation where it would be better to use the symbolic method instead of the Octal method for changing file permissions?
When scripting, if you were changing the permissions on all files in the directory and did not want to disturb permissions already set on
certain files.
- List two commands that will remove a directory. rmdir Name , rm -fr
- What distinguishes an absolute path from are relative path? An absolute pathname is the full name of the directory or file. An absolute pathname begins with the root directory (/) . The
relative pathname is made relative to the directory you are currently in. You can distinguish between absolute pathname and a relative pathname by looking for the (/).
- List the advantages of using link files (both hard and symbolic) links allow access to data located in different places on the file system without having to type long path names, Linked files
allow one or more references to be made to a file, Linked files do not take additional disk space, Linked files provide a means of accessing the latest information without having to making new
copies of a file, symbolic link files allow linking across file systems, symbolic link files allow linking two entire directory structure. Remember, if the destination file of a symbolic link file is removed
then there is no file to reference.
[ top ]
[Unit 04] The UNIX Editor
- Unit 4 Objectives: Using the vi editor. Navigate through a file with
cursor movement keys, enter text into a file, use editor commands to change, paragraphs, and insert words, characters, sentences, and paragraphs. Move and rearrange text within a file, Perform line and global
substitutions, use special vi commands for enhanced editing.
- Visual editor = vi, is a mode driven editor (command, edit)
[ top ]
[Unit 05] The UNIX Shell
- Unit 5 Objectives: Define the purpose and functions of the shell, use shell filename expansion
metacharacters, use the shell quoting mechanisms, redirect input and output, use the pipe mechanism, execute jobs in the foreground and background, use shell job control mechanisms, use shell command line
editing features.
- Shell functions:
- Command line interpretation; the Shell reads lines from the keyboard, parses and interprets
them, and passes the information to the operating system for command execution.
- Establishes user environment; when a user logs-on, the shell establishes a personal working
environment based on various parameters the user has specified. These parameters are contained in a user file and can be customized on an individual or system wide bases.
- Filename generation; the shell can except certain beta characters which it expands into
filenames. For example, the "*" means match everything. This assist the user by reducing typing errors and allowing selection of certain files.
- Input/output redirection; the shell allows users to redirect data to and from files in lieu of the
terminal.
- Pipeline connections; the output of one program can be sent directly to the input of another
program through the pipe mechanism. This reduces the need for intermediate and temporary files.
- Job control; commands can be executed in the foreground or background mode. Executing
commands in the background allows us to continue working while the command is running.
- Programming language; the shell is an interpretive
programming language. We can build simple to complex shell programs for use in normal operations and prototype C program.
[ top ]
[Unit 06] UNIX Utilities
- Unit 6 Objectives
- Use regular expression search characters
- Use regular expression replacement characters
- Use UNIX utilities to: view selected portions of files, select specific information from files, find files based on selected file
attributes, determined the type of information stored in a file, differentiate and compare files.
- Regular Expressions: A Pattern consisted of standard and special characters which are used by
numerous programs on UNIX to search for text. The regular expression pattern matching mechanism is a language in itself. Regular expressions are used by vi editor, grep, pg,…
- The "&" is used in a replacement string, it means to repeat the search during execution. Therefore, it
must be "escaped" when you want to use it as a literal into replacement string.
[ top ]
|