0% found this document useful (0 votes)
110 views18 pages

Homework Title/No: 1 Course Code: CAP 614

This document contains a student's homework submission for their CAP 614 course. It includes the student's name, roll number, date of submission, and a declaration that the work is their own. The evaluator will provide comments and mark the submission out of a total mark. The submission contains answers to two questions - the first lists Linux commands for various directory and user tasks, and the second provides a structural overview of the Linux operating system.

Uploaded by

Surendra Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views18 pages

Homework Title/No: 1 Course Code: CAP 614

This document contains a student's homework submission for their CAP 614 course. It includes the student's name, roll number, date of submission, and a declaration that the work is their own. The evaluator will provide comments and mark the submission out of a total mark. The submission contains answers to two questions - the first lists Linux commands for various directory and user tasks, and the second provides a structural overview of the Linux operating system.

Uploaded by

Surendra Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 18

Homework Title/No: 1 Course Code: CAP 614

Course Instructor: Mr. Akash Bhardwaj applicable): NA Date of Allotment: 08-31-2012 SEPT 2012 Students Roll Number D1R07 A03 Declaration: I declare that this term paper is my individual work. I have not copied from any other students work or from any other source except where due acknowledgement is made explicitly in the text, nor has any part been written for me by another person. Students Chauhan Sign: Surendra Course Tutor (if Date of submission: 21 Section No.: D1R07

Evaluators Comments: ___________________________________________________ Marks obtained: ____________ out of __________________

Q1: List various Commands used to perform following operations a) Make your Home Directory your current directory. b) To display who is logged in your system. c) To change password for the current user. d) To move the directory /usr/local to /opt/pgms. e) To list various files and directories in current working directory.

ANSWER:-

A:

