Survey of Operating Systems: Overview (2022)

Survey of Operating Systems:
§ 3: Basic UNIX Commands

Instructor: M.S. Schmalz

This section reviews UNIX file, directory, and systemcommands, and is organized as follows:

    3.1. The UNIX Command Line Interface
    3.2. Overview of UNIX File System
    3.3. UNIX Documentation via man command
    3.4. File Commands
    3.5. Directory Commands
    3.6. Basic System Commands

Information in this section was compiled from avariety of text- and Web-based sources, and is not to be used for anycommercial purpose.

Reading Assignments and Exercises

UNIX implementations employ a shell thataccepts user commands and invokes the appropriate OS processes. TheseOS routines can act on files, some of which can be executable, othersof which are data or documentation files. Additionally, UNIX providesthe man utility to help users view documentation about agiven command or group of commands. UNIX file, directory, and basicsystem commands enable one to (a) navigate through a UNIX-basedcomputer system and (b) locate, retrieve, modify, or store informationorganized in files or hierarchical structures called directories.

3.1. The UNIX Command Line Interface

Reading Assignments and Exercises

UNIX users run one of a collection ofprograms, the most frequently used of which is called a "shell".Numerous shells have been developed over the years (e.g., Korn shell,C shell, etc.) The shell you will use is the C-shell, whose syntax issimilar to the "C" language. In point of information, the name of theC-shell program is "csh", which is the command you will invoke to runit.

When you run the C-shell, you will see a prompt onthe screen. The prompt can be the name of your computer followed by aspecial character, like "%" or ">". The whole prompt might look likethis:

    Example of UNIX Prompt: hausdorff% ,

which would mean that (a) you are using a computer called"hausdorff", and (b) the shell is waiting for your keyboard input(signified by "%"). Since prompt formats vary widely, your shell'sprompt might be different from the example shown above.

Convention. Throughout these course notes, thesymbol "%" indicates the end of the prompt, the symbol after which youtype a command or statement into the C-shell.

At the prompt, if you type the name of a program tobe run followed by the Enter key, then the shell will run theprogram. When the program is done, you are sent back to theshell. Many programs that the shell runs are similar to traditionaloperating system commands (e.g., the directory listing commandDIR in MS-DOS). To get a directory listing in UNIX, type"ls" and press to list the contents of your directory.

Example. If you want to invoke a UNIX directory listing,the system prompt and the string you type (emboldened) would appear asfollows:

% ls

Many UNIX programs or commands have optionsthat change the command's functionality. In the UNIX command line,options are usually preceded by a dash.

Example. Detailed information about filesin the current directory can be obtained by typing ls -l,i.e.,

Detailed File Information: % ls-l

Here, the "-" precedes an option ("l", which standsfor long).

Screen output from the ls -l commandshould look similar to the following. In an actual UNIX session, auser's login-name would be substituted for "bsimpson":

 total 6 -rw-r--r-- 1 bsimpson 123 Jun 23 1998 -i drwxr-S--- 2 bsimpson 512 Apr 7 12:31 Articles/ drwxr-s--- 1 bsimpson 512 May 2 14:01 News/ drwxr-s--- 4 bsimpson 1024 Apr 11 14:17 programs/ -rw------- 1 bsimpson 1891 May 4 11:56 dead.letter -rw------- 1 bsimpson 25247 May 4 11:33 mbox

In Section 3.3, we will describe in detail themeaning of the preceding display, as well as the function of UNIX filecommands. Now that you know what the command line is and how to useit, we will digress briefly to discuss the UNIX file system.

3.2. Overview of UNIX File System

Reading Assignments and Exercises

When a disk is formatted, the physical disk isdivided into a number of partitions, which are abstractions, each ofwhich has an associated file system. The file system consists ofhierarchically-arranged subdirectories and files that can beconveniently represented by an abstraction called a directorytree. A directory tree that might be found in a UNIX file systemis exemplified in Figure 3.2.1.

Survey of Operating Systems: Overview (1)
Figure3.2.1. Tree representation of an example UNIX file system.

3.2.1. UNIX System Directories

Several standard directories typically appear in a UNIX filesystem,as follows:

dev directory contains specialdevice files that are used to drive hardware objects such as CD-ROM,floppy disk, etc. These files will be discussed in a later portion ofthe course, if time permits.

etc directory files are requiredfor operation of the specific machine or system that you are using(also called machine-dependent or system-dependent files

home directory houses acollection of user directories on a given system. This is where yourpersonal files would be kept if you had an account on a UNIX systemsuch as grove.

opt directory typically containsapplication-specific subdirectories and files (e.g., programs such asFrameMaker or a public domain package such as the image editorxv or graphing package xvgr).

usr directory contains files thatcan be shared by all users (recall data and program sharing introducedin the MULTICS operating system)

var directory is comprised offiles whose size varies with time, such as incoming mail and spoolerfiles (e.g., print spool files for printout).

3.2.2. UNIX File Description

A Unix file is specified by a parameter block called ani-node. An i-node exists on disk for every file that ison that disk, and there exists a copy of the i-node in kernel memoryfor every open file. All of the information that UNIX knows about afile, except the file name, is stored in the i-node, which includes:

File access and file type, known as the mode.

File ownership information, which is importantfor security

Time stamps that record date and time of lastmodification, last access, and last modification of mode

Link count and File size in bytes,which pertain to the amount of information in a file

Addresses of physical blocks - these tell UNIXwhere to find the data for the file whose i-node is currently beingexamined

There exist 13 physical block addresses in an i-node.Each of these addresses is 3 bytes long, and the addresses point tothe following information:

Addresses 1-10: The first ten block addressesrefer to data blocks

Address 11 refers to a first-level index blockthat holds the addresses of further data blocks

Address 12 points to a second-level indexblock that holds the addresses of further index blocks

Address 13 refers to a third level index block(which holds the addresses of further second level index blocks, toallow for file expansion beyond the second level).

All physical addresses associated with a file areimplicitly assumed to reside on the same disk, since standard UNIXprovides no facility for a file to span more than one disk. There isno requirement that the physical addresses of a file should becontiguous (i.e., in adjacent sectors on the disk). Since UNIXis able to handle multiple files on one disk, it is unlikely thatcontiguity would offer any performance advanatages. UNIX also has norequirement that all logical blocks (file address specifications)should map to physical blocks (pieces of data on the disk). Instead,files can have "holes", which often happens with large, sparselypopulated, direct-access files.

Now, let us discuss UNIX file size. For purposes ofdiscussion, assume 512 byte blocks and 3 bytes per address, which isequivalent to a disk capacity of about 8 GByte. An index block of 512bytes is capable of holding 170 3 byte addresses. Given thisinformation, the largest file size in UNIX can be calculated asfollows:

  1. Directly addressed blocks 10 × 512 byte =5,120 bytes

  2. Blocks addressed via first level index block170 × 512 byte = 87,040 bytes

  3. There will be 170 index blocks addressed viathe second level index block. This will address 170 &times 170 &times 512bytes = 14,796,800 bytes

  4. Via the third level index block there will be170 × 170 × 170 × 512 bytes of addressable data,which yields 2,515,456,000 bytes.

Therefore, the total addressable space per file is2,530,344,960 bytes (approximately 2.5 Gbytes). Note that BSD andother more recent versions of Unix use a larger disk i-node formatthat consists of 32 4 byte words. The block addresses now occupy 4bytes rather than 3 and various other fields are larger. This trendis expected to be carried forth into future versions of UNIXimplemented on progressively larger disk storage systems.

In particular, the BSD extensions include space for32-bit user and group ids and an i-node generation number.This number, incremented when a free i-node is used for a differentfile, is employed by the network file system for file handlecalculation. Additionally, in the BSD extension, all time fields haveexpanded to 64 bits so that the year 2038 (some say Y2.038K) problem(when the Unix standard &time variable maxes out, then wraps) can beavoided.

Once a file has been opened, the version of thei-node resident in memory contains the following information:

In-memory i-node status that indicateswhether or not

    a) the i-node is locked

    b) a process is waiting for the i-node to be unlocked

    c) the memory-resident i-node is dirty, i.e. differs from the version stored on disk

    d) file modifications have been made that were not written to disk


