sap4help@gmail.com +91 8956877466
This website is always under updation with new contents
Unit - III
Unit I
Unit II
Unit III
Unit IV
Unit V
Q1) Explain wild card characters in UNIX, with suitable examples.
UNIX Wildcards There are several special characters that can be used to match multiple files at the same time:
A number of characters are interpreted by the UNIX shell before any other action takes place.
These characters are known as wildcard characters. Usually these characters are used in place of filenames or directory names.
* An asterisk matches any number of characters in a filename, including none.
? The question mark matches any single character.
[ ] Brackets enclose a set of characters, any one of which may match a single character
at that position. - A hyphen used within [ ] denotes a range of characters.
~ A tilde at the beginning of a word expands to the name of your home directory.
If you append another user's login name to the character, it refers to that user's home directory.
Here are some examples: 1. cat c* displays any file whose name begins with c including the file c, if it exists.
2. ls *.c lists all files that have a .c extension.
3. cp ../rmt?. Copies every file in the parent directory that is four characters long and begins with rmt to the working directory. (The names will remain the same.)
4. ls rmt[34567] lists every file that begins with rmt and has a 3, 4, 5, 6, or 7 at the end.
5. ls rmt[3-7] does exactly the same thing as the previous example.
6. ls ~ lists your home directory.
7. ls ~hessen lists the home directory of the guy1 with the user id hessen.
Q2) what is kernel Operating system? Explain its functions

Ans: The kernel is the essential center of a computer operating system, the core that provides basic services for all other parts of the operating system.
A synonym is nucleus. The central module of an operating system. It is the part of the operating system that loads first, and it remains in main memory.
Because it stays in memory, it is important for the kernel to be as small as possible while still providing all the essential services required by other parts of the operating system and applications.
Typically, the kernel is responsible for memory management, process and task management, and disk management.
A kernel can be contrasted with a shell, the outermost part of an operating system that interacts with user commands.
Kernel and shell are terms used more frequently in UNIX operating systems than in IBM mainframe or Microsoft Windows systems.