- Make your Home Directory your current directory: - Each user has a branch in the `/home' directory for their own files, called their home directory. When you are in a shell, you are always in a directory on the system, and that directory is called the current working directory. cd.. (Double dot) command is used to directly jump to the home directory from current directory or we can say that using this command we can make our home directory our current directory.

B:

- There are four different methods to identify who is on your Linux system.

W command Who command Users command Whoami

To display who is logged in your system: - who command is used to get the list of the usernames who are currently logged in. Output of the who

command contains the following columns: user name, tty number, date and time, machine address.

C: - To change password for the current user: - passwd command is use


to change the paasword for the user.

Using graphical and command base tools to change user password or reset user password. Every user that use your Linux system must have their own password in order to use the system.

Change user password using system-config-users the graphical interface user management tool (root). User Change their own Password using passwd command. User change own password using graphical tool (user).

D: - To move the directory /usr/local to /opt/pgms: - mv command is use


to move the directory from one path to another. Example: - $ mv /usr/local /opt/pgms.

E: - To list various files and directories in current working directory: command is use to list various files and directory in current working directory

ls

Q2: Give a brief structural overview of Linux operating system with an appropriate diagram? ANS: The Linux kernel is useless in isolation; it participates as one part in a larger system that, as a whole, is useful. As such, it makes sense to discuss the

kernel in the context of the entire system. Figure 2.1 shows a decomposition of the entire Linux operating system:

Figure : Decomposition of Linux System into Major Subsystems

The Linux operating system is composed of four major subsystems:

User Applications -- the set of applications in use on a particular Linux system will be different depending on what the computer system is used for, but typical examples include a word-processing application and a web-browser. O/S Services -- these are services that are typically considered part of the operating system (a windowing system, command shell, etc.); also, the programming interface to the kernel (compiler tool and library) is included in this subsystem. Linux Kernel -- this is the main area of interest in this paper; the kernel abstracts and mediates access to the hardware resources, including the CPU. Hardware Controllers -- this subsystem is comprised of all the possible physical devices in a Linux installation; for example, the CPU, memory hardware, hard disks, and network hardware are all members of this subsystem

Overview of the Kernel Structure

The Linux kernel is composed of five main subsystems:

1. The Process Scheduler (SCHED) is responsible for controlling

process access to the CPU. The scheduler enforces a policy that ensures that processes will have fair access to the CPU, while ensuring that necessary hardware actions are performed by the kernel on time.

2. The Memory Manager (MM) permits multiple process to securely

share the machine's main memory system. In addition, the memory manager supports virtual memory that allows Linux to support processes that use more memory than is available in the system. Unused memory is swapped out to persistent storage using the file system then swapped back in when it is needed. 3. The Virtual File System (VFS) abstracts the details of the variety of hardware devices by presenting a common file interface to all devices. In addition, the VFS supports several file system formats that are compatible with other operating systems. 4. The Network Interface (NET) provides access to several networking standards and a variety of network hardware. 5. The Inter-Process Communication (IPC) subsystem supports several mechanisms for process-to-process communication on a single Linux system.

Figure shows a high-level decomposition of the Linux kernel, where lines are drawn from dependent subsystems to the subsystems they depend on:

Figure : Kernel Subsystem Overview

This diagram emphasizes that the most central subsystem is the process scheduler: all other subsystems depend on the process scheduler since all

subsystems need to suspend and resume processes. Usually a subsystem will suspend a process that is waiting for a hardware operation to complete, and resume the process when the operation is finished. For example, when a process attempts to send a message across the network, the network interface may need to suspend the process until the hardware has completed sending the message successfully. After the message has been sent (or the hardware returns a failure), the network interface then resumes the process with a return code indicating the success or failure of the operation. The other subsystems (memory manager, virtual file system, and inter-process communication) all depend on the process scheduler for similar reasons.

The other dependencies are somewhat less obvious, but equally important:

The process-scheduler subsystem uses the memory manager to adjust the hardware memory map for a specific process when that process is resumed. The inter-process communication subsystem depends on the memory manager to support a shared-memory communication mechanism. This mechanism allows two processes to access an area of common memory in addition to their usual private memory. The virtual file system uses the network interface to support a network file system (NFS), and also uses the memory manager to provide a ramdisk device. The memory manager uses the virtual file system to support swapping; this is the only reason that the memory manager depends on the process scheduler. When a process accesses memory that is currently swapped out, the memory manager makes a request to the file system to fetch the memory from persistent storage, and suspends the process.

In addition to the dependencies that are shown explicitly, all subsystems in the kernel rely on some common resources that are not shown in any subsystem. These include procedures that all kernel subsystems use to allocate and free memory for the kernel's use, procedures to print warning or error messages, and system debugging routines. These resources will not be referred to explicitly since they are assumed ubiquitously available and used within the kernel layer.

Q3: Explain various features of Linux? ANS:

What is Linux?
Linux is an operating system, a software program that controls your computer. Most vendors load an operating system onto the hard drive of a PC before delivering the PC, so, unless the hard drive of your PC has failed, you may not understand the function of an operating system.

An operating system solves several problems arising from hardware variation. As you're aware, no two PC models (or models of other computers, for that matter) have identical hardware. For example, some PCs have an IDE hard drive, whereas others have a SCSI hard drive. Some PCs have one hard drive, others have two or more. Most PCs have a CDROM drive, but some do not. Some PCs have an Intel Pentium CPU, whereas others have an AMD K-6, and so on. Suppose that, in a world without operating systems, you're programming a new PC application, perhaps a new multimedia word processor. Your application must cope with all the possible variations of PC hardware. As a result, it becomes bulky and complex. Users don't like it because it consumes too much hard drive space, takes a long time to load, and - because of its size and complexity has more bugs than it should.

How Linux is Different


Linux is distinguished from many popular operating systems in three important ways.

Linux is a cross-platform operating system that runs on many computer models. Only Unix, an ancestor of Linux, rivals Linux in this respect. In comparison, Windows 95 and Windows 98 run only on CPUs having the Intel architecture. Windows NT runs only on CPUs having the Intel architecture or the DEC Alpha.

Linux is free, in two senses. First, you may pay nothing to obtain and use Linux. On the other hand, you may choose to purchase Linux from a vendor who bundles Linux with special documentation or applications, or who provides technical support. However, even in this case, the cost of Linux is likely to be a fraction of what you'd pay for another operating system. So, Linux is free or nearly free in an economic sense.

Second, and more important, Linux and many Linux applications are distributed in source form. This makes it possible for you and others to modify or improve them. You're not free to do this with most operating systems, which are distributed in binary form. For example, you can't make changes to Microsoft Windows or Microsoft Word only Microsoft can do that. Because of this freedom, Linux is being constantly improved and updated, far outpacing the rate of progress of any other operating system. For example, Linux will likely be the first operating system to support Intel's forthcoming Merced 64-bit CPU.

Linux has attractive features and performance. Free access to Linux source code lets programmers around the world implement new features, and tweak Linux to improve its performance and reliability. The best of these features and tweaks are incorporated in the standard Linux kernel or made available as kernel patches or applications. Not even Microsoft can mobilize and support a software development team as large and dedicated as the volunteer Linux software development team, which numbers in the hundreds of thousands, including programmers, code reviewers, and testers.

Key features of Linux Operating System:


Following are the key features of the Linux operating system:
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/multithreading:

it has native kernel support for multiple independent threads of control within a single process memory space. It has memory protection between processes, so that one program can't bring the whole system down. Demand loads executable: Linux only reads from disk those parts of a program that are actually used. Shared copy-on-write pages among executable. 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 file system, 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. 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. 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 file systems, including minix, Xenix, and all the common system V file systems, and has an advanced file system of its own, which offers file systems of up to 4 TB, and names up to 255 characters long. 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.

Q4: Write a short note on a) Chmod b) Shell

ANSWER:-

CHMOD:The chmod command allows you to change permissions on a file. The basic usage is: chmod PERMISSIONS FILE Where PERMISSIONS is either the numeric or the alpha equivalent of the permissions you want to assign and FILE is the file (or folder) you want to effect. Since the numeric permissions are the easiest to understand (and use) lets look at that method. Remember, file permissions are in the form: OWNER | GROUP | All Others

Each of those sections includes: READ | WRITE | EXECUTE Each permission (read, write, execute) is represented with the binary representation of the initial letter: r4 w2 x1

To get the numeric permission you add which permissions you want to use together. So if you want r+w you get 6. If you want r+w+x you get 7. If you want r+x you get 5. If you want only r you get 4. So now, remembering you have to cover permissions for three different users (Owner, Group, All Others), you will need to have a numeric number for each. So if you want Owner and Group to have rwx permission and All Others to only have r permissions, you would have: 774 Now, to change the permission of a particular file to 774 you would issue the command: chmod 774 FILENAME Where FILENAME is the name of the file.

SHELL:The Linux/Unix shell refers to a special program that allows you to interact with it by entering certain commands from the keyboard; the shell will execute the commands and display its output on the monitor. The environment of interaction is text-based (unlike the GUI-based interaction we have been using in the previous chapters) and since it is commandoriented this type of interface is termed Command Line interface or CLI. Before the advent of GUI-based computing environments, the CLI was the only way that one can interact and access a computer system.

Up until now, there was never a need to type commands into a shell; and with the modernisation and creation of a lot of newer GUI-based tools, the shell is becoming increasingly un-required to perform many tasks. But that said, the shell is a very powerful place, and a lot is achieved through it. A lot of the front-end GUI methods of doing things have similar ways and means to get done with using the shell. Professional Linux and UNIX users find the shell very powerful, and an introduction to at least the basic shell usage is useful.

Q5: Explain different types of Users existing for Linux Operating System? ANS: -

User Accounts
Types of User Accounts
o o o

The root account Regular user accounts Non-regular user accounts

The root Account


o o o

Super user account that has supervisory privileges throughout the Linux system Used by the system administrator to administer the machine The su (substitute user) utility Changes any user account's permissions to the permissions assigned to another user account [root@pattyo kickstart]# su - pattyo [pattyo@pattyo ~]$

* The '-' means make the shell a login shell. You will inherit the user's environment (.bashrc, .cshrc, ...). Note the two different prompts provided by the shell. The root account by default will use the pound sign (#) as its prompt.

Regular User Accounts


o

Intended for people who need to log in and use the system

o o

Commonly associated with individuals No more than eight characters for user name

Non-Regular User Accounts


o o o o

Employed only by Linux programs Programs can better control file permissions and therefore ensure the security of the system Cannot be used to log in Don't have a shell

Q6: Elaborate File and Directory Permissions available in Linux OS? ANS:
Linux files are setup so access to them is controlled. There are three types of access: 1. read 2. write 3. execute Each file belongs to a specific user and group. Access to the files is controlled by user, group, and what is called other. The term, other, is used to refer to someone who is not the user (owner) of the file, nor is the person a member of the group the file belongs to. When talking about setting permissions for "other" users to use, it is commonly referred to as setting the world execute, read, or write bit since anyone in the world will be able to perform the operation if the permission is set in the other category.

File names and permission characters


File names can be up to 256 characters long with "-", "_", and "." characters along with letters and numbers. When a long file listing is done, there are 10 characters that are shown on the left that indicate type and permissions of the file. File permissions are shown according to the following syntax example: drwerwerwe.

There are a total of 10 characters in this example, as in all Linux files. The first character indicates the type of file, and the next three indicate read, write, and execute permission for each of the three user types, user, group and other. Since there are three types of permission for three users, there are a total of nine permission bits. The table below shows the syntax: 1 File 2 User Permissio ns Read r Writ e w Execu te e 3 4 5 Group Permissio ns Read r Writ e w Execu te e 6 7 8 Other Permissio ns Read r Writ e w Execu te e 9 10

Typ e d

Character 1 is the type of file: - is ordinary, d is directory, l is link. Characters 2-4 show owner permissions. Character 2 indicates read permission, character 3 indicates write permission, and character 4 indicates execute permission. Characters 5-7 show group permissions. Character 5=read, 6=write, 7=execute. Characters 8-10 show permissions for all other users. Character 8=read, 9=write, 10=execute.

There are 5 possible characters in the permission fields. They are: r = read - This is only found in the read field. w = write - This is only found in the write field. x = execute - This is only found in the execute field. s = setuid - This is only found in the execute field. If there is a "-" in a particular location, there is no permission. This may be found in any field whether read, write, or execute field.

Examples:
Type "ls -l" and a listing like the following is displayed:

total 10 drwxrwxr wx -rw-rwrw-rw-rwrw4 1 1 george george george team1 team1 team1 122 1873 1234 Dec 12 18:02 Aug 23 08:34 Sep 12 11:13 Projects test datafile

Which means the following: Type and Permissio n field | drwxrwxr wx # of Links | 4 Files's Owner | george File's Group | team1 Size in Bytes | 122 Date of last modificati on | Dec 12 18:02 | Projects Filename

The fields are as follows: 4. Type field: The first character in the field indicates a file type of one of the following: o o o o o o o d = directory l = symbolic link s = socket p = named pipe - = regular file c= character (unbuffered) device file special b=block (buffered) device file special

5. Permissions are explained above. 6. Links: The number of directory entries that refer to the file. In our example, there are four.

7. The file's owner in our example is George. 8. The group the file belongs to. In our example, the group is team1. 9. The size of the file in bytes 10.The last modification date. If the file is recent, the date and time is shown. If the file is not in the current year, the year is shown rather than time. 11.The name of the file.

Directory Permissions
There are two special bits in the permissions field of directories. They are: s - Set group ID t - Save text attribute (sticky bit) - The user may delete or modify only those files in the directory that they own or have write permission for.

Save text attribute

The /tmp directory is typically world-writable and looks like this in a listing: drwxrwxrwt 13 root root 4096 Apr 15 08:05 tmp

Everyone can read, write, and access the directory. The "t'' indicates that only the user (and root, of course) that created a file in this directory can delete that file. To set the sticky bit in a directory, do the following: chmod +t data

This option should be used carefully. A possible alternative to this is Create a directory in the user's home directory to which he or she can write temporary files. Set the TMPDIR environment variable using each user's login script. Programs using the tempnam(3) function will look for the TMPDIR variable and use it, instead of writing to the /tmp directory.

Examples
Below are examples of making changes to permissions: chmod myfile chmod myfile chmod myfile chmod myfile u+x +x Gives the user execute permission on myfile. Gives everyone execute permission on myfile.

ugo+x Same as the above command, but specifically specifies user, group and other. 400 Gives the user read permission, and removes all other permission. These permissions are specified in octal, the first char is for the user, second for the group and the third is for other. The high bit (4) is for read access, the middle bit (2) OS for write access, and the low bit (1) is for execute access. 764 Gives user full access, group read and write access, and other read access. 751 Gives user full access, group read and execute permission, and other, execute permission. +s go=rx Set the setuid bit. Remove read and execute permissions for the group and other

chmod myfile chmod myfile chmod myfile chmod myfile

Table. Access Permissions for Files and Directories.


Access Permission File Folder Users can view the contents of the directory. Without this permission, users cannot list the contents of this directory with ls -l, for example. However, if they only have execute permission for the directory, they can nevertheless access certain files in this directory if they know of their existence.

Read (r)

Users can open and read the file.

Access Permission

File

Folder

Write (w)

Users can change the file: They can add or drop data and can even delete the contents of the file. However, this does not include the Users can create, rename or delete permission to remove the file files in the directory. completely from the directory as long as they do not have write permissions for the directory where the file is located.

Users can execute the file. This permission is only relevant for files like programs or shell scripts, not for text files. If the operating system can execute the file Execute (x) directly, users do not need read permission to execute the file. However, if the file must me interpreted like a shell script or a perl program, additional read permission is needed.

Users can change into the directory and execute files there. If they do not have read access to that directory they cannot list the files but can access them nevertheless if they know of their existence.

You might also like