Device number of the disk on which the file isresident

I-node number, occasionally called thei-number - On disk the i-nodes form an array and the i-numberis inferred from the i-node's position in this array.

Pointers to other memory-resident i-nodes

Reference count that indicates the number ofinstances the file is (or, in some UNIX implementations, has been)active or open.

3.2.3. UNIX Directories

Note that the file name and the i-number whichuniquely identifies the i-node is stored in a directory entry,which in UNIX is implemented as a file. When discriminating betweendirectories and files, the UNIX kernel will not allow a directory tobe opened for writing using normal file system calls, to preserve filesystem integrity. Otherwise, a user could change i-node informationat will, with disastrous results to his or her file system.

Previous versions of Unix (System 5 and earlier) useda directory format comprised of a sequence of 16 byte records. Inparticular, the first 2 bytes held the i-number and the remaining 14bytes held the file name. Hence, there was a limit of 14 characters onthe maximum size of a file name. When a file was deleted, thei-number of the associated directory record was set to zero to markthe record as having been freed up for future use. However, thefilename was not set to null.

More recent versions of Unix have adopted the moreflexible structure for directory entries shown in the followingfigure.

Survey of Operating Systems: Overview (2)
Figure 3.2.2. High-level diagram of i-node structure.

When the user invokes the file deletion command, thespace occupied by the file's directory entry is combined with the freespace at the end of the previous directory entry (this is denoted asamalgamated space in Figure 3.2.2). The information blocksize field is then incremented to reflect the amount of spaceallocated. This allows reasonably long file names without requiringlarge directory records. A disadvantage is more complex manipulationof directories, which are read via a special system call(getdent() - get a directory entry).In programming practice, manipulation of directories from withinprograms is handled via library routines, to safeguard filesystemsfrom user-inflicted damage.

3.3. UNIX Documentation via man command

Reading Assignments and Exercises

The majority of operating systems have an on-linehelp facility. UNIX expresses its help information in terms of manpages, which are supposed to resemble pages from a softwaremanual.

In UNIX, the man command displaysinformation from specially-formatted reference manuals. These areuseful, reasonably complete manual pages that the user can select by(a) command name, or (b) one-line summaries selected either by keyword(-k option), or by the name of an associated file(-f option). If no manual page can be found for a givencommand, option, or keyword, then the man program printsan error message.

The man command is invoked using thefollowing syntax:

machine% man {keyword}

