Laboratory Manual@Os

download Laboratory Manual@Os

of 13

Transcript of Laboratory Manual@Os

  • 8/4/2019 Laboratory Manual@Os

    1/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 1 -

    LABORATORY MANUAL

    CS-591 Operating system Lab

    SESSION 2010-2011

    B.P. Poddar Institute of Management & Technology

  • 8/4/2019 Laboratory Manual@Os

    2/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 2 -

    LEARNING OVERVIEW

    Importance of the Subject

    An operating system is an essential part of a computer system. This field is

    undergoing change at a breathtakingly rapid rate, as computers are now prevalentvirtually in every application, from games of children through the most sophisticatedplanning tools for governments and multinational firms. Yet the fundamentalconcepts remain fairly clear.

    Even though Technology changes fast - sometimes, every month certainapproaches to technology retain a sort of permanence. UNIX is one of them; it hassurvived the test of time. It is no wonder that theoretical courses on operatingsystems often use UNIX system to illustrate key features.

    The subject operating system intends to teach the students design and datastructures used to develop an operating system. The students will also learn thevarious services of an operating system, organized in various layers to performdifferent functions. These basic concepts can be used for a proper understanding ofsingle user and multi-user operating systems.

    The students will also familiarize themselves with case study on UNIX O.S., itsdesign architecture, command structures, utilities and UNIX shell programmingfeatures. The manual consist of two parts: The fundamental aspects of the systemhave been treated in Part 1 covering the first seven experiments of these, first threeexperiments are based on basic commands for the system, fourth and fifth

    experiments are related with files and directory commands. Sixth experiment isbased on communication facility available with UNIX system whereas seventhexperiment gives the information about standard I/O and pipes. The advancedaspects of the system have been treated in Part 2 covering the remainingexperiments. It covers vieditor, shell programming, process related activities andexecution of C programs under the Unix environment.

  • 8/4/2019 Laboratory Manual@Os

    3/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 3 -

    Aim of Laboratory:

    To help students to understand important concepts and algorithms in operatingsystems. Major components discussed are process management, virtual memory,I/O and file systems. By the end of this course students will have a thoroughunderstanding of the issues that affect the behaviour and performance of computeroperating systems.

    Objectives of Laboratory:

    In this lab student concentrate on Window operating system, Linux operating system.Lab intended to introduce practical study of operating system .In this lab studentmust know the fundamental that are applicable window operating system and Linux

    operating system .Lab experiments also focused on Linux command and alsopractice shell programming.

    Learning Outcomes

    Upon completion of this course, the students should be able:

    To understand the key concepts of modern operating systems.

    To understand the trade off of different algorithms in operating system design.

    To apply the knowledge to system performance tuning and system administration.

    To appreciate the wide spectrum of operating systems in different platforms.

    Software and Hardware Environment

    Software:>Window XP Operating system>Linux Operating system.>C- compiler.

    Hardware:

    >Processor P-IV (1.8 GHz)>RAM 256 MB>Hard disk 40 GB

  • 8/4/2019 Laboratory Manual@Os

    4/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 4 -

    GRAPHICAL STRUCTURE OF SUBJECT

    AREA Third year- IT

    OPERATING SYSTEMS

  • 8/4/2019 Laboratory Manual@Os

    5/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 5 -

    INSTRUCTION FOR THE STUDENTSStudents shall read the points given below for understanding the theoretical

    concepts & practical applications.

    1) Listen carefully to the lecture given by teacher about importance of subject,

    curriculum philosophy, graphical structure, and skills to be developed,information about equipment, instruments, procedure, method of continuous

    assessment, tentative plan of work in laboratory and total amount of work to

    be done in a semester.

    2) Read the write up of each experiment to be performed, a day in advance.

    3) Organize the work in the group and make a record of all observations.

    4) Understand the purpose of experiment and its practical implications.

    5) Write the answers of the questions allotted by the teacher during practical

    hours if possible or afterwards, but immediately.

    6) Student should not hesitate to ask any difficulty faced during conduct ofpractical / exercise.

    7) The student shall study all the questions given in the laboratory manual and

    practice to write the answers to these questions

    8) Student shall develop maintenance skills as expected by the industries.

    9) Student should develop the habit of pocket discussion / group discussionrelated to the experiments / exercises so that exchanges of knowledge / skills

    could take place.

    10) Student shall attempt to develop related hands-on-skills and gain confidence.

    11) Student shall focus on development of skills rather than theoretical or codifiedknowledge.

    12) Student shall insist for the completion of recommended Laboratory Work,

    answers to the given questions, etc.

    13) Student shall develop the habit of evolving more ideas, innovations, skills etc.

    than included in the scope of the manual.

    14) Student should develop the habit of not to depend totally on teachers but to

    develop self learning techniques.

    15) Student should develop the habit to react with the teacher without hesitation

    with respect to the academics involved.

    16) Student should develop habit to submit the practical exercise continuously

    and progressively on the scheduled dates and should get the assessment

    done.

    17) Student should be well prepared while submitting the write up of the exercise.

    This will develop the continuity of the studies and he will not be over loadedat the end of the term.

  • 8/4/2019 Laboratory Manual@Os

    6/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 6 -

    University Syllabus:

    1. Shell programming [6P]: creating a script, making a script executable, shell syntax(variables, conditions, control structures, functions, and commands).

    2. Process [6P]: starting new process, replacing a process image, duplicating aprocess image, waiting for a process, zombie process.

    3. Signal [9P]: signal handling, sending signals, signal interface, signal sets.

    4. Semaphore [6P]: programming with semaphores (use functions semctl, semget,semop, set_semvalue, del_semvalue, semaphore_p, semaphore_v).

    5. POSIX Threads [9P]: programming with pthread functions(viz. pthread_create,pthread_join, pthread_exit, pthread_attr_init, pthread_cancel)

    6. Inter-process communication [9P]: pipes(use functions pipe, popen, pclose),named pipes(FIFOs, accessing FIFO)

    Books/Reference:

    1. Your UNIX: The Ultimate Guide, Sumitabha Das2. www.wikipidea.org3. www.linux.org

  • 8/4/2019 Laboratory Manual@Os

    7/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 7 -

    List of Experiments & Record of Progressive Assessment

    Exp.

    No. Name of the ExperimentsPage

    No.Date of

    Perfor-

    mance

    Date of

    submi -

    ssion

    Assess-

    ment

    Max.

    Marks 15

    Sign. of

    teacher&

    Remarks

    1 Introduction to Laboratory workandUnix System 1

    2 Use of Basic Unix Commands 6

    3 Use of general purpose utilities 14

    4 File access Permissions 20

    5 File processing commands 25

    6 Study ofcommunication commands 35

    7 Standard I/O and Pipes 40

    8 Study of vi Editor 45

    9 Shell programmingI 54

    10 Shell programmingII 63

    11 To execute process related commands 69

    12 System Administration commandsto manage users and groups 74

    13 Develop and execute Cprogramsunder Unixplatform 79

    Total

    Marks

    Average

    Marks

    out of

    15*

  • 8/4/2019 Laboratory Manual@Os

    8/13

  • 8/4/2019 Laboratory Manual@Os

    9/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 9 -

    chown [OPTION] --reference=RFILE FILE

    Options

    Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference,

    change the owner and group of each FILE to those of RFILE.

    -c, changes like verbose but report only when a change is made

    -dereference affect the referent of each symbolic link, rather than the symbolic link itself

    -h, no-dereference affect each symbolic link instead of any referenced file (useful only on

    systems that can change the ownership of a symlink)

    -from=CURRENT_OWNER:CURRENT_GROUP

    change the owner and/or group of each file only if its current owner and/or group match

    those specified here. Either may be omitted, in which case a match is not required for the

    omitted attribute.

    -no-preserve-root do not treat `/' specially (the default)

    -preserve-root fail to operate recursively on `/'

    -f, -silent, -quiet suppress most error messages

    -reference=RFILE use RFILE's owner and group rather than the specifying

    OWNER:GROUP values

    -R, -recursive operate on files and directories recursively-v, -verbose output a diagnostic for every file processed

    The following options modify how a hierarchy is traversed when the -R option is also

    specified. If more than one is specified, only the final one takes effect.

    -H if a command line argument is a symbolic link to a directory, traverse it

    -L traverse every symbolic link to a directory encountered

    -P do not traverse any symbolic links (default)

    chmod - change file access permissions

    Usage

    chmod [-r] permissions filenames

    r Change the permission on files that are in the subdirectories of the directory that you are

    currently in. permission Specifies the rights that are being granted. Below is the different

    rights that you can grant in an alpha numeric format.filenames File or directory that you are

    associating the rights with Permissions

    u - User who owns the file.

    g - Group that owns the file.

  • 8/4/2019 Laboratory Manual@Os

    10/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 10 -

    o - Other.

    a - All.

    r - Read the file.

    w - Write or edit the file.

    x - Execute or run the file as a program.

    Numeric Permissions:

    CHMOD can also to attributed by using Numeric Permissions:

    400 read by owner

    040 read by group

    004 read by anybody (other)

    200 write by owner

    020 write by group

    002 write by anybody

    100 execute by owner

    010 execute by group

    001 execute by anybody

    ls - Short listing of directory contents

    -a list hidden files

    -d list the name of the current directory

    -F show directories with a trailing '/'

    executable files with a trailing '*'

    -g show group ownership of file in long listing

    -i print the inode number of each file

    -l long listing giving details about files and directories

    -R list all subdirectories encountered

    -t sort by time modified instead of name

    cp - Copy files

    cp myfile yourfile

  • 8/4/2019 Laboratory Manual@Os

    11/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 11 -

    Copy the files "myfile" to the file "yourfile" in the current working directory. This command

    will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning

    if it exists.

    cp -i myfile yourfile

    With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten.

    cp -i /data/myfile

    Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt

    before overwriting the file.

    cp -dpr srcdir destdir

    Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-

    poption), file attributes (-p option), and copy recursively (-r option). With these options, a

    directory and all it contents can be copied to another dir

    ln - Creates a symbolic link to a file.

    ln -s test symlink

    Creates a symbolic link named symlink that points to the file test Typing "ls -i test symlink"

    will show the two files are different with different inodes. Typing "ls -l test symlink" will

    show that symlink points to the file test.

    locate- A fast database driven file locator.

    slocate -u

    This command builds the slocate database. It will take several minutes to complete this

    command.This command must be used before searching for files, however cron runs this

    command periodically on most systems.locate whereis Lists all files whose names contain

    the string "whereis". directory.

    more - Allows file contents or piped output to be sent to the screen one page at a time

    less - Opposite of the more command

    cat- Sends file contents to standard output. This is a way to list the contents of short files to

    the screen. It works well with piping.

    whereis - Report all known instances of a command

    wc - Print byte, word, and line counts

    bg

    bg jobs Places the current job (or, by using the alternative form, the specified jobs) in the

    background, suspending its execution so that a new user prompt appears immediately. Use

    the jobs command to discover the identities of background jobs.

    cal month year- Prints a calendar for the specified month of the specified year.

  • 8/4/2019 Laboratory Manual@Os

    12/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 12 -

    cat files- Prints the contents of the specified files.

    clear - Clears the terminal screen.

    cmp file1 file2 - Compares two files, reporting all discrepancies. Similar to the diff

    command, though the output format differs.

    diff file1 file2- Compares two files, reporting all discrepancies. Similar to the cmp

    command, though the output format differs.

    dmesg - Prints the messages resulting from the most recent system boot.

    fg

    fg jobs - Brings the current job (or the specified jobs) to the foreground.

    file files - Determines and prints a description of the type of each specified file.

    find path -name pattern -print

    Searches the specified path for files with names matching the specified pattern (usually

    enclosed in single quotes) and prints their names. The find command has many other

    arguments and functions; see the online documentation.

    finger users - Prints descriptions of the specified users.

    free - Displays the amount of used and free system memory.

    ftp hostname

    Opens an FTP connection to the specified host, allowing files to be transferred. The FTPprogram provides subcommands for accomplishing file transfers; see the online

    documentation.

    head files - Prints the first several lines of each specified file.

    ispell files - Checks the spelling of the contents of the specified files.

    kill process_ids

    kill - signal process_ids

    kill -l

    Kills the specified processes, sends the specified processes the specified signal (given as a

    number or name), or prints a list of available signals.

    killall program

    killall - signal program

    Kills all processes that are instances of the specified program or sends the specified signal to

    all processes that are instances of the specified program.

    mail - Launches a simple mail client that permits sending and receiving email messages.

  • 8/4/2019 Laboratory Manual@Os

    13/13

    DEPERTMENT OF INFORMATION TECHNOLOGY

    B.P.P.I.M.T

    - 13 -

    man title

    man section title - Prints the specified man page.

    ping host- Sends an echo request via TCP/IP to the specified host. A response confirms that

    the host is operational.

    reboot- Reboots the system (requires root privileges).

    shutdown minutes

    shutdown -r minutes

    Shuts down the system after the specified number of minutes elapses (requires root

    privileges). The -r option causes the system to be rebooted once it has shut down.

    sleep time - Causes the command interpreter to pause for the specified number of seconds.

    sort files - Sorts the specified files. The command has many useful arguments; see the onlinedocumentation.

    split file - Splits a file into several smaller files. The command has many arguments; see the

    online documentation

    sync - Completes all pending input/output operations (requires root privileges).

    telnet host- Opens a login session on the specified host.

    top - Prints a display of system processes that's continually updated until the user presses the

    q key.traceroute host- Uses echo requests to determine and print a network path to the host.

    uptime - Prints the system uptime.

    w - Prints the current system users.

    wall - Prints a message to each user except those who've disabled message reception. Type

    Ctrl-D to end the message.