In computer science, the kernel is the central component of most computer operating system(OS).
Its responsibilities include managing the system's resources (the communication between hardware and software components).
As a basic component of an operating system, a kernel provides the lowest-level abstraction layer for the resources (especially memory, processors and I/O devices) that application software must control to perform its function.
It typically makes these facilities available to application programs through intercrosses communication mechanisms and system calls.
These tasks are done differently by different kernels, depending on their design and implementation.
While monolithic kernels will try to achieve these goals by executing all the code in the same address space to increase the performance of the system, microkernels run most of their services in user space, aiming to improve maintainability and modularity of the codebase.
A range of possibilities exists between these two extremes.
Q3) Write a note on Vi editors in Unix.
Ans: The vi editor (short for visual editor) is a screen editor which is available on almost all Unix systems.
Once you have learned vi, you will find that it is a fast and powerful editor.
vi has no menus but instead uses combinations of keystrokes in order to accomplish commands.
Starting vi To start using vi, at the Unix prompt type vi followed by a file name.
If you wish to edit an existing file, type in its name; if you are creating a new file, type in the name you wish to give to the new file.
%vi filename Then hit Return. You will see a screen similar to the one below which shows blank lines with tildes and the name and status of the file.
~ ~ "myfile" [New file] vi's Modes and Moods vi has two modes: the command mode and the insert mode.
It is essential that you know which mode you are in at any given point in time.
When you are in command mode, letters of the keyboard will be interpreted as commands.
When you are in insert mode the same letters of the keyboard will type or edit text.
vi always starts out in command mode. When you wish to move between the two modes, keep these things in mind. You can type i to enter the insert mode.
If you wish to leave insert mode and return to the command mode, hit the ESC key.
If you're not sure where you are, hit ESC a couple of times and that should put you back in command mode. General Command Information
As mentioned previously, vi uses letters as commands. It is important to note that in general vi commands:
• are case sensitive - lowercase and uppercase command letters do different things
• are not displayed on the screen when you type them
• generally do not require a Return after you type the command.
You will see some commands which start with a colon (:). These commands are ex commands which are used by the ex editor.
ex is the true editor which lies underneath vi -- in other words, vi is the interface for the ex editor.
Entering Text To begin entering text in an empty file, you must first change from the command mode to the insert mode.
To do this, type the letter i. When you start typing, anything you type will be entered into the file.
Type a few short lines and hit Return at the end of each of line. Unlike word processors, vi does not use word wrap.
It will break a line at the edge of the screen. If you make a mistake, you can use the Backspace key to remove your errors.
If the Backspace key doesn't work properly on your system, try using the Ctrl h key combination.
Cursor Movement You must be in command mode if you wish to move the cursor to another position in your file.
If you've just finished typing text, you're still in insert mode and will need to press ESC to return to the command mode.
Moving One Character at a Time Try using your direction keys to move up, down, left and right in your file.
Sometimes, you may find that the direction keys don't work.
If that is the case, to move the cursor one character at the time, you may use the h, j, k, and l keys.
These keys move you in the following directions: h left one space l right one space
j down one space k up one space
If you move the cursor as far as you can in any direction, you may see a screen flash or hear a beep. Moving among Words and Lines While these four keys (or your direction keys) can move you just about anywhere you want to go in your file, there are some shortcut keys that you can use to move a little more quickly through a document.
To move more quickly among words, you might use the following:
w moves the cursor forward one word
b moves the cursor backward one word (if in the middle of a
word, b will move you to the beginning of the current word).
e moves to the end of a word.
To build on this further, you can precede these commands with a number for greater movement.
For example, 5w would move you forward five words; 12b would move you backwards twelve words.
[You can also use numbers with the commands mentioned earlier. For example, 5j would move you down 5 characters.
Command Keys and Case You will find when using vi that lower case and upper case command keys are interpreted differently.
For example, when using the lower case w, b, and e commands, words will be defined by a space or a punctuation mark.
On the other hand, W, B, and E commands may be used to move between words also, but these commands ignore punctuation.
Shortcuts Two short cuts for moving quickly on a line include the $ and the 0 (zero) keys.
The $ key will move you to the end of a line, while the 0 will move you quickly to the beginning of a line.
Screen Movement To move the cursor to a line within your current screen use the following keys:
H moves the cursor to the top line of the screen.
M moves the cursor to the middle line of the screen.
L moves the cursor to the last line of the screen.
To scroll through the file and see other screens use:
ctrl-f scrolls down one screen
ctrl-b scrolls up one screen
ctrl-u scrolls up a half a screen
ctrl-d scrolls down a half a screen
Two other useful commands for moving quickly from one end to the other of a document are G to move to the end of the file and 1G to move to the beginning of the file.
If you precede G with a number, you can move to a specific line in the document (e.g. 15G would move you to line 15).
Deleting (or Cutting) Characters, Words, and Lines To delete a character, first place your cursor on that character. Then, you may use any of the following commands:
x deletes the character under the cursor.
X deletes the character to the left of your cursor.
dw deletes from the character selected to the end of the word.
dd deletes all the current line.
D deletes from the current character to the end of the line.
Preceding the command with a number will delete multiple characters.
For example, 10x will delete the character selected and the next 9 characters;
10X will delete the 10 characters to the left of the currently selected character.
The command 5dw will delete 5 words, while 4dd deletes four lines.
Pasting Text using Put Often, when you delete or cut text, you may wish to reinsert it in another location of the document.
The Put command will paste in the last portion of text that was deleted since deleted text is stored in a buffer.
To use this command, place the cursor where you wish the deleted text to appear. Then use p to reinsert the text.
If you are inserting a line or paragraph use the lower case p to insert on the line below the cursor or upper case P to place in on the line above the cursor.

Q3d) Describe various file types supported by UNIX operating system.
Ans: UNIX ha many different types of files which are described as follows:
ile system and UNIX was one of the first operating system to implement such a structure.
The hierarchical aspect improves access times. A directory is a special sort of file.
It can contain ordinary files or additional directories files. With directories the user has complete flexibility in grouping files in ma meaningful ways.
A UNIX directory must have a name normally of up to fourteen characters. These characters may be upper or lower case or a mixture of both.
2) Linked files and i-nodes: Unlike some other operating systems that have hierarchical file system, a UNIX file can have more than one name.
A single UNIX file may also be identified in more than one directory. This is done by the use of multiple links to the file.
UNIX assigns a unique number to every file that is created in the file system and this is called as i-node number.
Every file on the system must have one i-node. Following fig shows the use of i-nodes for files that have one link.
i. e. files that are only known by one name.

Since UNIX can also have multiple links, a file can appear in more than one directory.
Once the directory is entered, the link is followed and the user finishes up inside that directory.
The file is not duplicated. If duplicated this would be wastage of storage space.
The key thing is that we are linking to a single files and from the links originate doesn’t matter.
This ability to link file sis very useful, since different people can access the same file from different areas in the file system.
3) Ordinary files: This consists of a sequential series of bytes, which occupy disk- storage space.
An ordinary file is different from a directory in that a directory allows layers of files to be built up.
It therefore constitutes a ‘leaf node’ in the context of tree structured hierarchy. The UNIX imposes no rules regarding the internal format of ordinary files. Ordinary file are created using text editor.
UNIX supplies these editors as standard and they can be found in various directories in atypical UNIX file system.
4) Special files: Theses are those that refer to device such as terminals, printers and other peripherals.
The concept of a computer device as a file does see rather strange but it is a key advantage where device independently is concerned.
All of the UNIX devices are stored in a directory called /dev, which reside below the root directory.
Q4) Explian the use of filters and pipelines in UNIX.
Unix commands alone are powerful, but when you combine them together, you can accomplish complex tasks with ease.
The way you combine Unix commands is through using pipes and filters.
Using a Pipe The symbol | is the Unix pipe symbol that is used on the command line.
What it means is that the standard output of the command to the left of the pipe gets sent as standard input of the command to the right of the pipe.
Note that this functions a lot like the > symbol used to redirect the standard output of a command to a file.
However, the pipe is different because it is used to pass the output of a command to another command, not a file.
Here is an example:
$ cat apple.txt
core
worm seed
jewel
$ cat apple.txt | wc
3 4 21
$
In this example, at the first shell prompt, I show the contents of the file apple.txt to you.
In the next shell prompt, I use the cat command to display the contents of the apple.txt file, but I sent the display not to the screen
but through a pipe to the wc (word count) command. The wc command then does its job and counts the lines, words, and characters of what it got as input.
You can combine many commands with pipes on a single command line.
Here's an example where I count the characters, words, and lines of the apple.txt file, then mail the results to nobody@december.com with the subject line "The count."

Q5) Explain following commands with one example each:- i)rm: ii)rmdir ii)man iv)chmod
Ans: Rm command: rm (short for remove) is a basic UNIX command used to remove objects such as files, directories, device nodes, symbolic links, and so on from the filesystem. To be more precise, rm removes references to objects from the filesystem,
where those objects might have had multiple references (for example, a file with two different names),
and the objects themselves are discarded only when all references have been removed and no programs still have open handles to the objects.
This allows for scenarios where a program can open a file, immediately remove it from the filesystem,
and then use it for temporary space, knowing that the file's space will be reclaimed after the program exits, even if it exits by crashing.
rm generally does not destroy file data, since its purpose is really merely to unlink references,
and the filesystem space freed may still contain leftover data from the removed file.
This can be a security concern in some cases, and hardened versions sometimes provide for wiping out the data as the last link is being cut,
and programs such as shred are available which specifically provide data wiping capability.
To remove a file named "foo" from a directory one could type:
% rm foo
Common options that rm accepts include:
• -r, which removes directories, removing the contents recursively beforehand (so as not to leave files without a directory to reside in) ("recursive")
• -i, which asks for every deletion to be confirmed ("interactive")
• -f, which ignores non-existent files and overrides any confirmation prompts ("force"), although it will not remove files from a directory if the directory is write protected.
rm is often overlain by a C shell alias or Bourne shell function of "rm -i" so as to avoid accidental deletion of files.
If a user still wishes to delete a large number of files without confirmation, they can manually cancel out the -i argument by adding the -f option .
2)rmdir: It is unix utility that removes directory files.
Rm dir works in similar way to rm except that rmdir removes directory files.
The directory to be removed can be specified usinmg a full or partially qualified path.
Syntax: rmdir
Ex:$ rmdir1 rmdir: dir1 directory not empty
$ cd dir1
$ rm file1, file2
$ cd..
$ rmdir dir1
$
The above example illustare the attempts to delete the directory file named dir1.
We firstly examine dir1 by moving ito it using cd.
This reveals that the directory is not empty and in fact it contains two ordinary files here named file1, file2.
To delet directory we must dlete al the fiels in dir1. This can be done by rm file1 file2.
Once the files have been deleted we can delete the directory by using rmdir.
3) Man: A man page (short for manual page) is the software documentation for a computer program in a Unix, or Unix-like, operating system.
A user may invoke a man page by issuing the man command.
Usage:
To read a manual page for a UNIX command, one can use
man
Chmod: The chmod command (abbreviated from change mode) is a Unix command that lets a user tell the system how much (or little) access it should permit to a file. It changes the file system modes of files and directories.
The modes include permissions and special modes. It is also a C language function in Unix and Unix-like environments.
Usage The chmod command options are specified like this:[2]
$ chmod [options] mode[,mode] file1 [file2 ...]
This is used to control the file mode.
To view the current file mode:
$ ls -l file
or use the stat command to view the octal numerical values ("*" lists all files in current directory)
$ stat -c '%A %a %n' *

Q6) Discuss the features of UNIX operating system.
Ans: The UNIX Operating System is available on machines with a wide range of computing power, from microcomputers to mainframes,
and on different manufacture's machines. No other operating system can make this claim. We see the reasons of popularity and success of UNIX.
The reasons are Portability: The system is written in high-level language making it easier to read, understand, change and, therefore move to other machines.
The code can be changed and complied on a new machine.
Customers can then choose from a wide variety of hardware vendors without being locked in with a particular vendor.
Machine-independence: The System hides the machine architecture from the user, making it easier to write applications that can run on micros, mins and mainframes.
Multi-User Operations: UNIX is a multi-user system designed to support a group of users simultaneously.
The system allows for the sharing of processing power and peripheral resources, white at the same time providing excellent security features.
Hierarchical File System: UNIX uses a hierarchial file structure to store information.
This structure has the maximum flexibility in grouping information in a way that reflects its natural state.
It allows for easy maintenance and efficient implementation.
UNIX shell: UNIX has a simple user interface called the shell that has the power to provide the services that the user wants.
It protects the user from having to know the intricate hardware details.
Pipes and Filters: UNIX has facilities called Pipes and Filters which permit the user to create complex programs from simple programs.
Utilities: UNIX has over 200 utility programs for various functions.
New utilities can be built effortlessly by combining existing utilities.
Software Development Tools: UNIX offers an excellent variety of tools for software development for all phases, from program editing to maintenance of software,

Q7) What is input/output redirection? Explain.
Ans : Redirecting output using ‘>’:
Output that is redirected to a file using the ‘>’ redirection opearator will overwrite that file if it already exists in the directory specified.
The ‘>>’ redirection opesarator is similar to the ‘>’ opearator except that >> appends data to a file.
Examples:
$ who > a_file
S who >> a_file
These two commands redirect the output of ythe who command to a file named a-file.
The first command initially creates the file a_file which will hold the standard output of the who command.
The second command achieves the same outcome as the first, but the output is appended to the file a_file.
The file a_file should contain the following.
$ cat a file
John ttyl4 jun 8 16:01
Mary tty12 jun 8 14:16
Root tty1 jun 8 11:55
Redirecting the standard input using ‘<’ Redirecting the standard input of a command can be quite useful.
If we continue with the who command we can illustrate this.
Who displays a list of the current user who are logged into the system.
We also know that who can take input from a who-file. Whi files are maintained by UNIX for monitoring purposes.
The wtmp file for examples holds the login and logout information going back to the time when wtmp file was first created.
Example
$ who /etc/ wtmp
Will produce output similar to that given below:
Root console jan 15 12: 04
Paul console jan 17 12:13
. . . .
. . . .
The listing will probably continue for a few quite some time, so if you typed this command,
try pressing to interrupt the output or ctrl –s followed by ctrl-q to pause and restart the output.
In this example we have told who to take its input from a file named /etc/wtmp.
This could be considered a type of input redirection but where is the ‘<’ operator? In this case it is implied.
The who command assumes that the input is arriving from a file.