For example, on the SunOS system, entering manexit after the command line prompt yields the followinginformation for the exit command:

 Fortran Library Routines EXIT(3F) NAME exit - terminate process with status SYNOPSIS subroutine exit (status) integer*4 status DESCRIPTION exit flushes and closes all the files of the process, and notifies the parent process if it is executing a wait. The low-order 8 bits of status are available to the parent pro- cess. These 8 bits are shifted left 8 bits, and all other bits are zero. Therefore, status should be in the range of 256 - 65280. This call never returns. The C function exit may cause cleanup actions before the final `sys exit'. If you call exit without an argument, you get a warning mes- sage, and a zero is automatically provided as an argument. FILES libF77.a SEE ALSO exit(2), fork(2), fork(3f), wait(2), wait(3f) SunOS 5.6 Last change: 98/09/16 1

This documentation has several categories, as follows:

NAME - Gives the name of the command or programming language keyword, together with a short description of functionality

SYNOPSIS - Expanded description of functionality with respect to the string that follows NAME

DESCRIPTION - Fully describes the command or programming language keyword, including options and functionality in detail, often with examples

FILES - Shows what system files are associated with the command or programming language keyword

SEE ALSO - Provides other commands or programming language keywords that can be used as arguments to related man calls.

Additionally, at the bottom of the man page is a dateof most recent modification and a version number (in the aboveexample, SunOS 5.6) that tells you how recent the help ordocumentation is. The man command further supports the bugscategory, which tells the user or system analyst what known problemsare associated with the command or programming language keyword. In asimple command like exit listed above, there are few if anyknown bugs. However, other commands might have bugs associated withthem, as do public-domain programs that can be run from UNIX.

Additional Exercise: Find four UNIXcommands that have bugs associated with them, where the bug(s) is(are)listed on the man page for the given command.(Hint:Be prepared to answer a question similar to this on a midtermexam.)

3.3.1. Use of keyword (-k) Option

Occasionally, a user might know the documentationthat he or she is looking for in a general sense (e.g., by topic), butnot by exact command or keyword. UNIX man utilities provide asemantic keyword cross-reference capability that facilitates a limitedtype of content-directed search. For example, to find man pageinformation about a loader program, we first need to know whatcommands or keywords are associated with the keyword loader.Thus, we type:

machine% man -k loader

which usually produces the following display on a Sunworkstation running SunOS or Solaris:

 AutoLoader AutoLoader (3) - load subroutines only on demand DynaLoader DynaLoader (3) - Dynamically load C libraries into Perl code .PP dl_error(), dl_findfile(), dl_expandspec(), dl_load_file(), dl_find_symbol(), dl_find_symbol_anywhere(), dl_undef_symbols(), dl_install_xsub(), dl_load_flags(), bootstrap() \- routines used by DynaLoader modules ExtUtils ExtUtils (3) - make a bootstrap file for use by DynaLoader SelfLoader SelfLoader (3) - load functions only on demand download download (1) - host resident PostScript font downloader download download (1) - host resident PostScript font downloader

What the previous command did was to search the mandatabase for commands whose descriptive string or SEE ALSOcategory contained the string loader. The terms that werereturned, which could be used as arguments to the mancommand, include DynaLoader, ExtUtils,SelfLoader, and download. Note that manpages are sometimes repeated in the output of the man -kcommand, and occasionally there is much superfluous information.

3.3.2. The man filename (-f) Option

When one specifies man -f {file...}, where{file...} denotes a list of one or more filenames, man attemptsto locate manual pages related to any of the given files. It stripsthe leading path name components from each file, and then printsone-line summaries containing the resulting base- name or names. Thisoption also uses the windex database.

Additional Exercise: Read about the windex databaseroutines (in the C language) by typing man windex.Use the man -k windex command to find out moreabout windex.

3.4. File Commands

Reading Assignments and Exercises

The UNIX file system supports viewing of directoriesand file contents, moving and copying of files, renaming files andsetting permissions, and other similar tasks. These operations arestandard on modern computer file systems.

3.4.1. Viewing Directory File Information

Recall the example output of the ls -lcommand given in Section 3.1:

    total 6-rw-r--r-- 1 bsimpson 123 Jun 23 1991 -idrwxr-S--- 2 bsimpson 512 Apr 7 12:31 Articles/drwxr-s--- 1 bsimpson 512 May 2 14:01 News/drwxr-s--- 4 bsimpson 1024 Apr 11 14:17 programs/-rw------- 1 bsimpson 1891 May 4 11:56 dead.letter-rw------- 1 bsimpson 25247 May 4 11:33 mbox

    The first column (e.g. -rw-r--r--), pertainsto file permissions, namely, who has access to your files and whatthey can do with them (r = "read", w = "write", etc.).

    The name (bsimpson) is the login-i.d. of theperson who owns the files (should be you). The number after that ishow many bytes the file uses, followed by the creation date/time andfinally the file name. (Some systems have different formats forls output, so check with your consultant or systemadministrator if you have questions.)

    Example. In the preceding directory listing,file mbox is readable and writeable by bsimpson,occupies 25,247 bytes on disk, and was created May 4 of the currentyear at 11:33am.

    Another option for the ls command is-a, where a denotes all. Certain files inyour directory are usally invisible to the ls or ls-l command. (A file is invisible if its name begins with ".")These hidden files are usually system-oriented files that aretransparent to a user's day-to-day operations. If you had to look atthese every day, they would probably clutter up your directorylisting. By typing

      % ls -a

    you can obtain a listing of all your regular files,plus several files beginning with ".", for example, ., ..,.cshrc, .login, .newsrc andseveral others.

    One can usually combine options on thels command. For example, to detailed information on allof your files can be produced by typing ls -a -l orls -l -a.

    Efficient Usage Tip. With some commands (likels) you can put several options after just one dash, for example,

    ls -al or ls -la.

    3.4.2. Moving Files

    The command mv, which means move,allows a user to move or rename files. For safety, mvshould be used with the -i option, which asks you if youreally want to overwrite a file. You are also prompted if you try torename a file to a name that exists in the current directory. Newusers have the -i option set by default. The followingdiscussion explains two different forms of mv that youcan use.

  • mv file1 file2

    This form of mv changes the name of afile (from file1 to file2). This command also appliesto directories. For example, to rename a directory, use the directoryname instead of one or more filenames.

  • mv file1 ... fileN directory

    This form ofthe mv command will move one or more files (separated byspaces) into the designated directory, which is the last argument onthe command line. Note that file1 ... fileN can be eitherfile or directory names.

      Example. Given the following UNIX session:
      % ls

      a.out* cop3610/ emg3312/ private/ typescript

      % mv a.out typescript

      remove typescript? n

      % ls

      a.out* cop3610/ emg3312/ private/ typescript

      % mv a.out bogus

      % ls

      bogus* cop3610/ emg3312/ private/ typescript

      (Video) [ Lecture No 16 ] [ Survey Of different Operating Systems -Part 1]

      % mv bogus typescript cop3610

      % ls

      cop3610/ emg3312/ private/

      % ls cop3610

      bogus* typescript

    • The first mv attempted to renamea.out to `typescript (a file which alreadyexists). Since the -i option is used by default, thequestion remove typescript? was returned because the file`typescript already exists. By answering y,the target file typescript would have been overwritten bythe file a.out. Answering n simply cancelsthe move process.

      In the second use of mv,a.out was renamed to bogus.

      The third mv command moved thebogus and typescript files into thecop3610 directory.

      3.4.3. Copying Files

      To copy a file, use cp, which meanscopy. The cp command has two formats that areanalogous to the mv command formats. The only differencebetween the these commands is that cp doesn't remove theoriginal file. Thus we say that renaming a file is a destructiveform of copying, because the source file is removed.

      Similar to mv, cp also offers a-i option. New users have this option set by default.Again, note that cp and mv are almostidentical in usage.

      3.4.4. Removing Files

      The command rm means remove andis used to erase files. For safety, this command should almost alwaysbe used with the interactive option -i. Thus, wheneveryou remove a file you will be asked to verify the removal of the file.New users have rm initialized to use the -ioption by default.


        % ls

        a.out* cop3610/ emg3312/ private/ tempfile typescript

        % rm tempfile

        rm: remove tempfile? y

        % ls

        a.out* cop3610/ emg3312/ private/ typescript

        In this example, the file tempfile wasremoved. Note that rm asked if tempfileshould really be removed (the corresponding prompt is emboldened).

        Note: When you remove a file withrm, the file is no longer available from the user'sperspective - you will not be able to get it back unlessyou request a tape backup dump from the systems staff. Most UNIXsystems do not have an undelete command such as that found insome versions of MS-DOS or utility programs such as NortonUtilitiesTM.

        3.4.5. Changing File Permissions

        On a multi-user system, keeping selected files out ofthe reach of prying eyes is important. As a (relatively weak)security measure, the Unix operating system has built-in filepermissions feature.

        By typing ls -l, we have seen that along listing of the files in the current directory can be displayed.An example is displayed below. As noted previously, the letters anddashes on the left side of the listing represent the permissions seton each file or directory.


          % ls -l

          drwxr-xr-x 11 bsimpson 572 Nov 16 05:11 drafts/

          -rw------- 1 bsimpson 1 Dec 10 20:04 termpaper

          The letter in the first column describes the type ofthe file, while the other nine letters describe the file'spermissions, which indicate who can access the file and how it can beaccessed.

          In order to understand the concept of file securityat a basic level, the following permission codes are listed:

            - : permission is not set

            r : read permission is set

            w : write permission is set

            x : execute permission is set

            d : the file represents a directory

          The nine permission characters are partitioned intothree sets of three characters each, where each set of threecharacters contains r, w and xcodes. The three partitions comprise an access control list,and are described as follows:

          user - Permissions in the firstleft-hand group of three characters control the user's access to thefile. If the current user is not the owner of the file, then the usermight not be able to access that file, depending on how thepermissions are set. To find the owner of a file, use ls-l, and look at the username (e.g., bsimpson inthe preceding example).

          group - A collection of users can beformally aggregated in a group, which is a list of permissibleusernames. For example, a group cop3610 could contain theusernames of all students enrolled for this course in a givensemester. User permissions thus control the access that people in thegroup(s) assigned to the file have. You can use the command ls-lg to list all groups associated with each file.

          other - Users in the otherpartition comprise all users not in the user orgroup partitions. The other permissions controlaccess that users in the rest of the world (who can login to yoursystem) have to each file.


          -rw------- 1 instr cop3610 7830 Nov 19 15:06 hw2

          Only the owner (instr) of the file hw2 has permission to read and write to the file.

          -rw-r----- 1 instr cop3610 17820 Nov 19 15:06 hw1

          This is a file that is readable by both the owner (instr) and by users that are in the cop3610 group. However, only the owner has write permission to the file (rw code in the left-hand group of three characters).

          drwxr-xr-x 6 instr staff 512 Apr 19 22:27 /home/instr/410/

          This is a directory (as shown by the left-hand d) that is readable and executable by everyone, but can be written to only by the owner (instr). The groups field contains staff, which is usually a group of privileged users.

          -rw-rw-rw- 1 instr cop3610 783 Sep 18 15:06 temp

          This file (temp) is readable and writable by all users.

          When a file or directory is created, UNIX setsdefault file permissions according to the umaskdescriptor in your .cshrc file. To change thepermissions on a file, the chmod command is used, whichhas the following form:

            chmod mode file(s) 

            where mode specifies the change of permissions on thespecified file(s). The mode is specified as follows:

            Step 1. Choose one or more permission partitions by specifying u (user),g (group), o (other), ora (all).

            Step 2. Type + (add permission)or - (delete permission).

            Step 3.Specify the permissions to be changedusing r (read), w (write), or x(execute).

            Here follow three examples of chmod usage.
              Example 1.
              % ls -l

              drwxr-xr-x 11 bsimpson 572 Nov 16 05:11 drafts/-rw------- 1 bsimpson 5666 Dec 10 20:04 termpaper

              % chmod go+r termpaper

              (Video) Survey of PC & Network Operating Systems_Lecture 01 | Introduction to Computers| COMP-111

                This use of chmod gave read access forgroup and others to the file termpaper,as shown below:
                % ls -l

                drwxr-xr-x 11 bsimpson 572 Nov 16 05:11 drafts/-rw-r--r-- 1 bsimpson 5666 Dec 10 20:04 termpaper

                  Example 2. Assume the file status shown at the end of theprevious example.
                  % chmod o-rx drafts

                  % ls -l

                  drwxr-x--- 11 bsimpson 572 Nov 16 05:11 drafts/-rw-r--r-- 1 bsimpson 5666 Dec 10 20:04 termpaper

                    This example removed read and execute access forothers from the drafts directory.
                    Example 3. Assume the file status shown at the end of the previous example.
                    % chmod go-rwx termpaper

                    % ls -l

                    drwxr-x--- 11 bsimpson 572 Nov 16 05:11 drafts/-rw------- 1 bsimpson 5666 Dec 10 20:04 termpaper

                    In this example, the chmod command is directedto remove all permissions for group and others fromtermpaper.

                    Note: To make a directory accessible toeveryone, one must specify group and others read andexecute permissions for the entire directory. For example:

                    chmod go+rx directory


                    3.4.6. Viewing File Contents

                    We begin with the cat command, thenprogress to the more command.

                    The command cat means concatenateand is often used to view short files. Supplying catwith multiple file names, as follows:

                    cat file1 file2 ... fileN

                    will display each file sequentially in a continuousstream of text. This is why the command is called concatenate.If a file is large and you want to use cat to view it,you will have to have quick reflexes, and use {Ctrl}-sand {Ctrl}-q to stop and restart scrolling of text so youcan get a chance to view it. On modern computers, scrolling isusually so fast that you will likely lose the text you are trying tosee. Thus, we recommend the use of commands such as moreor less to view your files.

                    The commands more and lessare commonly used to view files one screen at a time. When you useeither of these commands, you will have an information bar at thebottom of the screen. For example, you can press the{spacebar} to go to the next screen, b to goback a page, or the {Return} to scroll the file forward aline at a time. When you finally get to the end of the file,more will return a Unix prompt, while lesswill wait for you to press q to quit. The following listof options will work for both more andlesscommands, unless otherwise indicated.

                    {spacebar} - Takes you to the next page.

                    b - Takes you to the previous page.

                    {Enter} key - Scrolls forward one line.

                    k - Scrolls backward one line(less only).

                    g - Takes you to the beginning of the file(less only).

                    G - Takes you to the end of the file(less only).

                    h - Shows you a help screen.

                    /pattern - Goes to thenext occurrence of pattern in the file. When you finish typingin the pattern, you must press the {Enter} key. Here,pattern is a regular expression, which we will definelater in this course.

                    n - Search forward for anotheroccurrence of the pattern previously searched for with /.

                    r - Search backwards for aprevious occurrence of the pattern previously searched for with/.

                    q - Quits the moreor less program.

                    Either program works, but less is muchmore flexible. Backward scrolling is just just one of many featuresthat less has, which more does not. Wesuggest using less if you want full-featured filedisplay.

                    3.4.7. Wildcard Usage

                    In certain cases, UNIX supports application of acommand to multiple files. The command length and complexity can bereduced via wildcard characters for efficient matching offilenames. Wildcard characters are:

                    1. ? -- matches any one character.
                    2. * -- matches any contiguous group(string) of zero or more characters.

                    To better understand the use of wildcards, let usconsider the following examples.

                    Example. Let a directory contain the filesfile, file2, file3,fun, fun2, mbox, andreadme. Here follows a terminal interactive session,where brackets ([ ]) contain explanations that do not appearon the computer monitor:

                      % ls * [ * matches all filenames]file file2 file3 fun fun2 mbox readme

                      % ls f* [ f* matches all filenames beginning with f]file file2 file3 fun fun2

                      % ls file? [ file? matches all filenames of length 5 beginning with file]file2 file3

                      % ls ???? [ ???? matches all filenames of length 4]file mbox

                      The first example shows ls with*, which matches all files in the directory (since allfilenames have 0 or more characters).

                      In the second example, f* matches all the filesbeginning with an f, which are listed.

                      The third example uses file? to matchall filenames that begin with the word file and have onecharacter following that word.

                      In the fourth example, four ? charactersin a row match all filenames that are four and only four characterslong.

                      Wildcards should be used with caution. For example,when used with a destructive command like rm, thewildcard "*" could help you remove all the files in your directory!

                      3.5. Directory Commands

                      Reading Assignments and Exercises

                      Having covered file commands, we now turn to commandsrelated to directories, which are collections of files and otherdirectories.

                      3.5.1. Discovering your Location

                      It is often difficult to remember where you arewithin a given file system, due to the tree structure that usually hasmany levels. To make the location of the current directory clear toyou, UNIX provides the pwd command, which meanspresent working directory.

                      Example. Using the previous login i.d. ofbsimpson, typing the command pwd inB. Simpson's home directory would yield the following interactivesession:

                        % pwd


                        This also holds for any location that you are at inthe file system.

                        3.5.2. Changing the Directory

                        To reset the current directory, which is like movingfrom one directory to another directory, UNIX provides thecd command, which means change directory.Whenever you need to move to your home directory, just typecd with no arguments. If you specify a directory name asan argument, cd will attempt to located that directory,then set it as the current directory if it is a valid directory in theUNIX filesystem.

                        Example. Suppose you want to view files inbsimpson's `cop3610' directory. Then, you wouldtype:

                          % cd ~bsimpson/cop3610% pwd


                          %ls -l

                          and the filenames would be displayed.

                          Important Note: the tilde preceding bsimpson isexpanded by the Unix C-shell into the full pathname of that person'shome directory, so you do not have to enter a potentially longpathname.

                          Suppose B. Simpson has an assign1directory under cop3610. To move there, type

                            % cd assign1% pwd


                            If you use `..' as the argument,cd will bring you up a level in the directorytree.

                            (Video) Survey on PC and NETWORK Operating System

                              Example. Assume the filesystem from the previous example.
                              % cd ..

                              % pwd


                              3.5.3. Viewing Directory Contents

                              We've already overviewed the ls commandfor listing directory contents, together with the "l" and "a" options.Several commonly-used options follow:

                              -a : Lists all the filesin the directory, including hidden files.

                              -F : Appends a single characterto filenames on the display only that aren't text files, todenote file type. For example, directories have a trailing /and executable files have a trailing *. New users have thisoption set by default. Hence, the examples of ls inthese course notes assume that this option is being used.

                              -l : Lists in long format,telling (from left to right) the file's permissions, number of linksto the file, the file's owner, the file's size in bytes, and the timethe file was last modified. Examples were provided previously.

                              -g : In conjunction with the-l option, the -g option of lsincludes the file's group following the owner field for eachfile.

                              -R : Used to generate arecursive listing of all directories encountered below thelevel of the current directory.

                              Note that ls lists the current directoryby default, if you do not specify the name of a file or directory youwish to list. Some interesting results can occur, as shown below.

                              Example. Suppose you are in bsimpson's homedirectory, and you type ls -a. If the directory isnot secured, you might see the following:

                                % ls -a./ .cshrc .login .msgsrc cop3610/ private/../ .emacs .logout a.out* emg3312/ typescript

                                Here, the two files called "." and".." are directory links. In particular,"." is a link to the current directory, and".." is a link to the parent of the currentdirectory. You can backtrack upward through a directory structure byusing "cd .." to pop up one directory level.

                                Additional Exercise. Use manls to learn the options of the ls command.

                                3.5.4. Creating a New Directory

                                Users can create new directories using the mkdircommand. Prior to this, one must determine where the directory is tobe placed. For example, a directory can be located one level belowone's home directory or subdirectory.

                                  Example. Let bsimpson create a directorywithin his emg3312 directory:
                                  % pwd [Locate the parent directory of the new directory]/home/bsimpson/emg3312

                                  % mkdir drafts [Make the new directory]% ls [Check to be sure that the new directory is there]

                                  drafts/ termpaper

                                  Recall that, when you create a directory, its permissions and thedefault permissions of all its children (files and directories) are setaccording to the umask setting. It is always wise to viewpermissions with the ls -l command, then change them with thechmod command.

                                  3.5.5. Removing an Existing Directory

                                  Occasionally, a user may decide he wants to remove a directory.(Sometimes this needs to be done to make room for more files in yourhome directory.) In this case, one uses the rmdircommand, which means remove directory. However, the directoryto be removed must be empty of all files and subdirectories.Otherwise, rmdir will inform you that the directory isnot empty and will not remove it.
                                    Example. Assuming that bsimpson has adrafts directory, let us try to remove that directoryusing rmdir:
                                    % pwd [check the current directory]/home/bsimpson/emg3312

                                    [this is the current directory]% ls [list contents of current directory]drafts/ termpaper

                                    % rmdir drafts [try to remove the drafts directory]rmdir: drafts: Directory not empty [this is an error message from rmdir]

                                    % ls drafts [o.k., let's see what is in "drafts"]monologue notes

                                    [contents of directory "drafts"]% rm drafts/* [try to remove contents of directory "drafts"]rm: remove drafts/monologue? y ["rm" asks do you really want to do this?rm: remove drafts/notes? y ...and you answer "y" for yes]

                                    % ls drafts [check to see if files have been removed] [no listing => directory "drafts" is empty]

                                    % rmdir drafts [now we can remove "drafts"]% ls [so what is left under emg3312?]termpaper [...only the "termpaper" directory remains]

                                    Note that bsimpson first had to remove (or move) the filesfrom the directory drafts before removing the directoryitself. Note also that the files were removedwith rm followed by a wildcard ("*"). Important Note: Upon the removal of a directory,rmdir will not tell you that the directory was removed.Instead, you are supposed to use ls to see that thedirectory is actually gone. This is another little idiosyncracy ofUNIX that users love to hate.

                                    3.5.6. Directory and File Command Summary

                                    Here follows a summary of the UNIX file and directory commandscovered in this section:

                                    (present working directory) Display the full pathname of the current directory.

                                    cd directory

                                    (changedirectory) Changes the current directory. If you specify noarguments, then cd will bring you back to your homedirectory.

                                    ls directory ...

                                    (listdirectory) Lists the contents of a directory or directories. If thedirectory name is unspecified, then ls will list thecontents of the current directory. You can also supply filename(s)instead of a directory name, to get more information about one or morefiles.
                                    mkdir directory ...
                                    (make directory) Create a directory or directories.
                                    rmdir directory ...
                                    (remove directory) Remove an empty directory or directories (the directories must not contain any files).
                                    cat file1...
                                    (concatenate) Used to view a file or filescontinuously on your terminal. If you use cat to view along file, it is necessary to use {Ctrl}-s keys to pausethe screen and {Ctrl}-q keys to unpause. Otherwise, filecontents will be displayed too fast for you to read them. For fileslonger than one screen, it is recommended that you use eithermore or less to view the file.
                                    more file
                                    These two programs display a file one screen ata time, and offer viewing options such as paging backwards through afile and pattern searching. In a typical UNIX idiosyncrasy,less is the more sophisticated of the two and hasfeatures that aren't found in more.
                                    rm file1 ...
                                    (remove) Removes thespecified file(s).
                                    mv file1 file2
                                    mv file1... fileN directory
                                    (move) Moves a file or directory.In the first form, file1 will be moved to (renamed as)file2. The second form will move a number of files into adirectory which you specify as the final argument on the command line.Directory names can be used in place of the filenames in either of theforms, to move or rename directories.
                                    cp file1 file2
                                    cp file1... fileN directory
                                    (copy) Copies files. In the firstform, file1 will be copied to a file called file2. Thesecond form will copy a number of files into a directory which youspecify as the final argument on the command line.
                                    chmod mode file1 ...
                                    (change mode)Changes file permissions. The mode specifies how permissions are to be changed for the listed file(s).
                                    This terminates our overview of UNIX file and directory commands.We next discuss commands that affect the computer system directly.

                                    3.6. Basic System Commands

                                    Reading Assignments and Exercises

                                    When using a computer or networked workstation, it isoccasionally useful to perform system functions such as determiningwho is using the computer, what is the date and time, and so forth.UNIX commands that affect the system without changing files ordirectories are called system commands. Severalfrequently-used system commands are reviewed, as follows.

                                    3.6.1. Changing your Password

                                    UNIX enforces access control to user directories andaccounts in several different ways. One device we have not discussedis the password, which you must enter when you log in to youraccount. To keep you account secure, your password should have thefollowing attributes:

                                    Many characters (at least ten)

                                    Non-alphabetic characters to make the search space larger for a password-based attack on your account. For example, include characters such as "!@#$%^&*()_+|~`\=-" and the digits 0-9.

                                    No common words such as "password" or your first name.

                                    To change your password, use the passwd command.typing passwd at the command prompt, then answering thequestions. On most systems, UNIX will ask you for your new password and ask you to type it in twice to make sure there were no typing errors. It may also ask for your old password for verification.

                                      Example. User bsimpson changes his password (user'sentries are emboldened):
                                    login: bsimpsonpassword: ajfglsh7598&*96fd gator% passwdpasswd: Changing password for bsimpsonEnter login password: ajfglsh7598&*96fd Enter new password: 349dhfc07-2397vkd&$$^#$(jdghEnter new password again for verification: 349dhfc07-2397vkd&$$^#$(jdghPassword changed.

                                    3.6.2. Getting the Date and Time

                                    UNIX has a convenient method for showing you whattime it is. Just type date on the command line, and youwill get a date and 24-hour time display like this:


                                    % dateTue Feb 8 19:36:33 EST 2000

                                    This means that today is Tuesday, 8 February 2000,and the time is 7:36:33 pm Eastern Standard Time.

                                    3.6.3. Discovering other Users

                                    If you are working on a networked computer system,type the users command to get a list of all the usersthat are logged in.


                                    % usershkmung bsimpson tdavids cmellish

                                    This means that users hkmung bsimpson tdavidscmellish are logged into your system.

                                    To learn more about a user by his or herusername, the finger command is available (likefingering through a Rolodex). To find out about user bsimpson,use finger as follows:


                                    % finger bsimpsonLogin name: hyoon In real life: Hankil YoonDirectory: /homes/bsimpson Shell: /local/bin/tcshLogin Name Idle TTY Host When Wherebsimpson Bart Simpson 5 day 0 tern Thu 15:41 New mail since Tue Feb 8 19:31:40 2000.Has not read mail for 2:32:14.Project: CARTOON project (URL: Ph.D. candidate in Arts and Sciences University of Florida, Gainesville email: Home: 973-8 Maguire Village Office: 4523 Weil Hall Gainesville, FL 32603 University of Florida Gainesville, FL 32611 Phone: (H) (352) 899-3749 (O) (352) 392-1924 Fax: (352) 392-1714 URL:

                                    This means that user bsimpson is aPh.D. candidate in Arts and Sciences at UF, has not read his mail fortwo hours, 32 minutes, and 14 seconds, and is trusting enough to posta lot of information about himself in public view.

                                    3.6.4. Finding Out Who is Logged In to a Workstation

                                    Suppose you happen upon a UNIX workstation andsomeone is logged in. Your first inclination might be to ask aroundand see who is using the computer. Or, you can typewhoami at an available prompt to see who the user is.


                                    % whoamihkmung

                                    This means that user hkmung is logged into thesystem. If you want to find out more about this person, typefinger hkmung after the prompt.

                                    3.6.5. Finding out How Much Disk Space is Available

                                    Occasionally you might want to know how much disk space isavailable (or is consumed) by a directory or filesystem. The commandsdf (means disk free) and du (diskusage) will respectively return this information.


                                    % df/var (/dev/dsk/c0t0d0s3 ): 491650 blocks 124392 files/export/blank0 (/dev/dsk/c0t0d0s7 ):15162232 blocks 957692 files/tmp (swap ): 1072656 blocks 20209 files

                                    This display shows the status of three devices:/var, /export/blank0, and /tmp,whose names are listed in the first column. The second column is theUNIX device pathname by which the logical names in the first columnare referenced. The third column shows the number of blocks (1KB perblock) that the disks contain, and the fourth column shows the numberof files.

                                    If you were to attach to my public_htmldirectory, you would find a superset of (more information than) thefollowing example of disk usage.


                                    % du [...some stuff deleted for brevity...]5782 ./MLI492 ./DiscreteMath2 ./SurroundSound178 ./IAF-Test572 ./SeniorProject5280 ./OpSysUNIX47734 .

                                    This display shows the disk space consumption of sixof the the subdirectories in my HTML directory. For example, theMLI directory has 5,782 blocks (approximately 6MB), and thedirectory for this course (OpSysUNIX) has 5,280 blocks. Atotal of 47,734 blocks (approximately 50MB) are in my HTML directoryat the time I executed this du command.

                                    (Video) Survey of PC and Network operating system

                                    Commands such as du and df areuseful for maintaining your directory, i.e., deleting files to makeroom for newer material. Most student accounts have quotas (maximumamount of disk storage you may use) and these commands are appropriateto help you comply with the quota.

                                    This concludes our overview of basic UNIX commands. We nextdiscuss the software development process with a UNIX operating system.



                                    What is the overview of operating system? ›

                                    An Operating System (OS) is an interface between a computer user and computer hardware. An operating system is a software which performs all the basic tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives and printers.

                                    What are the 5 key concepts of an operating system? ›

                                    To understand clearly about an operating system, user need to know the five fundamental concepts of the operating system, which are the five tasks that an operating system can and will do. The five tasks are Main Memory Management, Processor Management, Device Management, File Management, and User Interface.

                                    What are the 3 main objectives of operating system? ›

                                    An operating system has three main functions: (1) manage the computer's resources, such as the central processing unit, memory, disk drives, and printers, (2) establish a user interface, and (3) execute and provide services for applications software.

                                    What is the main purpose of operating system? ›

                                    An operating system is the most important software that runs on a computer. It manages the computer's memory and processes, as well as all of its software and hardware. It also allows you to communicate with the computer without knowing how to speak the computer's language.

                                    What is the conclusion of operating system? ›

                                    In conclusion, an operating system is a software that manages computer hardware and software resources, and to provide public services for computer programs. The operating system is an important part of the system software in a computer system.

                                    What are the main features of an operating system? ›

                                    Functions of the operating system

                                    manages the CPU - runs applications and executes and cancels processes. multi-tasks - allows multiple applications to run at the same time. managesmemory - transfers programs into and out of memory, allocates free space between programs, and keeps track of memory usage.

                                    What is the most important part of an operating system? ›

                                    The main components of an OS mainly include kernel, API or application program interface, user interface & file system, hardware devices and device drivers. An Operating System provides services to both the users and to the programs. It provides programs an environment to execute.

                                    What are the main components of operating system? ›

                                    There are following 8-components of an Operating System:
                                    • Process Management.
                                    • I/O Device Management.
                                    • File Management.
                                    • Network Management.
                                    • Main Memory Management.
                                    • Secondary Storage Management.
                                    • Security Management.
                                    • Command Interpreter System.

                                    What is operating system questions and answers? ›

                                    An operating system is a program that manages the computer hardware. it act as an intermediate between a users of a computer and the computer hardware. It controls and coordinates the use of the hardware among the various application programs for the various users. 2.

                                    What is operating system long question? ›

                                    An Operating System is the interface between the computer hardware and the end-user. Processing of data, running applications, file management and handling the memory is all managed by the computer OS. Windows, Mac, Android etc.

                                    How many types of operating systems are there? ›

                                    There are five main types of operating systems.

                                    What are the 4 Roles of an operating system? ›

                                    In any computer, the operating system:
                                    • Controls the backing store and peripherals such as scanners and printers.
                                    • Deals with the transfer of programs in and out of memory.
                                    • Organises the use of memory between programs.
                                    • Organises processing time between programs and users.
                                    • Maintains security and access rights of users.

                                    What is operating system classification? ›

                                    Classification of Operating Systems

                                    Single-User: just allows one user to use the programs at one time. Multiprocessor: Supports opening the same program more than just in one CPU. Multitasking: Allows multiple programs running at the same time.

                                    What are the two major design goal of operating system? ›

                                    There are two types of goals of an Operating System i.e. Primary Goals and Secondary Goal.

                                    How do you write a conclusion for a project? ›

                                    Here are some key aspects to include in your conclusion to ensure its effectiveness:
                                    1. End the essay on a positive note.
                                    2. Communicate the importance of your ideas and the subject matter.
                                    3. Provide the reader with a sense of closure.
                                    4. Reiterate and summarize your main points.
                                    5. Rephrase and then restate your thesis statement.

                                    How do you write a conclusion for a computer project? ›

                                    How to Write a Conclusion
                                    1. Include a topic sentence. Conclusions should always begin with a topic sentence. ...
                                    2. Use your introductory paragraph as a guide. ...
                                    3. Summarize the main ideas. ...
                                    4. Appeal to the reader's emotions. ...
                                    5. Include a closing sentence.
                                    7 Jun 2021

                                    What is library operating system? ›

                                    A library operating system is one in which the services that a typical operating system provides, such as networking, are provided in the form of libraries and composed with the application and configuration code to construct a unikernel: a specialized, single address space, machine image that can be deployed to cloud ...

                                    What are the 3 categories of operating systems? ›

                                    In this unit, we will focus on the following three types of operating systems namely, stand-alone, network and embedded operating systems.

                                    What are the two most common operating systems? ›

                                    The three most common operating systems for personal computers are Microsoft Windows, Mac OS X, and Linux. Modern operating systems use a graphical user interface (GUI).

                                    What causes operating system failure? ›

                                    An operating system failure can be caused by a hardware malfunction or a software crash, and it usually results in the inability of the operating system to boot. The OS may repeatedly reboot and freeze with an error message displayed on the screen, or it may completely stop running with no notifications.

                                    What are the 6 basic functions of an operating system? ›

                                    Functions of OS are:
                                    • Memory Management.
                                    • Process Management/CPU Scheduling.
                                    • Device Management.
                                    • File Management.
                                    • Security.
                                    • Accounting.
                                    • Error detection etc.

                                    What are examples of operating system? ›

                                    Examples of Operating Systems

                                    Some examples include versions of Microsoft Windows (like Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP), Apple's macOS (formerly OS X), Chrome OS, and various Unix and Linux distribution lists. (Unix and Linux are open-source operating systems.)

                                    What is operating system answer in one word? ›

                                    An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. ...

                                    What is an operating system PDF? ›

                                    An operating system is a type of system software that manages and controls the resources and computing capability of a computer or a computer network, and provides users a logical interface for accessing the physical computer to execute applications.

                                    What is critical section in OS? ›

                                    What is the Critical Section in OS? Critical Section refers to the segment of code or the program which tries to access or modify the value of the variables in a shared resource.

                                    Which operating system is easy to use? ›

                                    #1) MS-Windows

                                    Windows is the most popular and familiar operating system on this list. From Windows 95, all the way to the Windows 10, it has been the go-to operating software that is fueling the computing systems worldwide. It is user-friendly, and starts up & resumes operations fast.

                                    What is the evolution of operating system? ›

                                    The evolution of operating systems began with serial processing. It marks the start of the development of electronic computing systems as alternatives to mechanical computers. Because of the flaws in mechanical computing devices, humans' calculation speed is limited, and they are prone to making mistakes.

                                    What is an operating system simple definition? ›

                                    Definition of operating system

                                    : software that controls the operation of a computer and directs the processing of programs (as by assigning storage space in memory and controlling input and output functions)

                                    What are the 4 types of operating system? ›

                                    Types of operating systems
                                    • Batch OS. The batch operating system does not have a direct link with the computer. ...
                                    • Time-sharing or multitasking OS. ...
                                    • Distributed OS. ...
                                    • Network OS. ...
                                    • Real-time OS. ...
                                    • Mobile OS.

                                    What is operating system with examples? ›

                                    Operating System is defined as a collection of programs that coordinates the operations of computer hardware and software. It acts as a bridge for the interface between man and machine. Examples of Operating System are: Windows Linux BOSS etc.

                                    What are the 3 categories of operating systems? ›

                                    In this unit, we will focus on the following three types of operating systems namely, stand-alone, network and embedded operating systems.

                                    How many types of OS are there? ›

                                    There are five main types of operating systems. These five OS types are likely what run your phone, computer, or other mobile devices like a tablet.

                                    What are the two basic types of operating systems? ›

                                    There are two basic types of network operating systems, discussed as follows: Peer-to-Peer Network Operating Systems: allow users to share network resources saved in a common, accessible network location. Client/Server Network Operating Systems: provide users with access to resources through a server.

                                    What is operating system classification? ›

                                    Classification of Operating Systems

                                    Single-User: just allows one user to use the programs at one time. Multiprocessor: Supports opening the same program more than just in one CPU. Multitasking: Allows multiple programs running at the same time.

                                    What are the types of operating system in computer? ›

                                    What are the types of an Operating System?
                                    • Batch Operating System. ...
                                    • Time-Sharing Operating System. ...
                                    • Distributed Operating System. ...
                                    • Embedded Operating System. ...
                                    • Real-time Operating System.

                                    What is the history of OS? ›

                                    The first operating system (OS) was created in the early 1950s and was known as GMOS. General Motors has developed OS for the IBM computer.

                                    What are the 8 types of operating system? ›

                                    Types of Operating System
                                    • Batch Operating System. There is no direct communication between the computer and the OS. ...
                                    • Real-Time Operating System. It has a data processing system. ...
                                    • Time-Sharing Operating System. ...
                                    • Distributed Operating System. ...
                                    • Embedded Operating System. ...
                                    • Network Operating System. ...
                                    • Mobile Operating System.

                                    What is a operating system called? ›

                                    An operating system is the primary software that manages all the hardware and other software on a computer. The operating system, also known as an “OS,” interfaces with the computer's hardware and provides services that applications can use.


                                    1. Survey of Operating Systems 6th Holcombe Test Bank and Solution Manual
                                    (Santiago Islas)
                                    2. Operating System Full Course | Operating System Tutorials for Beginners
                                    (Academic Lesson)
                                    3. Operating Systems (Types, Functions, Survey) - Intro to Computing in Urdu / Hindi
                                    (ZA Learning)
                                    4. Computer Fundamentals - Operating Systems - Desktop & Mobile OS - Microsoft Windows Mac Fundamental
                                    (Professor Adam Morgan)
                                    5. [Lecture No 17 ][ Survey Of different Operating Systems-Part-2]
                                    (Fakhar Khan)
                                    6. Operating Systems: Course Overview
                                    (David Evans)

                                    Top Articles

                                    Latest Posts

                                    Article information

                                    Author: Foster Heidenreich CPA

                                    Last Updated: 10/04/2022

                                    Views: 5457

                                    Rating: 4.6 / 5 (76 voted)

                                    Reviews: 83% of readers found this page helpful

                                    Author information

                                    Name: Foster Heidenreich CPA

                                    Birthday: 1995-01-14

                                    Address: 55021 Usha Garden, North Larisa, DE 19209

                                    Phone: +6812240846623

                                    Job: Corporate Healthcare Strategist

                                    Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

                                    Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.