Lecture notes on UNIX operating system

unix operating system advantages and disadvantages. unix operating system architecture and features | pdf free download
JackBrown Profile Pic
JackBrown,Georgia,Professional
Published Date:11-07-2017
Your Website URL(Optional)
Comment
SYLLABUS UNIX OPERATING SYSTEM Overview of UNIX Operating System, basic features of Unix operating System, File Structure, CPU Scheduling, Memory Management, File System Implementation of Operating System Functions in UNIX. Starting Of Unix and Text Manipulation and user- to-user communication User Names and Groups, Logging In, Format of Unix Commands, Changing your password, Unix Documentation, Files and Directories, File permission, Basic Operation on Files, Changing Permission Modes, Standard files, Processes Inspecting Files, Operating On Files, Printing Files, Rearranging Files, Sorting Files, Splitting Files, Translating Characters, On line communication, Off line communication. VI EDITORS General characteristics, Adding text and Navigation, changing text, searching for text, copying and Moving text, Features of Ex, Line Editors Ex and Ed, Stream editor SED, changing several files in SED, AWK. Shell Programming Programming in the Bourne and C-Shell, Wild Cards, Simple Shell program, variables, Programming Construct, Interactive Shell scripts, Advanced Features, Unix Compiler, Maintaining program System Administration Define system Administration, Booting the system, Maintaining User Accounts, File System, and special files, Backup and Restoration 5 System administration 5.1 System administration Definition 5.2 The Boot Procedure 5.3 Unix Shutdown and Reboot 5.3.1 Methods of shutting down and rebooting 5.4 Operating System install overview 5.5 What is a UNIX System Administrator? 5.5.1 Some Common System Administration Tasks. 5.6 Types of Unix users. 5.7 Things to be aware of when using root account 5.7.1 Some Useful Tools. 5.7.2 ps command (System V) 5.7.3 ps command (BSD) 5.7.4 find command 5.8 Users, Groups and Passwords 5.8.1 Creating user accounts 5.8.2 Deleting user accounts 5.8.3 Making changes 5.9 UNIX file system 5.10 Structure of the file system 5.11 Controlling access to your files and directories 5.12 Backup and File Restoration 1 UNIX OPERATING SYSTEM 1.2 Unix introduction 1.2 History of Unix 1.2.1 The Connection between Unix and C 1.2.2 Why Use Unix? 1.3 Components of UNIX operating system 1.4 Basic Characteristics of Unix 1.5 Unix File structures 1.5.1 Unix Command Format 1.5.2 Listing Files with ls 1.5.3 File Types, Permissions, and Modes 1.5.4 Changing permissions with chmod 1.5.5 Manipulating files with cp and mv 1.5.5.1 cp command 1.5.5.2 mv command 1.5.5.3 Viewing Files 1.6 Directories and the Unix File System 1.6.1 what are Directories? 1.6.2 Current and Home Directories 1.6.3 Naming UNIX Files and Directories 1.6.3.1 Absolute Naming 1.6.3.2 Relative Naming 1.6.3.3 Shortcuts for File Naming 1.6.3.4 File Naming Limitations 1.6.3.5 File Name Extensions 1.6.4 More About Listing Directories 1.6.5 Moving Around the File System 1.6.6 Creating and Removing Directories 1.7 Standard Filesystem Layout 1.7.1 Using MetaCharacters for File Matching 1.8 Data Redirection and Pipes 1.9 CPU Scheduling 1.10 Memory Management 1.10.1 OS Memory Uses: 1.10.2 Process Memory Uses: 1.10.3 Swapping 1.10.4 Mapped Files 1.10.5 How much memory is there? 1.10.6 How much memory is being used? 1.1 Unix introduction Unix is the multi-user multitasking Operating system. UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops. UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows, which provides an easy to use environment. However, knowledge of UNIX is required for operations, which aren't covered by a graphical program, or for when there are no windows interface available, for example, in a telnet session. 1.2 History of Unix The Unix operating system found its beginnings in MULTICS, which stands for Multiplexed Operating and Computing System. The MULTICS project began in the mid 1960s as a joint effort by General Electric, Massachusetts Institute for Technology and Bell Laboratories. In 1969 Bell Laboratories pulled out of the project. One of Bell Laboratories people involved in the project was Ken Thompson. He liked the potential MULTICS had, but felt it was too complex and that the same thing could be done in simpler way. In 1969 he wrote the first version of Unix, called UNICS. UNICS stood for Uniplexed Operating and Computing System. Although the operating system has changed, the name stuck and was eventually shortened to Unix. Ken Thompson teamed up with Dennis Ritchie, who wrote the first C compiler. In 1973 they rewrote the Unix kernel in C. The following year a version of Unix known as the Fifth Edition was first licensed to universities. The Seventh Edition, released in 1978, served as a dividing point for two divergent lines of Unix development. These two branches are known as SVR4 (System V) and BSD. Ken Thompson spent a year's sabbatical with the University of California at Berkeley. While there he and two graduate students, Bill Joy and Chuck Haley, wrote the first Berkely version of Unix, which was distributed to students. This resulted in the source code being worked on and developed by many different people. The Berkeley version of Unix is known as BSD, Berkeley Software Distribution. From BSD came the vi editor, C shell, virtual memory, Sendmail, and support for TCP/IP. For several years SVR4 was the more conservative, commercial, and well supported. Today SVR4 and BSD look very much alike. Probably the biggest cosmetic difference between them is the way the ps command functions. The Linux operating system was developed as a Unix look alike and has a user command interface that resembles SVR4. • Figure 1: The Unix Family Tree 1.2.1 The Connection Between Unix and C At the time the first Unix was written, most operating systems developers believed that an operating system must be written in an assembly language so that it could function effectively and gain access to the hardware. Not only was Unix innovative as an operating system, it was ground-breaking in that it was written in a language (C) that was not an assembly language. The C language itself operates at a level that is just high enough to be portable to variety of computer hardware. A great deal of publicly available Unix software is distributed as C programs that must be complied before use. Many Unix programs follow C's syntax. Unix system calls are regarded as C functions. What this means for Unix system administrators is that an understanding of C can make Unix easier to understand. 1.2.2 Why Use Unix? One of the biggest reasons for using Unix is networking capability. With other operating systems, additional software must be purchased for networking. With Unix, networking capability is simply part of the operating system. Unix is ideal for such things as world wide e-mail and connecting to the Internet. Unix was founded on what could be called a "small is good" philosophy. The idea is that each program is designed to do one job well. Because Unix was developed different people with different needs it has grown to an operating system that is both flexible and easy to adapt for specific needs. Unix was written in a machine independent language. So Unix and unix-like operating systems can run on a variety of hardware. These systems are available from many different sources, some of them at no cost. Because of this diversity and the ability to utilize the same "user-interface" on many different systems, Unix is said to be an open system. 1.3 Components of UNIX operating system The UNIX operating system is made up of three parts; the kernel, the shell and the programs. The kernel The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the file store and communications in response to system calls. As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the file store for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands. The shell The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems). The adept user can customize his/her own shell, and users can use different shells on the same machine. Staff and students in the school have the tcsh shell by default. The tcsh shell has certain features to help the user inputting commands. Filename Completion - By typing part of the name of a command, filename or directory and pressing the Tab key, the tcsh shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed, it will beep, prompting you to type a few more letters before pressing the tab key again. History - The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands. Files and processes Everything in UNIX is either a file or a process. A process is an executing program identified by a unique PID (process identifier). A file is a collection of data. They are created by users using text editors, running compilers etc. Examples of files: • a document (report, essay etc.) • the text of a program written in some high-level programming language • instructions comprehensible directly to the machine and incomprehensible to a casual user, for example, a collection of binary digits (an executable or binary file); • a directory, containing information about its contents, which may be a mixture of other directories (subdirectories) and ordinary files. The Directory Structure All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root (written as a slash / ) In the diagram above, we see that the home directory of the undergraduate student "ee51vn" contains two sub-directories (docs and pics) and a file called report.doc. The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc" 1.4 Basic Characteristics of Unix Unix is, at its base level, a multi-user, multitasking, virtual memory operating system that runs on a wide variety of hardware platforms. This means that Unix is able to do many things at the same time, for many different users, and using more memory than it really has physically installed. From a user's perspective this is very nice, and from an operating systems point of view, it is very interesting. But UNIX really is much more than just an operating system; it is a philosophy of using and programming a computer that gets its power from the relationships between programs rather than the programs themselves. This is evident from many of the design points of UNIX, which will be mentioned later. Let's look at each of the three characteristics of Unix listed above. a) Unix is a multi-user system. This means that inherent to Unix is the idea that there are different users of the system, and that different users may have different sorts of privileges and types of access to different parts of the system. It allows for the idea that some users may want to protect some of their data from being accessed by other users on the system. So, in being a multi-user system, the basic ideas of system security and data privacy come up. Likewise, there must be some way to identify one user from another in a multi-user system. Unix uses a system of login names to identify users and passwords to authenticate that a user is, in fact, who she claims to be. b) Unix is a multitasking system. This means that Unix has the ability to handle more than one task at a time. These tasks might be several programs that any particular user wants to run, or they may be programs run by several users at once. Multitasking, combined with being a multi-user system, makes it possible for more than one person to be logged in and using a Unix system at once. This is true for any Unix system, not just large timesharing systems. Even small, desktop systems have the capability to support multiple concurrent users. Additionally, some of the tasks that the system could be doing, and probably is doing, can be system tasks related to keeping the system going and providing the services needed by the users. c) Unix is a virtual memory operating system. The concept of virtual memory and memory management is a bit beyond the scope of this seminar, but a few key concepts are important to note. In a virtual memory system, the system behaves as if it has much more memory than is physically installed. Some portion of the disk is used to simulate extra memory. This idea makes it possible to run large programs on a smaller system. Some tradeoff exists between the amount of memory that a program uses and how fast it will run, since if it is very large, it must access the disk a lot, but it will eventually run. In a multitasking environment, tasks that are not currently running can be moved out of memory and onto disk to free up memory for tasks that more urgently need it. The overall result is better use of the system resources for all involved. 1.5 Unix File structures Once we understand the Unix file system, its structure, and how to move around in it, you will be able to easily interact with Unix. It is important that you remember and understand that in Unix, everything is treated as a file. Unix files are for the most part simply collections of bytes. There is no concept of a record in Unix. Some programs choose to treat certain bytes (like newline characters) differently than others, but to Unix, they're just bytes. Directories are basically just files as well, although they contain other files. Special files are still just files to Unix and include things like external devices, memory, and terminals. Since Unix is a multi-user system, each user is allocated his own file space. Each user has a directory on the system where his files will be kept. This file is known as that user's home directory. When you log into a Unix system, you are automatically placed in your home directory. You can create, delete, and modify files in this directory, but probably not in many other places on the system. Likewise, other users are not able to access files in your home directory unless you allow them to. Let's assume that you have logged in and some files already exist in your account. It would be helpful to be able to find out what files are there. The ls command is used to list files in Unix. Using the ls command might give an output something like the following: % ls baby.1 ig.discography src bin mbox unix.refer From this, we can see that several files exist in our account already. We don't know anything about them, but that won't bother us for now. What we care about now is the fact that we can tell what files exist. ls has given us a list of the names of the files. Notice that the list of files is formatted nicely to fit within the width of the screen. ls works at making the output look relatively attractive and not jumbled. File names are laid out in columns, the number of columns depending on the size of the display and the size of the filenames. By default, the names are sorted alphabetically. 1.5.1 Unix Command Format Since ls is the first Unix command that we have looked at, now is a good time to stand back and see how most Unix commands work. In almost all cases, the syntax of the Unix command is the same and follows the pattern: command options arguments where command is the command that you want to execute, options are different flags and options to the command, usually preceded with a minus sign, and argument specifies what to do the command to. It is not always necessary to give options and arguments to commands, since most commands have a default set of options and a default object of their action. Some commands have only a few options while other have so many options. 1.5.2 Listing Files with ls The ls command, as it turns out, has many modifiers and options. These change things, like which files are listed, in what order the files are sorted, and what additional information to give about the files. For example, if you name a file so that the first character of its name is a dot (.), then ls does not, by default, show you this file. This is helpful so that you don't see the many system files that control your Unix session each time you list your files. However, the modifier a causes ls to display all of the files, even ones starting with dot. The special files . and .. will be discussed later, along with the purpose of many of the other dot files. % ls a . .emacs .mailrc bin unix.refer .. .exrc .plan ig.discography .aliases .login .rhosts mbox .cshrc .logout baby.1 src Files have many more attributes than just their names. Each file has a size, an owning user and owning group, a date of last modification, as well as other system related information. The l option to ls shows you more about the files. % ls l total 23 rwrr 1 dickson 2639 Jan 30 18:02 baby.1 drwxrxrx 2 dickson 512 Jan 30 18:02 bin rwrr 1 dickson 9396 Jan 30 18:03 ig.discography rw 1 dickson 5239 Jan 30 18:10 mbox drwxrwxrx 3 dickson 512 Jan 30 18:06 src rwrr 1 dickson 1311 Jan 30 18:03 unix.refer This listing shows us several fields of information for each file. The first field specifies the file type and access permissions. More about this shortly. The second field tells the number of links to the file. For now, we can disregard this. Links are sort of like aliases for files and are generally important only to the system. The third column tells us what user owns the file. For all of these files, since they are our files, we own them. The next column shows us how many bytes are in the file. Next comes the time when the file was last modified. Finally comes the name of the file. There are many, many more options to ls, so refer to man ls for the details. 1.5.3 File Types, Permissions, and Modes At this point, we need to talk a little bit about file access permissions and file types. The field in ls for file types and permissions is made up of ten characters, never more, never less. The first character tells us what kind of file this is. Most commonly, there will be a in this field specifying that this is a plain file. The second most common file type to be found here is d for a directory. Any other character means that it is a special file. These would include things like symbolic links, different kinds of devices, pipes, etc. It is not really important at this point to distinguish between types of special files, but it is important to be able to recognize them. In the example above, we can see that src and bin are both directories and that the rest of the files are just plain files. The next nine characters specify who is able to read, write, and execute this file. Unix access permissions are broken into three classes: the owner of the file, other people in the same account group as the owner, and the rest of the world. Every user is part of at least one account group. This is just a collection of users assigned to a group due to a similar need for access to data, enrollment in a class, or any other reason that the system administrator might choose. Groups can only be created by the system administrator. Just as there are three groups for access permissions, the permission field is broken into three sets of three characters. In each set of three characters, the first is for permission to read the file. Second is the permission to write or change the file, and last is the ability to execute the file. If a letter is found in the field corresponding to a permission, then that permission is granted. If a is found, then that permission is denied. With respect to the three sets of letters, the first triplet corresponds to the permissions that the owner of the file has, the second set of three belongs to the group permission, and the last set of three corresponds to the rest of the users on the system. In the example above, we can see that for all of the files above, the owner of the file is able to read and write the file. None of the plain files are executable by anyone. This would indicate that they are not things that are meant to be run, but rather are probably just some sort of data. All of the files, except the one named mbox are readable by other people in the user's account group, as well as anyone else on the system. mbox, the mailbox for the user, is protected so that only he can read its contents. Notice that for the two directories, bin and src, they have execute permissions set. Permissions are interpreted differently for directories than for plain files. Read permission on a directory grants the ability to list the contents of that directory (in other words, see the list of files in it). Write permission on a directory grants the ability to create or remove files in the directory. In order to delete a file, you must have write permission on the directory, not the file. Finally, execute permission on a directory grants the ability to change to (cd) that directory. 1.5.4 Changing permissions with chmod What if we decided that we didn't want people outside of our group to be able to read what was in unix.refer? The chmod (CHange MODe) command alters the access permissions to files. If we wanted to remove the right of anyone else to read unix.refer, the command chmod or unix.refer would do the trick. The modifiers for chmod are fairly complex. In general, they can be summarized by saying that you specify whose permissions you are modifying (u for the user, g for the group, and o for others), what you are doing to the permission (+ to add, to remove, or = to set), and what permissions you plan to modify (r for read, w for write, and x for execute). See man chmod for the details. If we then decided that we want to allow people within our group to modify this bibliography (refer is the standard Unix bibliography program), we would use the following command: chmod g+w unix.refer The following shows this transaction and its output. % chmod or unix.refer % chmod g+w unix.refer % ls l unix.refer rwrw 1 dickson 1311 Jan 30 18:03 unix.refer We can now see that the changes we wanted have been made to the file permissions. 1.5.5 Manipulating files with cp and mv 1.5.5.1 cp command The cp command is used to copy a file from one file to another or one directory to another. In general, cp makes an identical copy of a file, updating its last time of modification, but maintaining most of its permissions (subject to some conditions see man umask for more details). If you want to copy a file and preserve its modification time and its permissions, use the p option. If you want to copy a directory and all of its contents, use the r, for recursive, option. The following is an example of just copying a file. % cp unix.refer NewBibliography.refer % ls l .refer rwr 1 dickson 1311 Jan 30 19:20 NewBibligraphy.refer rwrw 1 dickson 1311 Jan 30 18:03 unix.refer In the following example, we will copy several files into a directory. % mkdir bibs % cp .refer bibs % ls l bibs total 4 rwr 1 dickson 1311 Jan 30 19:42 NewBibligraphy.refer rwr 1 dickson 1311 Jan 30 19:42 unix.refer 1.5.5.2 mv command If you want to change the name of a file, mv will rename the file. Actually, mv moves the file within the filesystem, but that is, for all intents and purposes, the same thing. You can move one file or directory to another, just renaming it. Or, you can move one or more files or directories into a target directory. If we had wanted to move our bibliographies from the above example into the bibs directory instead of copying them, the following sequence of commands would have done the trick. % mkdir bibs % mv .refer bibs % ls l bibs total 4 rwr 1 dickson 1311 Jan 30 19:42 NewBibligraphy.refer rwr 1 dickson 1311 Jan 30 19:42 unix.refer 1.5.5.3 Viewing Files So far, we have seen how to list, copy, and rename files. Another necessary operation is to view the contents of a file. There are a large number of commands in Unix that will display the contents of a file in a variety of ways. The simplest of these is the cat command. cat, in this application, reads the named file and displays it on the screen. In actuality, cat is doing something a little simpler and more generic than that even. We'll talk more about that shortly, as well as looking at a number of other commands for viewing files. The following is a simple example of the cat command. % cat ShortFile This is a short file so that we can see what a file looks like. There are only about four lines in this file. And this is the fourth line. 1.6 Directories and the Unix File System 1.6.1 What are Directories? So far, we have mentioned directories several times and used them as objects and targets for copying or renaming files, but have not discussed just what the filesystem looks like and how directories are arranged. Directories are basically just files that contain other files. If you are familiar with MSDOS, the idea is just the same. If you are a Macintosh user, directories are very similar to folders. A directory can contain any sort of file that you might want, including other directories. This leads to a tree structured file system, with the top of the file system being a directory called the root and labeled as / . The files in a directory are called the children its children. So, every file on the system is either a child of the root, or a descendent at some level of the root. When you create a new directory, it is not completely empty at its creation time. Every directory has at least two children, . and .. . The directory labeled . refers to the directory itself, and .. refers to its immediate parent directory. These allow us to have a larger degree of flexibility in naming files.

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.