Q8) Explain the term home directory in UNIX. Where is it created and why?
Ans: A Home directory is a file system directory on a multi-user operating system containing files for a given user of the system.
A user's home directory is intended to contain that user's files; including text documents, music, pictures or videos, etc.
It may also include their configuration files of preferred settings for any software they have used there and might have tailored to their liking:
web browser bookmarks, favorite desktop wallpaper and themes, passwords to any external services accessed via a given software, etc.
The user can install executable software in this directory, but it will only be available to users with permission to this directory.
The home directory can be organized further with the use of sub-directories.
The content of a user's home directory is protected by file system permissions, and by default is only accessible to that user and administrators.
Any other user that has been granted administrator privileges has authority to access any protected location on the file system including other users home directories.
In Unix, a user will be automatically placed into their home directory upon login.
The ~user shorthand variable refers to a user's home directory (allowing the user to navigate to it from anywhere else in the file system,
or use it in other Unix commands). The ~ (tilde character) shorthand command refers to that particular users home directory.
In Unix, a user will be automatically placed into their home directory upon login.
The ~user shorthand variable refers to a user's home directory (allowing the user to navigate to it from anywhere else in the file system,
or use it in other Unix commands). The ~ (tilde character) shorthand command refers to that particular users home directory.
The Unix superuser has access to all directories on the file system, and hence can access home directories of all users.
The superuser's home directory on older systems was /, but on many newer systems it is located at /root (Linux, BSD), or /var/root (Mac OS X).

Q9) Explain the use of following commands with one example of each:- i) Mv ii) Ls iii) Cat iv) Pwd
Ans: mv : mv (short for move) is a Unix command that moves one or more files or directories from one place to another.
Since it can "move" files from one filename to another, it is also used to rename files.
Using mv requires the user to have write permission for the directories which the file will move between.
This is because mv changes the file's location by editing the file list of each directory.
When a filename is moved to an existing filename (in the same directory), the existing file is deleted.
If the existing file is not writable but is in a directory that is writable, the mv command asks for confirmation ( if run from a terminal) before proceeding, unless the -f (force) option is used
Syntax
mv [-f] [-i] oldname newname
-f mv will move the file(s) without prompting even if it is writing over an existing target.
Note that this is the default if the standard input is not a terminal.
-i Prompts before overwriting another file.
oldname The oldname of the file renaming.
newname The newname of the file renaming.
filename The name of the file you want to move directory - The directory of were you want the file to go.
Examples
mv myfile.txt newdirectory/
Moves the file myfile.txt to the directory newdirectory.
mv myfile.txt ../
Moves the file myfile.txt back one directory (if available).
mv computer\ hope.txt computer_hope.txt
Moves (renames) the file "computer hope.txt" to computer_hope.txt.
When working with a file or directory with a space you must escape that space with a backslash or surround the filename or directory with quotes.
Ls : Refer Q3d of winter 2008
3) CAT : The cat command reads one or more files and prints them to standard output.
The operator > can be used to combine multiple files into one. The operator >> can be used to append to an existing file.
The syntax for the cat command is:
cat [options] [files]
options:
-e $ is printed at the end of each line. This option must be used with -v.
-s Suppress messages pertaining to files that do not exist.
-t Each tab will display as ^I and each form feed will display as ^L. This option must be used with -v.
-u Output is printed as unbuffered.
-v Display control characters and nonprinting characters
Examples:
cat file1
cat file1 file2 > all
cat file1 >> file2
Pwd: In Unix-like and some other operating systems, the pwd command (present working directory) is used to output the path of the current working directory.
Syntax: pwd
Examples
pwd
Typing pwd at the prompt would give you something similar to:
/home/computerhope/public_html
Users who are familiar with MS-DOS or the Windows command prompt may type cd alone to print the working directory.
However, typing cd alone in Linux and UNIX will return you to the home directory.
For accessing computer programs go to TECHNOLOGY