Department of Computer Science & Engineering LAB MANUAL SUBJECT: Operating System (BTCS-406) 5th Semester (B. Tech) (Branch: CSE) Chandigarh Group of Colleges College of Engineering Landran, Mohali-140307 SUBJECT: Operating System (BTCS-406) COURSE OBJECTIVE This course will provide the students with good understanding of Operating System including its architecture and all its components. Good conceptions on all the subjects like processes, inter communication, semaphore, message passing, classical systems, security and protection mechanism, I/O hardware and software, deadlocks, etc. should be provided COURSE OUTCOMES This subject will help the students in following mentioned ways; - This course provides the student with an understanding of the basic components of a general-purpose operating system. - Topics include processes, process management, synchronization, input/output devices and their programming, interrupts, memory management, resource allocation, and an introduction to file systems. - It allow students to know how to write applications that leverage operating system resources or for those that wish to develop operating systems themselves. LIST OF EXPERIMENTS 1. Installation Process of various operating System. 2. Virtualization, Installation of Virtual Machine Software and installation of Operating System on Virtual Machine 3. Commands for files & directories: cd, ls, cp, md, rm, mkdir, rmdir. Creating and viewing files using cat. File comparisons. Disk related commands: checking disk free spaces. Processes in linux connecting processes with pipes, background processing, managing multiple processes. Manual help. Background process: changing process priority, scheduling of processes at command, Batch commands, kill, ps, who, sleep. Printing file. File related commands ws, sat, cut, grep. 4. Shell Programming: Basic of shell programming, various types of shell, Shell Programming in bash, conditional & looping statement, case statements, parameter passing and arguments shell variables, shell keywords, creating shell programs for automate system tasks, report printing. EXPERIMENT NO. 1 Aim:- To study the details of DOS and Windows so as to understand the difference between both the operating systems. Objective: To study in detail about DOS and Windows. INTRODUCTION:When the computer starts, it starts the operating system that takes the control of the machine. An Operating System is a set of programs that help in controlling and managing the Hardware and the Software resources of a computer system. A good operating system should have the following features: 1. Help in the loading of programs and data from external sources into the internal memory before they are executed. 2. Help programs to perform input/output operations, such as; o Print or display the result of a program on the printer or the screen. o Store the output data or programs written on the computer in storage device. o Communicate the message from the system to the user through the VDU. o Accept input from the user through the keyboard or mouse. DISK OPERATING SYSTEM:DOS is a single user, single task operating system with basic kernel functions that are nonreentrant code; once a process is begun, it must be allowed to run until finished before the same process can be used again. Basically, DOS is the medium through which the user and external devices attached to the system communicate with the system. DOS translate the command issued by the user in the format that is understandable by the computer and instruct computer to work accordingly. It also translates the result and any error message in the format for the user to understand. The main functions of DOS are to manage disk files, allocate system resources according to the requirement. DOS provides features essential to control hardware devices such as Keyboard, Screen, Disk Devices, Printers, Modems and programs. The text-based MS-DOS user interface may seem primitive, but it is actually very fast and powerful. The MS-DOS interface is geared around the prompt, which is a path followed by a greater than (>) sign. When we see the prompt, we know MS-DOS is ready to accept our commands. MS-DOS is always focused on a directory, and the prompt shows us which directory we are focused on. Any commands we issue are performed on that directory. MS-DOS prompt History of MS-DOS:When IBM launched its revolutionary personal computer, the IBM PC, in August 1981, it came complete with a 16-bit operating system from Microsoft, MS-DOS 1.0. This was Microsoft's first operating system, and it also became the first widely used operating system for the IBM PC. QDOS was written by Tim Paterson, a Seattle Computer Products employee, for the new Intel 16-bit 8086 CPU (central processing unit), and the first version was shipped in August, 1980. Although it was completed in a mere six weeks, QDOS was sufficiently different from CP/M to be considered legal. Paterson was later hired by Microsoft. Versions of MS-DOS featured improved performance and additional functions, not a few of which were copied from other operating systems. For example, version 1.25, released in 1982, added support for double-sided disks, thereby eliminating the need to manually turn the disks over to access the reverse side. Version 2.0 released the next year, added support for directories, for IBM's then huge 10MB hard disk drive (HDD) and for 360KB, 5.25-inch floppy disks. This was followed by version 2.11 later in the same year, which added support for foreign and extended characters. Version 3.0 launched in 1984, added support for 1.2MB floppy disks and 32MB HDDs. This was soon followed by version 3.1, which added support for networks. Additions and improvements in subsequent versions included support for multiple HDD partitions, for disk compression and for larger partitions as well as an improved disk-checking utility, enhanced memory management, a disk defragmenter and an improved text editor. The final major version was 7.0, which was released in 1995 as part of Microsoft Windows 95. It featured close integration with that operating system, including support for long filenames and the removal of numerous utilities, some of which were on the Windows 95 CDROM. It was revised in 1997 with version 7.1, which added support for the FAT32 file system on HDDs. MS-DOS LAYERED STRUCTURE The Structure of DOS:The structure of Disk Operating System for IBM PC-compatible computers can be broken down into four distinct components: BIOS Module Kernel Command Processor External Commands The BIOS Module: The BIOS module includes the default resident drivers for: Console display and keyboard (CON) Line printer (PRN) Auxiliary device (AUX) Date and time (CLOCK) Boot disk device (block device) It also accommodates installable drivers (DEVICE=commands in CONFIG.SYS), such as: MOUSE.SYS ANSI.SYS 386EMM.SYS CLOCK.SYS, etc. The primitive parts of the resident drivers are in the ROM BIOS while the rest are in the IO.SYS (or IBMBIO.COM) system file. The DOS Kernel: The DOS Kernel performs the following functions: File and record management Memory management Character device input/output Spawning other programs Access to real-time clock The DOS kernel components are contained in the MSDOS.SYS (or IBMDOS.COM) system file. Programs communicate with the kernel via software interrupts. The Command Processor: The command processor is also known as the shell, or the command interpreter. The command processor is not the operating system, but rather a special class of program running under control of MS-DOS - it is the user interface to DOS. The command processor is responsible for parsing and carrying out user commands, including the loading and execution of other programs from disk (external commands). The command processor also includes the code for many of the most commonly-used DOS commands, known as the internal commands. Five standard handles defined by MS-DOS for COMMAND.COM Standard input CON Standard output CON Standard error CON Auxiliary AUX List device PRN The DOS External Commands: The external commands are known as disk bound commands. They reside in individual files on disk and must be loaded into primary memory (RAM) before they can be executed. DOS Commands :MS-DOS has a relatively small number of commands, and an even smaller number of commonly used ones. Moreover, these commands are generally inflexible because, in contrast to Linux and other Unix-like operating systems, they are designed to accommodate few options or arguments (i.e., values that can be passed to the commands). Some of the most common commands are as follows (corresponding commands on Unix-like operating systems are shown in parenthesis): CD - changes the current directory (cd) COPY - copies a file (cp) DEL - deletes a file (rm) DIR - lists directory contents (ls) EDIT - starts an editor to create or edit plain text files (vi, vim, ed, joe) FORMAT - formats a disk to accept DOS files (mformat) HELP - displays information about a command (man, info) MKDIR - creates a new directory (mkdir) RD - removes a directory (rmdir) REN - renames a file (mv) TYPE - displays contents of a file on the screen (more, cat) Windows operating system:- Windows is preemptive, reentrant operating system, which has been designed to work with either uniprocessor or symmetrical multi processor (SMP)-based computers. To process input/output (I/O) requests it uses packet-driven I/O, which utilizes I/O request packets (IRPs) and asynchronous I/O. Architecture of Windows:- The architecture of Windows is highly modular and consists of two main layers: components that run in user mode and components that run in kernel mode. Programs and subsystems in user mode are limited in terms of what system resources they have access to, while the kernel mode has unrestricted access to the system memory and external devices. The architecture comprises a hybrid kernel, hardware abstraction layer (HAL), drivers, and a range of services (collectively named Executive), which all exist in kernel mode. User mode:- The user mode is made up of subsystems which can pass I/O requests to the appropriate kernel mode drivers via the I/O manager (which exists in kernel mode). Two subsystems make up the user mode layer of Windows: the Environment subsystem and the Integral subsystem. The environment subsystem was designed to run applications written for many different types of operating systems. None of the environment subsystems can directly access hardware, and must request access to memory resources through the Virtual Memory Manager that runs in kernel mode. Also, applications run at a lower priority than kernel mode processes. There are three main environment subsystems: the Win32 subsystem, an OS/2 subsystem and a POSIX subsystem. The Win32 environment subsystem can run 32-bit Windows applications. It contains the console as well as text window support, shutdown and hard-error handling for all other environment subsystems. It also supports Virtual DOS Machines (VDMs). The Win32 environment subsystem process (csrss.exe) also includes the window management functionality, sometimes referred to as a "window manager." It handles input events (such as from the keyboard and mouse), then passes messages to the applications that need to receive this input. Each application is responsible for drawing or refreshing its own windows and menus, in response to these messages. The OS/2 environment subsystem supports 16-bit character-based OS/2 applications and emulates OS/2 1.x, but not 32-bit or graphical OS/2 applications as used with OS/2 2.x or later. The POSIX environment subsystem supports applications that are strictly written to either the POSIX.1 standard or the related ISO/IEC standards. The POSIX subsystem has been an area of recent active development and is a major feature of Windows Compute Cluster Server 2003. The integral subsystem looks after operating system specific functions on behalf of the environment subsystem. It consists of a security subsystem, a workstation service and a server service. The security subsystem deals with security tokens, grants or denies access to user accounts based on resource permissions, handles login requests and initiates login authentication, and determines which system resources need to be audited by Windows. It also looks after Active Directory. The workstation service is an API to the network redirector, which provides the computer access to the network. The server service is an API that allows the computer to provide network services. Kernel mode:- Windows kernel mode has full access to the hardware and system resources of the computer and runs code in a protected memory area. It controls access to scheduling, thread prioritisation, memory management and the interaction with hardware. The kernel mode stops user mode services and applications from accessing critical areas of the operating system that they should not have access to; user mode processes must ask the kernel mode to perform such operations on their behalf. While the x86 architecture supports four different I/O privilege levels (numbered 0 to 3), only the two extreme IOPL levels are used. Usermode programs are run with IOPL 3, and the kernel runs with IOPL 0. These two levels are often referred to as "ring 3" and "ring 0", respectively. Such a design decision had been done to achieve code portability to RISC platforms that only support two privilege levels. Kernel mode consists of executive services, which is itself made up on many modules that do specific tasks, kernel drivers, a kernel and a Hardware Abstraction Layer, or HAL. Executive:- The Executive interfaces with all the user mode subsystems. It deals with I/O, object management, security and process management. It's informally divided into several subsystems, among which Cache Manager, Configuration Manager, I/O Manager, Local Procedure Call (LPC), Memory Manager, Object Manager, Process Structure and Security Reference Monitor (SRM). Grouped together, the components can be called Executive services (internal name Ex). System Services (internal name Nt), i.e., system calls, are implemented at this level, too, except very few that call directly into the kernel layer for better performance. Object Manager: The Object Manager (internal name Ob) is an executive subsystem that all other executive subsystems, especially system calls, must pass through to gain access to Windows resources— essentially making it a resource management infrastructure service. The object manager is used to reduce the duplication of object resource management functionality in other executive subsystems, which could potentially lead to bugs and make development of Windows harder. To the object manager, each resource is an object, whether that resource is a physical resource (such as a file system or peripheral) or a logical resource (such as a file). Each object has a structure or object type that the object manager must know about. Object creation is a process in two phases, creation and insertion. Creation causes the allocation of an empty object and the reservation of any resources required by the object manager, such as an (optional) name in the namespace. If creation was successful, the subsystem responsible for the creation fills in the empty object. Finally, if the subsystem deems the initialization successful, it instructs the object manager to insert the object, which makes it accessible through its (optional) name or a cookie called a handle. From then on, the lifetime of the object is handled by the object manager, and it's up to the subsystem to keep the object in a working condition until being signaled by the object manager to dispose of it. Object types define the object procedures and any data specific to the object. In this way, the object manager allows Windows to be an object oriented operating system, as object types can be thought of as polymorphic classes that define objects. Most subsystems, though, with a notable exception in the I/O Manager, rely on the default implementation for all object type procedures. Cache Controller: Closely coordinates with the Memory Manager, I/O Manager and I/O drivers to provide a common cache for regular file I/O. Uniquely, the Windows Cache Manager operates on file blocks (rather than device blocks), for consistent operation between local and remote files, and ensures a certain degree of coherency with memory-mapped views of files, since cache blocks are a special case of memory-mapped views and cache misses a special case of page faults. Configuration Manager: Implements the Windows registry. I/O Manager: Allows devices to communicate with user-mode subsystems. It translates user-mode read and write commands in read or write IRPs which it passes to device drivers. It accepts file system I/O requests and translates them into device specific calls, and can incorporate low-level device drivers that directly manipulate hardware to either read input or write output. It also includes a cache manager to improve disk performance by caching read requests and write to the disk in the background. Local Procedure Call (LPC): Provides inter-process communication ports with connection semantics. LPC ports are used by user-mode subsystems to communicate with their clients, by Executive subsystems to communicate with user-mode subsystems, and as the basis for the local transport for MSRPC. Memory Manager: Manages virtual memory, controlling memory protection and the paging of memory in and out of physical memory to secondary storage, and implements a general-purpose allocator of physical memory. It also implements a parser of PE executables that lets an executable be mapped or unmapped in a single, atomic step. Process Structure: Handles process and thread creation and termination, and it implements the concept of Job, a group of processes that can be terminated as a whole, or be placed under shared restrictions (such a total maximum of allocated memory, or CPU time). PnP Manager: Handles Plug and Play and supports device detection and installation at boot time. It also has the responsibility to stop and start devices on demand—this can happen when a bus (such as USB or FireWire) gains a new device and needs to have a device driver loaded to support it. Its bulk is actually implemented in user mode, in the Plug and Play Service, which handles the often complex tasks of installing the appropriate drivers, notifying services and applications of the arrival of new devices, and displaying GUI to the user. Power Manager: Deals with power events (power-off, stand-by, hibernate, etc.) and notifies affected drivers with special IRPs (Power IRPs). Security Reference Monitor (SRM): The primary authority for enforcing the security rules of the security integral subsystem. It determines whether an object or resource can be accessed, via the use of access control lists (ACLs), which are themselves made up of access control entries (ACEs). ACEs contain a security identifier (SID) and a list of operations that the ACE gives a select group of trustees—a user account, group account, or login session—permission (allow, deny, or audit) to that resource. GDI: The Graphics Device Interface is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. Kernel: The kernel sits between the HAL and the Executive and provides multiprocessor synchronization, thread and interrupt scheduling and dispatching, and trap handling and exception dispatching; it is also responsible for initializing device drivers at bootup that are necessary to get the operating system up and running. That is, the kernel performs almost all the tasks of a traditional microkernel; the strict distinction between Executive and Kernel is the most prominent remnant of the original microkernel design, and historical design documentation consistently refers to the kernel component as "the microkernel". The kernel often interfaces with the process manager. The level of abstraction is such that the kernel never calls into the process manager, only the other way around (save for a handful of corner cases, still never to the point of a functional dependence). Kernel-mode drivers: Windows uses kernel-mode device drivers to enable it to interact with hardware devices. Each of the drivers has well defined system routines and internal routines that it exports to the rest of the operating system. All devices are seen by user mode code as a file object in the I/O manager, though to the I/O manager itself the devices are seen as device objects, which it defines as either file, device or driver objects. Kernel mode drivers exist in three levels: highest level drivers, intermediate drivers and low level drivers. The highest level drivers, such as file system drivers for FAT and NTFS, rely on intermediate drivers. Intermediate drivers consist of function drivers—or main driver for a device—that are optionally sandwiched between lower and higher level filter drivers. The function driver then relies on a bus driver—or a driver that services a bus controller, adapter, or bridge—which can have an optional bus filter driver that sits between itself and the function driver. Intermediate drivers rely on the lowest level drivers to function. The Windows Driver Model (WDM) exists in the intermediate layer. The lowest level drivers are either legacy Windows device drivers that control a device directly or can be a PnP hardware bus. These lower level drivers directly control hardware and do not rely on any other drivers. Hardware abstraction layer: The Windows hardware abstraction layer, or HAL, is a layer between the physical hardware of the computer and the rest of the operating system. It was designed to hide differences in hardware and therefore provide a consistent platform on which the kernel is run. The HAL includes hardware-specific code that controls I/O interfaces, interrupt controllers and multiple processors. In particular, hardware abstraction does not involve abstracting the instruction set, which generally falls under the wider concept of portability. Abstracting the instruction set, when necessary (such as for handling the several revisions to the x86 instruction set, or emulating a missing math coprocessor), is performed by the kernel, or via platform virtualization. Windows features:The various features of Windows operating system are as described in the following table: Feature Description Benefit Reliable Built on the new Windows engine Windows XP Professional is Windows XP built on the proven code base of Professional will Windows NT and Windows provide a 2000, which features a 32-bit dependable computing architecture and a computing fully protected memory model. experience for all business users. Enhanced device driver verifier Building on the device driver Device drivers verifier found in Windows 2000, that these pass the Windows XP Professional tests will be the will provide even greater stress most tests for device drivers. robust drivers available, which will ensure maximum system stability. Feature Dramatically Description reduced scenarios Benefit reboot Eliminates most scenarios that Users will force end users to reboot in experience higher Windows NT 4.0 and Windows levels of system 95/98/Me. Also, many software uptime. installations will not require reboots. Improved code protection Critical kernel data structures are Rogue read-only, so that drivers and applications applications cannot corrupt cannot adversely them. All device driver code is affect read-only and page protected. core operating system areas. Side-by-side DLL support Provides a mechanism for This helps to multiple versions of individual address the "DLL Windows components to be hell" problem by installed and run "side by side." allowing an application written and tested with one version of a system component to continue to use that version even if an application that uses a newer version of the same component is installed. Feature Description Benefit Windows File Protection Protects core system files from By safeguarding being overwritten by application system installations. If overwritten, Windows Protection a will file restore correct version. files, is Windows XP File Professional the mitigates many of the most common system failures encountered in earlier versions of Windows. Windows Installer A system service that helps users Will help install, configure, track, upgrade, minimize user and remove software programs downtime and correctly. increase system stability. Enhanced policies software restriction Provide administrators a policy- Can contribute to driven mechanism to identify improved system software running environment and in control their integrity, its manageability, ability to execute. This facility and, ultimately, can be used in virus and Trojan lower cost of horse prevention and software ownership of the lockdown. Preemptive architecture multitasking Designed PC. to applications allow multiple Run to your most run demanding simultaneously, while ensuring applications while great system response and still experiencing Feature Description Benefit stability. impressive system response time. Scalable memory support and processor Supports up to 4 gigabytes (GB) Users who need of RAM and up to two the highest level symmetric multiprocessors. of performance will be able to work with the latest hardware. Encrypting File System (EFS) with Encrypts multi-user support each file with a The highest level randomly generated key. The of protection from encryption and decryption hackers and data processes are transparent to the theft. user. In Windows XP Professional, EFS can provide multiple users access to an encrypted document. IP Security (IPSec) Helps protect data transmitted IT administrators across a network. IPSec is an will be able to important part security for of providing build virtual secure private VPNs quickly and networks (VPNs), which allow easily. organizations to transmit data securely over the Internet. Kerberos support Provides industry-standard and Windows XP high-strength authentication with Professional will fast, single logon to Windows offer single logon Feature Description Benefit 2000—based enterprise for end users for resources. Kerberos is an resources and Internet standard, which makes it supported especially effective for networks applications that include different operating hosted systems such as UNIX. on both Windows 2000 and next- our generation server platform, Windows Server 2003. Smart card support Smart card capabilities are Smart cards integrated into the operating enhance softwaresystem, including support for only smart card logon to terminal such server sessions hosted solutions as client on authentication, Windows Server 2003—based interactive logon, (the next-generation platform) terminal servers. Internet Explorer Add-on Manager server code signing, and secure e-mail. Easily manage and enforce a list Helps reduce the of Internet Explorer add-ons that potential for are either permitted or disabled crashes. to enhance security. Windows Firewall Turned on by default, the built-in Reduces the risk Windows Firewall helps increase of network and computer security from startup Internet-based to shutdown. attacks. Feature Description Benefit Windows Security Center Easily manage security resources Easily change with this single, unified view of settings and key settings, tools, and access to identify security resources. Attachment Manager Isolates issues. potentially unsafe Helps provide attachments during the opening protection from process. viruses spread through Outlook Express, Windows Messenger, and Internet Explorer. Data Execution Prevention Helps prevent certain types of Reduces the risk malicious code from attacking of buffer and overwhelming a computer’s overruns. memory. Windows Firewall Exception List Helps administrators better Increases manage applications and static application port exceptions by allowing only compatibility with ports needed by an application to Windows be open. Windows Firewall Application and Easily Port Restrictions Firewall. configure applications Helps reduce the and ports to receive network potential traffic only with a source address network-based from any location, the local attacks. subnet only, or from specific IP for Feature Description Benefit addresses. Easy to Use Fresh visual design While maintaining the core of Allows the most Windows 2000, Windows XP common tasks to Professional has a fresh visual be exposed easily, design. Common tasks have helping users get been consolidated and the most of out of simplified, and new visual cues Windows XP have been added to help users Professional. navigate their computers more easily. Administrators or end users can choose this updated user interface or the classic Windows 2000 interface with the click of a button. Adaptive user environment Adapts to the way an individual A cleaner work user works. With a redesigned environment Start menu, the most frequently allows the user to used applications are shown be more efficient. first. When you open multiple Users can find the files in the same application, crucial data and (such as multiple the e-mail applications they messages in Microsoft need quickly and Outlook messaging and easily. All of collaboration client) the open these settings can windows will be consolidated be under a single task bar button. using controlled Group Feature Description Benefit To remove some of the clutter Policy, so IT from the notification area, items administrators can that are not being used will be decide what hidden. All of these features can features are most be set using Group Policy. appropriate for their environments. Context-sensitive task menus When a file is selected in Common tasks Windows Explorer, a dynamic that were hard to menu appears. This menu lists find in previous tasks that are appropriate for the versions of type of file selected. are Windows exposed for easy access. Integrated CD burning Support for burning CDs on CD- Archiving R and CD-RW integrated into drives data is onto CD is now as Windows easy as saving to a Explorer. floppy disk, and does not require an expensive third-party solution. Easily publish information to the Files and folders can be easily Users will be able Web published to any Web service to that uses the WebDAV protocol. publish important information to Web servers on Feature Description Benefit the company's intranet. A single computer desktop can Users will be able Dual view be displayed on two monitors to maximize their driven off of a single display productivity by adapter. With a laptop computer, working on a user could run the internal multiple screens, LCD display as well as an while removing external monitor. A variety of the need for high-end display adapters will multiple CPUs. support this functionality for desktops. Helps users and administrators Enables users to Troubleshooters configure, optimize, and be more self- troubleshoot numerous Windows sufficient, XP Professional functions. resulting in greater productivity, fewer help desk calls, and better customer service. Revolutionizes the Way Remote Users Work Remote Desktop Allows users to create a virtual Allows users to session onto their desktop access all of their computers using the Microsoft data and Feature Description Remote Benefit Desktop Protocol applications (RDP). housed on their desktop computers from another computer running Windows 95 or later that is connected to their machine via a network. Credential Manager A secured store for password Users who are not information. It allows users to connected to a input user names and passwords domain, or who once, and then have the system need automatically supply information for to access that resources in subsequent multiple domains visits. without trust relationships, will be able to easily access network resources. Offline Files and Folders A user can specify which Users can work network-based files and folders with documents she needs when she disconnects while from the network. Offline disconnected from folders can now be encrypted to the network in the provide the highest level of same manner they Feature Description Benefit security. do when they're connected. Clear Type A new text display technology Microsoft that triples resolution the horizontal ClearType display available for technology offers rendering text through software. a clearer display of text on a Liquid Crystal Display (LCD) screen. Differences between DOS and WINDOWS: All of our programs work just fine on 32-bit Windows systems! They are not bloated like Windows programs. They're really nice because they run very fast, do not write to the registry, take only one click to remove, and use only KB's of RAM. The terminology, and the mechanics, surrounding it has changed, but DOS still exists on all current Windows operating systems, even if it seems to be hidden on some. What used to be the "MS-DOS Prompt" has become, on some systems, the "Command Prompt." Back when DOS was King, individual printer / add-on vendors were responsible for making their hardware work with DOS. Now, things have changed. The Windows operating system bears the brunt of responsibility. This is good - with the advent of "plug and play," things are better for everyone. Now, due to differences in how printers are "tied" to the operating system in DOS and in Windows, there are differences in how you print data files in a Windows system. DOS programs generally expect themselves to be the only program running on your computer, so they will directly manipulate the hardware, such as writing to the disk or displaying graphics on the screen. They may also be dependent on timing, since the computer won't be doing anything else to slow them down. Many games fall into this category. Windows programs, on the other hand, realize that they must share your computer with other Windows programs. MS-DOS (MicroSoft Disk Operating System) is a CLI (Command-Line Interface),while Windows is a GUI (Graphical User Interface). Experiment no.-1(b) Aim:-To study the details of UNIX and Linux operating systems. Operating System:An operating system (OS) is a resource manager. It takes the form of a set of software routines that allow users and application programs to access system resources (e.g. the CPU, memory, disks, modems, printers, network cards etc.) in a safe, efficient and abstract way. For example, an OS ensures safe access to a printer by allowing only one application program to send data directly to the printer at any one time. An OS encourages efficient use of the CPU by suspending programs that are waiting for I/O operations to complete to make way for programs that can use the CPU more productively. An OS also provides convenient abstractions (such as files rather than disk locations) which isolate application programmers and users from the details of the underlying hardware. Fig. 1.1: General operating system architecture Fig. 1.1 presents the architecture of a typical operating system and shows how an OS succeeds in presenting users and application programs with a uniform interface without regard to the details of the underlying hardware. We see that: The operating system kernel is in direct control of the underlying hardware. The kernel provides low-level device, memory and processor management functions (e.g. dealing with interrupts from hardware devices, sharing the processor among multiple programs, allocating memory for programs etc.) Basic hardware-independent kernel services are exposed to higher-level programs through a library of system calls (e.g. services to create a file, begin execution of a program, or open a logical network connection to another computer). Application programs (e.g. word processors, spreadsheets) and system utility programs (simple but useful application programs that come with the operating system, e.g. programs which find text inside a group of files) make use of system calls. Applications and system utilities are launched using a shell (a textual command line interface) or a graphical user interface that provides direct user interaction. Operating systems (and different flavours of the same operating system) can be distinguished from one another by the system calls, system utilities and user interface they provide, as well as by the resource scheduling policies implemented by the kernel. A Brief History of UNIX:In the late 1960s, researchers from General Electric, MIT and Bell Labs launched a joint project to develop an ambitious multi-user, multi-tasking OS for mainframe computers known as MULTICS (Multiplexed Information and Computing System). MULTICS failed (for some MULTICS enthusiasts "failed" is perhaps too strong a word to use here), but it did inspire Ken Thompson, who was a researcher at Bell Labs, to have a go at writing a simpler operating system himself. He wrote a simpler version of MULTICS on a PDP7 in assembler and called his attempt UNICS (Uniplexed Information and Computing System). Fig. 1.2: Simplified UNIX FamilyTree Because memory and CPU power were at a premium in those days, UNICS (eventually shortened to UNIX) used short commands to minimize the space needed to store them and the time needed to decode them - hence the tradition of short UNIX commands we use today, e.g. ls, cp, rm, mv etc. Ken Thompson then teamed up with Dennis Ritchie, the author of the first C compiler in 1973. They rewrote the UNIX kernel in C - this was a big step forwards in terms of the system's portability - and released the Fifth Edition of UNIX to universities in 1974. The Seventh Edition, released in 1978, marked a split in UNIX development into two main branches: SYSV (System 5) and BSD (Berkeley Software Distribution). BSD arose from the University of California at Berkeley where Ken Thompson spent a sabbatical year. Its development was continued by students at Berkeley and other research institutions. SYSV was developed by AT&T and other commercial companies. UNIX flavours based on SYSV have traditionally been more conservative, but better supported than BSD-based flavours. The latest incarnations of SYSV (SVR4 or System 5 Release 4) and BSD Unix are actually very similar. Some minor differences are to be found in file system structure, system utility names and options and system call libraries as Feature Typical SYSV Typical BSD kernel name /unix /vmunix boot init /etc/rc.d directories mounted FS /etc/mnttab default shell sh, ksh /etc/rc.* files /etc/mtab csh, tcsh FS block size 512 bytes->2K 4K->8K print subsystem lp, lpstat, cancel lpr, lpq, lprm echo command echo "\c" echo -n ps command ps -fae ps -aux multiple wait poll select memset, memcpy bzero, bcopy (no new line) syscalls memory access syscalls Fig. 1.3: Differences between SYSV and BSD Architecture of UNIX:- shown in The architecture of UNIX consists of the following main components: Kernel : The core of the UNIX system. Loaded at system start up (boot). Memory-resident control program. o Manages the entire resources of the system, presenting them to you and every other user as a coherent system. Provides service to user applications such as device management, process scheduling, etc. o Example functions performed by the kernel are: managing the machine's memory and allocating it to each process. scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible. accomplishing the transfer of data from one part of the machine to another interpreting and executing instructions from the shell enforcing file access permissions o You do not need to know anything about the kernel in order to use a UNIX system. Shell o Whenever you login to a Unix system you are placed in a shell program. The shell's prompt is usually visible at the cursor's position on your screen. To get your work done, you enter commands at this prompt. o The shell is a command interpreter; it takes each command and passes it to the operating system kernel to be acted upon. It then displays the results of this operation on your screen. o Several shells are usually available on any UNIX system, each with its own strengths and weaknesses. o Different users may use different shells. Initially, your system adminstrator will supply a default shell, which can be overridden or changed. The most commonly available shells are: Bourne shell (sh) C shell (csh) Korn shell (ksh) TC Shell (tcsh) Bourne Again Shell (bash) o Each shell also includes its own programming language. Command files, called "shell scripts" are used to accomplish a series of tasks. Utilities o UNIX provides several hundred utility programs, often referred to as commands. o Accomplish universal functions editing file maintenance printing sorting programming support online info etc. o Modular: single functions can be grouped to perform more complex tasks Logging into (and out of) UNIX Systems:Text-based (TTY) terminals: When you connect to a UNIX computer remotely (using telnet) or when you log in locally using a text-only terminal, you will see the prompt: login: At this prompt, type in your usename and press the enter/return/ key. Remember that UNIX is case sensitive (i.e. Will, WILL and will are all different logins). You should then be prompted for your password: login: will password: Type your password in at the prompt and press the enter/return/ key. Note that your password will not be displayed on the screen as you type it in. If you mistype your username or password you will get an appropriate message from the computer and you will be presented with the login: prompt again. Otherwise you should be presented with a shell prompt which looks something like this: $ To log out of a text-based UNIX shell, type "exit" at the shell prompt (or if that doesn't work try "logout"; if that doesn't work press ctrl-d). Graphical terminals: If you're logging into a UNIX computer locally, or if you are using a remote login facility that supports graphics, you might instead be presented with a graphical prompt with login and password fields. Enter your user name and password in the same way as above (N.B. you may need to press the TAB key to move between fields). Once you are logged in, you should be presented with a graphical window manager that looks similar to the Microsoft Windows interface. To bring up a window containing a shell prompt look for menus or icons which mention the words "shell", "xterm", "console" or "terminal emulator". To log out of a graphical window manager, look for menu options similar to "Log out" or "Exit". Changing your password: One of the things you should do when you log in for the first time is to change your password. The UNIX command to change your password is passwd: $ passwd The system will prompt you for your old password, then for your new password. To eliminate any possible typing errors you have made in your new password, it will ask you to reconfirm your new password. Remember the following points when choosing your password: o Avoid characters which might not appear on all keyboards, e.g. '£'. o The weakest link in most computer security is user passwords so keep your password a secret, don't write it down and don't tell it to anyone else. Also avoid dictionary words or words related to your personal details (e.g. your boyfriend or girlfriend's name or your login). o Make it at least 7 or 8 characters long and try to use a mix of letters, numbers and punctuation. UNIX File System:The UNIX operating system is built around the concept of a filesystem which is used to store all of the information that constitutes the long-term state of the system. This state includes the operating system kernel itself, the executable files for the commands supported by the operating system, configuration information, temporary workfiles, user data, and various special files that are used to give controlled access to system hardware and operating system functions. Every item stored in a UNIX file system belongs to one of four types: 1. Ordinary files : Ordinary files can contain text, data, or program information. Files cannot contain other files or directories. Unlike other operating systems, UNIX filenames are not broken into a name part and an extension part (although extensions are still frequently used as a means to classify files). Instead they can contain any keyboard character except for '/' and be up to 256 characters long (note however that characters such as *,?,# and & have special meaning in most shells and should not therefore be used in filenames). Putting spaces in filenames also makes them difficult to manipulate - rather use the underscore '_'. 2. Directories: Directories are containers or folders that hold files, and other directories. 3. Devices: To provide applications with easy access to hardware devices, UNIX allows them to be used in much the same way as ordinary files. There are two types of devices in UNIX - block-oriented devices which transfer data in blocks (e.g. hard disks) and character-oriented devices that transfer data on a byte-by-byte basis (e.g. modems and dumb terminals). 4. Links: A link is a pointer to another file. There are two types of links - a hard link to a file is indistinguishable from the file itself. A soft link (or symbolic link) provides an indirect pointer or shortcut to a file. A soft link is implemented as a directory file entry containing a pathname. Typical UNIX Directory Structure:The UNIX filesystem is laid out as a hierarchical tree structure which is anchored at a special top-level directory known as the root (designated by a slash '/'). Because of the tree structure, a directory can have many child directories, but only one parent directory. Fig. 2.1 illustrates this layout. Fig. 2.1: Part of a typical UNIX filesystem tree To specify a location in the directory hierarchy, we must specify a path through the tree. The path to a location can be defined by an absolute path from the root /, or as a relative path from the current working directory. To specify a path, each directory along the route from the source to the destination must be included in the path, with each directory in the sequence being separated by a slash. To help with the specification of relative paths, UNIX provides the shorthand "." for the current directory and ".." for the parent directory. For example, the absolute path to the directory "play" is /home/will/play, while the relative path to this directory from "zeb" is ../will/play. Fig. 2.2 shows some typical directories you will find on UNIX systems and briefly describes their contents. Note that these although these subdirectories appear as part of a seamless logical filesystem, they do not need be present on the same hard disk device; some may even be located on a remote machine and accessed across a network. Directory Typical Contents / The "root" directory /bin Essential low-level system utilities /usr/bin Higher-level system utilities and application programs /sbin Superuser system utilities (for performing system administration tasks) Program libraries (collections of system calls that can be included in /lib programs by a compiler) for low-level system utilities /usr/lib Program libraries for higher-level user programs /tmp Temporary file storage space (can be used by any user) /home or /homes User home directories containing personal file space for each user. Each directory is named after the login of the user. /etc UNIX system configuration and information files /dev Hardware devices A pseudo-filesystem which is used as an interface to the kernel. /proc Includes a sub-directory for each active program (or process). Fig. 2.2: Typical UNIX directories When you log into UNIX, your current working directory is your user home directory. You can refer to your home directory at any time as "~" and the home directory of other users as "~<login>". So ~will/play is another way for user jane to specify an absolute path to the directory /homes/will/play. User will may refer to the directory as ~/play. Main Features of UNIX: multi-user more than one user can use supported via terminals (serial or network connection) the machine at a time multi-tasking more than one program can be run at a time hierarchical directory structure to support the organisation and maintenance of files portability only the tools kernel for ( <10%) program written in assembler development a wide range of support tools (debuggers, compilers) Multi-User Operating Systems A multi-user operating system allows more than one user to share the same computer system at the same time. It does this by time-slicing the computer processor at regular intervals between the various users. In the above example, there are five users which share the processor hardware and main memory on a time basis. We start off by giving the first user (which we will call Sophia) the processor hardware, and run Sophia's program for 1/5th of a second. When the time is up, we intervene, save Sophia's program state (program code and data) and then start running the second users program (for 1/5th of a second). This process continues till we eventually get back to user Sophia. To continue running Sophia's program, we restore the programs code and data and then run for 1/5th of a second. This switching between user programs is done by part of the kernel. To switch from one program to another requires, a regular timed interrupt event (provided by a clock) saving the interrupted programs state and data restoring the next programs state and data running that program till the next timed interrupt occurs Main system memory is divided into portions for the operating system and user programs. As you can see in the above diagram, the kernel space is kept separate from user programs. In UNIX systems, each user is presented with a shell. This is a program which displays the users prompt, handles user input and displays output on the terminal. The shell program provides a mechanism for customizing each user's setup requirements, and storing this information for reuse (in a file called .profile). When the UNIX system starts up, it also starts a system process which monitors the state of each terminal input line. Whenever a user logs in and their password is validated the UNIX system associates the shell program with that terminal. Multi-Tasking Operating Systems Multi-tasking operating systems permit the use of more than one program to run at once. It does this in the same way as a multi-user system, by rapidly switching the processor between the various programs. OS/2 and Windows 95 are examples of multi-tasking single-user operating system. UNIX is an example of a multi-tasking multi-user operating system. A multi-user system is also a multi-tasking system. This means that a user can run more than one program at once, using key selection to switch between them. Multi-tasking systems support foreground and background tasks. A foreground task is one that the user interacts directly with using the keyboard and screen. A background task is one that runs in the background (it does not have access to the keyboard). Background tasks are usually used for printing or backups. The role of the operating system is to keep track of all the programs, allocating resources like disks, memory and printer queues as required. History of Linux:Linux is a free open source UNIX OS for PCs that was originally developed in 1991 by Linus Torvalds, a Finnish undergraduate student. Linux is neither pure SYSV or pure BSD. Instead, incorporates some features from each (e.g. SYSV-style startup files but BSD-style file system layout) and aims to conform with a set of IEEE standards called POSIX (Portable Operating System Interface). To maximise code portability, it typically supports SYSV, BSD and POSIX system calls (e.g. poll, select, memset, memcpy, bzero and bcopy are all supported). The open source nature of Linux means that the source code for the Linux kernel is freely available so that anyone can add features and correct deficiencies. This approach has been very successful and what started as one person's project has now turned into a collaboration of hundreds of volunteer developers from around the globe. The open source approach has not just successfully been applied to kernel code, but also to application programs for Linux. As Linux has become more popular, several different development streams or distributions have emerged, e.g. Redhat, Slackware, Mandrake, Debian, and Caldera. A distribution comprises a prepackaged kernel, system utilities, GUI interfaces and application programs. Redhat is the most popular distribution because it has been ported to a large number of hardware platforms (including Intel, Alpha, and SPARC), it is easy to use and install and it comes with a comprehensive set of utilities and applications including the X Windows graphics system, GNOME and KDE GUI environments, and the StarOffice suite (an open source MS-Office clone for Linux). Hardware requirements: To run LINUX on system following are some basic requirements to be fulfilled in terms of processing power, memory size and disk space. We need 16 bit microprocessor and about 3MB of RAM. The hard disk space should be 80MB or more. There is also a need of system administrator. Architecture of the Linux Operating System:Linux has all of the components of a typical OS (at this point you might like to refer back to Fig 1.1): Kernel: The Linux kernel includes device driver support for a large number of PC hardware devices (graphics cards, network cards, hard disks etc.), advanced processor and memory management features, and support for many different types of filesystems (including DOS floppies and the ISO9660 standard for CDROMs). In terms of the services that it provides to application programs and system utilities, the kernel implements most BSD and SYSV system calls, as well as the system calls described in the POSIX.1 specification. The kernel (in raw binary form that is loaded directly into memory at system startup time) is typically found in the file /boot/vmlinuz, while the source files can usually be found in /usr/src/linux. Shells and GUIs: Linux supports two forms of command input: through textual command line shells similar to those found on most UNIX systems (e.g. sh - the Bourne shell, bash - the Bourne again shell and csh - the C shell) and through graphical interfaces (GUIs) such as the KDE and GNOME window managers. If you are connecting remotely to a server your access will typically be through a command line shell. System Utilities: Virtually every system utility that you would expect to find on standard implementations of UNIX (including every system utility described in the POSIX.2 specification) has been ported to Linux. This includes commands such as ls, cp, grep, awk, sed, bc, wc, more, and so on. These system utilities are designed to be powerful tools that do a single task extremely well (e.g. grep finds text inside files while wc counts the number of words, lines and bytes inside a file). Users can often solve problems by interconnecting these tools instead of writing a large monolithic application program. Like other UNIX flavours, Linux's system utilities also include server programs called daemons which provide remote network and administration services (e.g. telnetd and sshd provide remote login facilities, lpd provides printing services, httpd serves web pages, crond runs regular system administration tasks automatically). A daemon (probably derived from the Latin word which refers to a beneficient spirit who watches over someone, or perhaps short for "Disk And Execution MONitor") is usually spawned automatically at system startup and spends most of its time lying dormant (lurking?) Application waiting for some event to occur. programs: Linux distributions typically come with several useful application programs as standard. Examples include the emacs editor, xv (an image viewer), gcc (a C compiler), g++ (a C++ compiler), xfig (a drawing package), latex (a powerful typesetting language) and soffice (StarOffice, which is an MS-Office style clone that can read and write Word, Excel and PowerPoint files). Redhat Linux also comes with rpm, the Redhat Package Manager which makes it easy to install and uninstall application programs. Directory structure of Linux:As you may have noticed, Linux organizes its files differently from Windows. First the directory structure may seem unlogical and strange and you have no idea where all the programs, icons, config files, and others are. This tuXfile will take you to a guided tour through the Linux file system. This is by no means a complete list of all the directories on Linux, but it shows you the most interesting places in your file system. </> The root directory. The starting point of your directory structure. This is where the Linux system begins. Every other file and directory on your system is under the root directory. Usually the root directory contains only subdirectories, so it's a bad idea to store single files directly under root. Don't confuse the root directory with the root user account, root password (which obviously is the root user's password) or root user's home directory. < /boot > As the name suggests, this is the place where Linux keeps information that it needs when booting up. For example, this is where the Linux kernel is kept. If you list the contents of /boot, you'll see a file called vmlinuz - that's the kernel. < /etc > The configuration files for the Linux system. Most of these files are text files and can be edited by hand. Some interesting stuff in this directory: /etc/inittab A text file that describes what processes are started at system bootup and during normal operation. For example, here you can determine if you want the X Window System to start automatically at bootup, and configure what happens when a user presses Ctrl+Alt+Del. /etc/fstab This file contains descriptive information about the various file systems and their mount points, like floppies, cdroms, and so on. /etc/passwd A file that contains various pieces of information for each user account. This is where the users are defined. < /bin, /usr/bin > These two directories contain a lot of programs (binaries, hence the directory's name) for the system. The /bin directory contains the most important programs that the system needs to operate, such as the shells, ls, grep, and other essential things. /usr/bin in turn contains applications for the system's users. However, in some cases it really doesn't make much difference if you put the program in /bin or /usr/bin. < /sbin, /usr/sbin > Most system administration programs are stored in these directories. In many cases you must run these programs as the root user. < /usr > This directory contains user applications and a variety of other things for them, like their source codes, and pictures, docs, or config files they use. /usr is the largest directory on a Linux system, and some people like to have it on a separate partition. Some interesting stuff in /usr: /usr/doc Documentation for the user apps, in many file formats. /usr/share Config files and graphics for many user apps. /usr/src Source code files for the system's software, including the Linux kernel. /usr/include Header files for the C compiler. The header files define structures and constants that are needed for building most standard programs. A subdirectory under /usr/include contains headers for the C++ compiler. /usr/X11R6 The X Window System and things for it. The subdirectories under /usr/X11R6 may contain some X binaries themselves, as well as documentation, header files, config files, icons, sounds, and other things related to the graphical programs. < /usr/local > This is where you install apps and other files for use on the local machine. If your machine is a part of a network, the /usr directory may physically be on another machine and can be shared by many networked Linux workstations. On this kind of a network, the /usr/local directory contains only stuff that is not supposed to be used on many machines and is intended for use at the local machine only. Most likely your machine isn't a part of a network like this, but it doesn't mean that /usr/local is useless. If you find interesting apps that aren't officially a part of your distro, you should install them in /usr/local. For example, if the app would normally go to /usr/bin but it isn't a part of your distro, you should install it in /usr/local/bin instead. When you keep your own programs away from the programs that are included in your distro, you'll avoid confusion and keep things nice and clean. < /lib > The shared libraries for programs that are dynamically linked. The shared libraries are similar to DLL's on Winblows. < /home > This is where users keep their personal files. Every user has their own directory under /home, and usually it's the only place where normal users are allowed to write files. You can configure a Linux system so that normal users can't even list the contents of other users' home directories. This means that if your family members have their own user accounts on your Linux system, they won't see all the w4r3z you keep in your home directory. ;-) < /root > The superuser's (root's) home directory. Don't confuse this with the root directory (/) of a Linux system. < /var > This directory contains variable data that changes constantly when the system is running. Some interesting subdirectories: /var/log A directory that contains system log files. They're updated when the system runs, and checking them out can give you valuable info about the health of your system. If something in your system suddenly goes wrong, the log files may contain some info about the situation. /var/mail Incoming and outgoing mail is stored in this directory. /var/spool This directory holds files that are queued for some process, like printing. < /tmp > Programs can write their temporary files here. < /dev > The devices that are available to a Linux system. Remember that in Linux, devices are treated like files and you can read and write devices like they were files. For example, /dev/fd0 is your first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on. All the devices that a Linux kernel can understand are located under /dev, and that's why it contains hundreds of entries. < /mnt > This directory is used for mount points. The different physical storage devices (like the hard disk drives, floppies, CD-ROM's) must be attached to some directory in the file system tree before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called the mount point. The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy drive, /mnt/cdrom for the CD-ROM, and so on. However, you're not forced to use the /mnt directory for this purpose, you can use whatever directory you wish. Actually in some distros, like Debian and SuSE, the default is to use /floppy and /cdrom as mount points instead of directories under /mnt. < /proc > This is a special directory. Well, actually /proc is just a virtual directory, because it doesn't exist at all! It contains some info about the kernel itself. There's a bunch of numbered entries that correspond to all processes running on the system, and there are also named entries that permit access to the current configuration of the system. Many of these entries can be viewed. < /lost+found > Here Linux keeps the files that it restores after a system crash or when a partition hasn't been unmounted before a system shutdown. This way you can recover files that would otherwise have been lost. Features of Linux: multitasking: several programs running at the same time. multiuser: several users on the same machine at the same time (and no two-user licenses!). multiplatform: runs on many different CPUs, not just Intel. multiprocessor: SMP support is available on the Intel and SPARC platforms (with work currently in progress on other platforms), and Linux is used in several loosely-coupled MP applications, including Beowulf systems and the Fujitsu AP1000+ SPARC-based supercomputer. multithreading: has native kernel support for multiple independent threads of control within a single process memory space. runs in protected mode on the 386. has memory protection between processes, so that one program can't bring the whole system down. demand loads executables: Linux only reads from disk those parts of a program that are actually used. shared copy-on-write pages among executables. This means that multiple process can use the same memory to run in. When one tries to write to that memory, that page (4KB piece of memory) is copied somewhere else. Copy-on-write has two benefits: increasing speed and decreasing memory use. virtual memory using paging (not swapping whole processes) to disk: to a separate partition or a file in the filesystem, or both, with the possibility of adding more swapping areas during runtime (yes, they're still called swapping areas). A total of 16 of these 128 MB (2GB in recent kernels) swapping areas can be used at the same time, for a theoretical total of 2 GB of useable swap space. It is simple to increase this if necessary, by changing a few lines of source code. a unified memory pool for user programs and disk cache, so that all free memory can be used for caching, and the cache can be reduced when running large programs. dynamically linked shared libraries (DLL's), and static libraries too, of course. does core dumps for post-mortem analysis, allowing the use of a debugger on a program not only while it is running but also after it has crashed. mostly compatible with POSIX, System V, and BSD at the source level. through an iBCS2-compliant emulation module, mostly compatible with SCO, SVR3, and SVR4 at the binary level. all source code is available, including the whole kernel and all drivers, the development tools and all user programs; also, all of it is freely distributable. Plenty of commercial programs are being provided for Linux without source, but everything that has been free, including the entire base operating system, is still free. POSIX job control. pseudoterminals (pty's). 387-emulation in the kernel so that programs don't need to do their own math emulation. Every computer running Linux appears to have a math coprocessor. Of course, if your computer already contains an FPU, it will be used instead of the emulation, and you can even compile your own kernel with math emulation removed, for a small memory gain. support for many national or customized keyboards, and it is fairly easy to add new ones dynamically. multiple virtual consoles: several independent login sessions through the console, you switch by pressing a hot-key combination (not dependent on video hardware). These are dynamically allocated; you can use up to 64. Supports several common filesystems, including minix, Xenix, and all the common system V filesystems, and has an advanced filesystem of its own, which offers filesystems of up to 4 TB, and names up to 255 characters long. transparent access to MS-DOS partitions (or OS/2 FAT partitions) via a special filesystem: you don't need any special commands to use the MS-DOS partition, it looks just like a normal Unix filesystem (except for funny restrictions on filenames, permissions, and so on). MS-DOS 6 compressed partitions do not work at this time without a patch (dmsdosfs). VFAT (WNT, Windows 95) support and FAT-32 is available in Linux 2.0 special filesystem called UMSDOS which allows Linux to be installed on a DOS filesystem. read-only HPFS-2 support for OS/2 2.1 HFS (Macintosh) file system support is available separately as a module. CD-ROM filesystem which reads all standard formats of CD-ROMs. TCP/IP networking, including ftp, telnet, NFS, etc. Appletalk server Netware client and server Lan Manager/Windows Native (SMB) client and server Many networking protocols: the base protocols available in the latest development kernels include TCP, IPv4, IPv6, AX.25, X.25, IPX, DDP (Appletalk), Netrom, and others. Stable network protocols included in the stable kernels currently include TCP, IPv4, IPX, DDP, and AX.25. Experiment no.-2 Aim:- Installation of Linux operating system. Steps to be followed for installing Linux on your system are as follows: We normally begin the installation process by booting off the first CD of the distribution. To do this, you need to have the machine switched on, so that you can open your CD-ROM drive. Insert Disk 1 of your Red Hat Linux distribution into your CD-ROM drive, and then restart the machine. The installation process should start automatically, as soon as the computer’s poweron self test is complete: The dialog asks you to select whether to install in graphical or text mode. Text mode is suitable in situations where a minimal configuration is required, or where there is a problem with the display. We will conduct our installation in graphical mode, so just press the Enter key. When you’ve selected the mode of installation, the boot program proceeds by displaying a flurry of messages on the screen. Don’t be alarmed by this – this is perfectly normal in a Linux operating system boot up. When Linux boots up, it stays in text mode briefly to perform a few routine checks and processes, and then launches the installation in graphical mode after that. In version 9, Red Hat has introduced a media test module into the installation process. The purpose of the media test module is to eliminate one of the most frequent sources of installation problems – defects in the CDs themselves. As shown below, the module asks you whether you would like to test the CD media before proceeding with the installation: This module will check your installation CDs and tell you if it finds any problems reading their contents. If you’re installing from CDs included as part of Red Hat’s retailed box set, then your CDs are likely to be fine. But if you’ve downloaded CD images and burned your own disks, then it’s definitely a good idea to use this module, to check the validity of your disks. Since the first disk is already in the drive, you can simply press Test to start the media test of the disk right away. The progress of the test is shown like this: When Disk 1 has been tested, you will be prompted as shown below, which asks you whether you want to insert any other disks for checking: Having tested all the CDs (or skipped the test altogether), the Red Hat Linux installer program – called Anaconda – begins, launching the graphical installer. It tries to detect the video card, monitor, and mouse, as shown below: Then it launches into the GUI install screen, as shown here. Press Next (in the bottom right corner) to continue to the next screen Red Hat supports many languages other than English during the installation process. Those more comfortable with their native language can use this screen to select the language appropriate for their use: At this stage, the installation will look for an existing version of Red Hat Linux on your machine. If it finds one, it will invite you to choose between upgrading the existing version and replacing it. An upgrade will take less time, and allow you to preserve any existing data on your drives while bringing the software packages up to date with the latest distribution. By contrast, a replacement may overwrite your existing data but will provide a completely up-todate installation. Here, we’ll opt for a completely new installation: The next screen allows you to organize the storage space on your machine’s hard disk: The space on your hard disk is normally divided into sections, called partitions, for better management of the space. Dividing a hard disk into partitions can help you segregate the available disk space according to its usage. For example, you might choose to dedicate one partition solely to your executable programs, and to set aside another partition just to hold your work-related data files. This type of organization has the advantage that when you are upgrading your system, you can ask Red Hat Linux to leave the data partition of your disk alone, and upgrade only the software packages installed in the other partitions. The optimum number and size of partitions on your disk depends on many factors – the overall disk size, the purpose of each partition, and so on. Such decisions are usually made on anticipated future requirements and data organization structure, and often rely heavily on previous experience. However, Red Hat Linux makes this decision simpler by offering an automatic partitioning option, which creates an arrangement of partitions based on your install type preferences. So, if you chose the Personal Desktop installation type in the previous screen, your hard disk can be automatically reorganized into partitions that are likely to be used for day-to-day personal work. Red Hat Linux also offers an option for creating partitions manually, and if you feel comfortable and confident with creating your own partitions, then feel free to do so. However, it is normally safe enough to accept the default automatic partition option, and that’s what we’ll do here. In the next screen, Red Hat Linux allows you to set various boot loader options. A boot loader is normally required when you have multiple operating systems on the hard disk, and an option (at boot time) for choosing the operating system to boot from. Red Hat provides the GRUB boot loader for this purpose. The installation process now takes you into the network configuration section. Your network configuration checklist will come in handy in this section: If you choose to do it now, you can use your network configuration checklist to fill up the entries on the screen. First, click on the Edit button at the top section of the screen to bring up the network device configuration dialog box: While you’re on this screen, you can also set the DNS hostname and the DNS servers (which you should have noted in your network configuration checklist). You can specify these values in the appropriate entry boxes near the bottom of the screen. At the end of your configuration, your screen should look something like this: By default, the installation process creates a single administrative user account for your machine, called root. Whenever you use the system, you do so through the context of a user account, and that to do so you log in by specifying the user account’s name and a password. Every user account on the system has its own password, and the root user (or superuser) is no different in this respect. In this screen, you are asked to supply the root user’s password. Of course, you are asked to type the password twice, to confirm that you didn’t mistype the first time. Type the password carefully each time to make sure you type it correctly. You might encounter a message that tells you that the password is too short or too simple. This is a security feature, designed to remind you of the importance of choosing password. EXPERIMENT 3 AIM : TO USE BASIC COMMAND IN LINUX. 1. echo : echo command is built in shell command , which used to display the value of a variable or print a line of text. Echo command plays a important role in building a shell script. Syntax : #echo [option] [string] 2. tput : You can move the cursor to a specific row and column using tput cup. Following example positions the cursor at row 2 and column 3. syntax : $ tput cup 2 3 3. tput lines : Following displays number of lines of your terminal screen. syntax : $ tput lines 4. tput cols : To display the number of columns of your terminal screen, do the following. syntax : $ tput cols 5. tput clear : If you are in middle of the terminal screen, tput clear will clear the screen and put you at the top of the terminal screen. syntax : $ tput clear 6. mkdir : Mkdir is a command for creating directories in Linux system. This command is a built-in command. syntax : $ mkdir 7. cd : The Change directory (cd) command is one of the simple commands in Unix (or Linux) and it is very easy to use. The cd command is used to change from the current directory to another directory. syntax : cd [directory] 8. cd .. : Change to parent directory: syntax : $ cd .. 9. pwd : pwd - print working directory, is a Linux command to get the current working directory. syntax : $ pwd [option] 10. rmdir : Unix provides rmdir and rm commands to remove the directories and files. syntax : rmdir [options] directories EXPERIMENT 4 AIM : TO USE LS, OPTIONS WITH LS, CAT, OPTIONS WITH CAT. 1. LS Lists the contents of a directory. Syntax : ls[OPTION]...[FILE]... 2. LS --ALL ls -a option flag lists all files including hidden files starting with '.' Syntax : $ls -a [options] [file|dir ] 3. LS -L ls -l option flag lists with long listing format. Syntax : $ ls -1[options] [file|dir] 4. LS -R ls command when used with option -R, it will display the contents of the sub-directories too. Syntax: ls-R 5. CAT cat is one of the most commonly-used commands in Linux. It can be used to: Display text files Copy text files into a new document Append the contents of a text file to the end of another text file, combining them EXAMPLE OF CAT COMMAND :- -> Read the contents of file.txt and display them on the screen. syntax: cat file.txt -> Reads the contents of file1.txt and file2.txt, and displays them in order on the terminal screen. syntax : cat file1.txt file2.txt ->Read the contents of file.txt and write them to newfile.txt, overwriting anythingnewfile.txt previously contained. If newfile.txt does not exist, it will be created. syntax: cat file.txt> newfile.txt -> Read the contents of file.txt and append them to the end of another-file.txt. Ifanotherfile.txt does not exist, it will be created. syntax: cat file.txt>> another-file.txt EXPERIMENT 5 AIM : TO USE MAN , WHATIS AND COMMANDS TO SHOW DATE , TIME OF THE SYSTEM. 1. MAN The man command is used to format and display the man pages. syntax : man [option(s)] keyword(s) 2. WHATIS searches the database for brief descriptions of command-line programs. Syntax : $ whatis keyword 3. DATE + %T Display time only. syntax : $ date +"%T" 4. DATE + % h display only month in character syntax : $ date +"%h" 5. DATE + %m display only month , of year in numerical. syntax : $ date +"%m" 6. DATE + %y display current year.(last two digit) syntax : $ date +"%y" 7. DATE +"%h%y" display combine month and year. syntax : $ date +"%h%y" EXPERIMENT NO:- 06 AIM : To Use Copy , Move , Comp and Wc Command in linux. 1. COPY : To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name. Copy File Examples :To make a copy of a file called file.doc in the current directory as newfile.doc, enter: $ cp file.doc newfile.doc Syntax : $ cp [OPTION] SOURCE DEST 2. MOVE : The mv command is used to move or renamefiles. Description :- mv renames file SOURCE to DEST, or moves the SOURCE file (or files) to directory. mv examples :mv myfile.txt destination-directory Syntax : mv [OPTION] . . . [-T] SOURCE DEST 3. CMP : cmp is used to compare two files byte by byte. If a difference is found, it reports the byte and line number where the first difference is found. If no differences are found, by default, cmp returns no output. cmp examples :cmp file1.txt file2.txt syntax : cmp [OPTION] . . . FILE1 [FILE2 [SKIP1 [SKIP2] ] ] 4. WC : wc prints newline, word, and byte counts for eachFILE, and a total if more than one FILE is specified. With no FILE, or when FILE is a dash ("-"), wc operates on standard input. (A word is a non-zero-length sequence of characters delimited by white space.) The options below may be used to select which counts are printed. Counts are always in the following order: newline, word, character, byte, maximum line length. wc examples :wc myfile.txt Displays information about the file myfile.txt. Output will resemble the following: 5 13 57 myfile.txt Where 5 is the number of lines, 13 is the number of words, and 57 is the number of characters. Syntax : WC [OPTION] . . . [FILE] . . . EXPERIMENT NO : 07 AIM : Understanding Pipes and Redirection For the Linux Command. REDIRECTION : Redirection is similar to pipes except using files rather than another program. The standard output for a program is the screen. Using the > (greater than) symbol the output of a program can be sent to a file. Here is a directory listing of dev again but this time redirected to a file called listing.txt 1. STANDARD INPUT : Many commands can accept input from a facility called standard input. By default, standard input gets its contents from the keyboard, but like standard output, it can be redirected. To redirect standard input from a file instead of the keyboard, the "<" character is used like this: sort < file_list.txt In the above example we used the sort command to process the contents of file_list.txt. The results are output on the display since the standard output is not redirected in this example. We could redirect standard output to another file like this: sort < file_list.txt > sorted_file_list.txt 2. STANDARD OUTPUT : Most command line programs that display their results do so by sending their results to a facility called standard output. By default, standard output directs its contents to the display. To redirect standard output to a file, the ">" character is used like this: ls > file_list.txt In this example, the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display. Each time the command above is repeated, file_list.txt is overwritten (from the beginning) with the output of the command ls. If you want the new results to be appended to the file instead, use ">>" like this: ls >> file_list.txt syntax : command-name > file name 3. STANDARD ERROR : On the other hand if you run the script as perl program.pl 2> err.txt, then the 2> symbol will redirect the error channel to the file err.txt. Syntax : command-name 2>> errors.txt PIPELINING : Pipes allow you to funnel the output from one command into another where it will be used as the input. In other words, the standard output from one program becomes the standard input for another. The “more” command takes the standard input and paginates it on the standard output (the screen). This means that if a command displays more information than can be shown on one screen, the “more” program will pause after the first screen full (page) and wait for the user to press SPACE to see the next page or RETURN to see the next line. Here is an example which will list all the files, with details ( ) in the directory and pipe the output to more. The directory should have dozens of files and hence ensure that more needs to paginate. example:ls _l > fileinfo.txt EXPERIMENT NO : 08 AIM : Describe about Process and its Attributes. SPAWMING : Spawn in computing refers to a function that loads and executes a new child process. The current process may wait for the child to terminate or may continue to executeasynchronously. Creating a new subprocess requires enough memory in which both the child process and the current program can execute. PS COMMAND : Reports a snapshot of the status of currently running processes. On every UNIX-like operating system, the process status command (ps) displays information about active processes. Every operating system's version of ps is slightly different, so consult your own documentation for specific options. ps examples :To see every process running on the system, using the standard syntax: ps -e ps -ef ps-eF ps -ely ps syntax : Ps [options] EXPERIMENT NO 09 AIM : FILTER IN LINUX. 1. HEAD : head makes it easy to output the first part of files. head, by default, prints the first 10 lines of each FILE to standard output. With more than one FILE, it precedes each set of output with a header identifying the file name. If no FILE is specified, or when FILE is specified as a dash ("-"), head reads from standard input. examples :head myfile.txt syntax : head [OPTION] . . . [FILE] . . . 2. TAIL : tail outputs the last part, or "tail", of files. tail prints the last 10 lines of each FILE to standard output. With more than one FILE, it precedes each set of output with a header giving the file name. If no FILE is specified, or if FILE is specified as a dash ("-"), tail reads from standard input. examples :tail myfile.txt syntax : tail [OPTION] . . . [FILE] . . . 3.SORT : sort sorts the contents of a text file, line by line. sort is a simple and very useful command which will rearrange the lines in a text file so that they are sorted, numerically and alphabetically. By default, the rules for sorting are: lines starting with a number will appear before lines starting with a letter; lines starting with a letter that appears earlier in the alphabet will appear before lines starting with a letter that appears later in the alphabet; lines starting with a lowercase letter will appear before lines starting with the same letter in uppercase. examples :Let's say you have a file, data.txt, which contains the following ASCII text: apples oranges pears kiwis bananas To sort the lines in this file alphabetically, use the following command: sort data.txt syntax: sort [OPTION] . . . [FILE] . . . 4. CUT : Remove or "cut out" sections of each line of afile or files. Examples :Outputs the third character of every line of the file file.txt, omitting the others cut -c 3 file.txt Outputs the first three characters of every line of the file file.txt, omitting the rest. cut -c 1-3 file.txt syntax : cut [OPTION] . . . [FILE] . . . 5. PASTE : The paste command displays the corresponding lines of multiple files side-by-side. paste writes lines consisting of the sequentially corresponding lines from each FILE, separated by tabs, to the standard output. With no FILE, or when FILE is a dash ("-"), paste reads from standard input. examples:This command would display the contents of file1.txt and file2.txt, side-by-side, with the corresponding lines of each file separated by a tab. paste file1.txt file2.txt syntax : paste [OPTION] . . . [FILE] . . .
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )