0% found this document useful (1 vote)
4K views12 pages

Why Is UNIX More Portable Than Other Operating System

UNIX is more portable than other operating systems because it can be easily rewritten in different programming languages like C. This allows UNIX to run on a variety of hardware. The UNIX file system provides excellent use of resources, high reliability, and vast amounts of free online documentation and software. Internal commands are built into the shell itself while external commands are separate programs that require launching a subprocess. The ls -l command displays seven attributes of files including permissions, ownership, size, date modified, and filename.

Uploaded by

Mukesh Kumar
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 (1 vote)
4K views12 pages

Why Is UNIX More Portable Than Other Operating System

UNIX is more portable than other operating systems because it can be easily rewritten in different programming languages like C. This allows UNIX to run on a variety of hardware. The UNIX file system provides excellent use of resources, high reliability, and vast amounts of free online documentation and software. Internal commands are built into the shell itself while external commands are separate programs that require launching a subprocess. The ls -l command displays seven attributes of files including permissions, ownership, size, date modified, and filename.

Uploaded by

Mukesh Kumar
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/ 12

1. Why is UNIX more portable than other operating system?

Ans. UNIX is an operating system which is readily available,


searchable and has complete documentation both on the system
and online via the internet. Changes can easily do on this operating
system. Taking an example, when C programming language was
developed, the UNIX operating system itself was rewritten into C.
This enabled UNIX to become the more open portable than other
operating system today.
2. Explain briefly the significance of a UNIX file system?
Ans. The significance of a UNIX file system can be explained as:
a. It has excellent use and control of system resources.
b. It has very high reliability (long uptimes between reboots).
c. It is readily available, searchable, and has complete
documentation both on the system and online via the
internet.
d. Massive stores of free software available for downloading
and building.
e. It is able to interact with more than one user at a time.

3. Distinguish between internal and external commands with


examples.
Ans. Some commands in UNIX are internal, built into the shell. For
example, the cd command is built-in. That is, the shell interprets
the command and changes the current directory. On the other
hand, cat command is an external program stored in the file
/bin/cat, which is used to make files.
The shell doesn’t start a separate process to run internal
commands. External commands require the shell to run a new
subprocess; this takes some time, especially if the system is busy.

4. Explain the output of the ls –l command.


Ans. The command ls –l lists seven attributes of all the files in the
working directory. The top list gives the file mode, which consists of
a string of 10 characters. The first column gives the file mode,
which consists of a string of 10 characters. The first character
indicates the file type. The nine characters after the file type are the
file permissions, which are displayed in three sets of three
characters each.
The second column gives the number of filenames or links
associated with the file.

(continue....)
The third column gives the file ownership. The third column
displays the owner of the file.
The fourth column shows the group ownership of each file.
At the time of user account creation, the system administrator
assigns the user to a group.
The fifth column displays the file size in bytes.
The sixth column gives the date and time of modification of the
files. The last column gives the name of the file and the list is
arranged in the alphabetical order.
5. Write a UNIX command to display the current date in the form
dd/mm/yyyy.
Ans. $ date +%D

6. Explain the different types of files in UNIX.


Ans. There are four possible types of file in UNIX:
Ordinary files: These files cannot contain text, data, or program
information. An ordinary file cannot contain another file, or directory. An ordinary
file can be a text file or a binary file.
Directory files: Directories are containers that can hold files, and
other directories. A directory is actually implemented as a file that has one line for
each item contained within the directory.
Special files: These files represent input/output (i/o) devices, like a
tty (terminal), a disk drive, or a printer. Because UNIX treats such devices as files,
some of the commands used to access ordinary files will also work with device files.
This allows for more efficient use of software.
Links: A link is a pointer to another file. Since a directory is a list of the
names and i-numbers of files, a directory entry can be a hard link, in which the i-number
points directly to another file.
1. Write a UNIX command to count how many users have
logged on to the UNIX system.
Ans. who –q
2. What is a process? Explain the mechanism of process
creation in UNIX system.
Ans. A process is born when a program starts execution and exists
as long as the program is running. After execution the process is
said to die. The name of the process is usually the name of the
program being executed.
The creation of a process is in three phases and uses three
system calls known as fork, exec and wait. ‘fork’ is a system call
that creates a new process from an existing process. The new
process is called the child process, and the existing process is called
the parent. The attributes of the parent and child are an identical
image except for parameters like Parent-ID. The child gets a new
Parent-ID and the process is forked. This is the mechanism used to
multiply process in the system. The child process overwrites the
image with a copy of program that is to be executed by using the
‘exec’ system call. No additional processes are created and the
existing program is replaced with a new program. The Parent-ID of
this process is the same as that of the child process which was
forked.
The ‘wait’ system call is executed by the parent process to
wait for the child process to get completed. The exit status of the
child process is picked up by the parent process.
3. What is a filter? Explain any five filters in UNIX system.
Ans. Filters are UNIX commands which are used for extracting
related information from a given file.
Five mainly used filters in UNIX are –
a. Paginating Files, ‘pr’ :- This command, i.e. ‘pr’, prepares
a file for printing by adding suitable headers, footers
and formatted text. This command has to be used with
a file name as an argument –
$ pr emp.lst
b. ‘head’ :- This command, as the name implies, displays
the top of the file. When used without an option, it
displays the first ten lines of the file. When used with –n
option, it displays the first ‘n’ number of lines.
$ head emp.lst
$ head –n 3 emp.lst
c. ‘tail’ :- The tail command displays the end of the file(as
opposite to head command). Like head, it displays the
last 10 lines when used without arguments and with –n
option, it displays the last ‘n’ number of lines.
$ tail emp.lst
$ tail –n 4 emp.lst
d. ‘cut’ :- The features of the ‘cut’ command will be
illustrated with specific reference to the file “shortlist”,
which stores the first five lines of ‘emp.lst’ file. We can
extract both columns and fields from this file with the
‘cut’ command. Columns are specified with –c optionand
fields with –f option.
Cut is powerful text manipulator often used in
combination with other commands or filters
Cut uses the tab as the default field delimiter, but can
also work with different delimiter.

e. ‘grep’ :- The ‘grep’ command in UNIX is used to search


for a pattern in a given file. It displays the selected
pattern, the line numbers or the file names where the
pattern occurs. The syntax is :
$ grep options pattern filename(s)
‘grep’ searches for pattern in one or more filenames. The
first argument is the pattern and ones remaining are filenames.
4. Write a shell script to check whether given year is a leap
year or not.
Ans. The script will be as –
echo “Enter the Year : ”
read year
leap = `expr $year % 4`
if test $leap –eq 0
then
echo “$year is a leap year.”
else
echo “$year is not a leap year”
fi
5. What is the significance of write and talk command in
UNIX.
Ans. Write and talk are communication programs that allow users
to talk to each-other in a network.
The “write” command copies lines from one user’s terminal
to that of another user. The command is used by typing the
following –
$ write username
where username is another logged in user. The recipient gets a
message from the sender along with the sender’s username. If the
recipient of the message now writes back, communication will start
between the two users and continues until an end-of-file is read from
the terminal or an interrupt is sent

How is UNIX different from other operating


systems?
Ans.
The differences between UNIX and other operating
systems are:
 UNIX is a multi-user operating system. Unlike
DOS and Windows, a number of users can access
the UNIX operating system simultaneously.
 UNIX has better scalability than Windows OS.
 UNIX is stable and can be operated continuously
without being rebooted compared to Windows
OS.
. What is the meaning of multitasking?
Ans.
A multitasking operating system allows a computer to run several
programs at the same time. The multitasking operating system
divides the CPU time among various processes and gives an
impression of doing many tasks at the same time. The concept of
dividing CPU time is known as time-sharing.

How are commands located in Unix?


Ans.
The commands can be located using the type
command in Unix.

2. How does the type command work?


Ans.
The type command returns the location of the
command that is passed as a parameter to the type
command. For example,
$ type who
When the above command is entered, the shell
searches for the command in the search path
specified in the PATH environmental variable. If the
command is found, the command's location is disp.
How do you stop and resume the scrolling of the
screen display?
Ans.
You can stop scrolling of the screen display by
pressing CTRL-s and resume scrolling by pressing
CTRL-q keys from the keyboard.
layed on the console.
How do you get one-line descriptions of any
command in Unix?
Ans.
You can get one-line description of any command by
using the whatis command in Unix. For example, to
see the one-line description of cat command, you
specify the following command:
$ whatis cat
Use the cal command to find out whether the year
1900 was a leap year.
Ans.
The following command can be used to find whether
the year 1900 is a leap year or not:
$ cal 2 1900
As the output is showing 28 days in February, 1900
was not a leap year.

2. Use the echo command to display the message


'Good Morning'. The cursor should move to the next
line after displaying the message.
Ans.
The command to display 'Good Morning' using the
echo command is:
$ echo "Good Morning"
3. Display the current date in the mm/dd/yy format.
Ans.
The command to display current date in mm/dd/yy
format is:
$ date +"%D"

4. Use bc to divide 35 by 9. Set the scale to 2.


Ans.
The following command is given for using the bc:
$ bc
scale=2
35/9

5. Record your login session into a file.


Ans.
The following command is given to record the login
session into a file:
$ script <name of the script file>

6. List out the users logged on into the system.


Ans.
The command to list the current users is:
$ who

7. Display your terminal filename.


Ans.
The command to display the terminal file name is:
$ tty

8. Display the release version of your operating


system.
Ans.
The command to display the release version of the
operating system is:
$ uname -r

9. How do you check a file for spelling errors?


Ans.
A file can be checked for spelling errors by using the
ispell command.

10. How do you lock your terminal for 20 minutes?


Ans.
The command to lock the terminal for 20 minutes is:
lock -20
11. How do you check your terminal settings?
Ans.
You can check your terminal settings using the stty
command.
What happens if a directory has permissions 777?
Ans.
If a directory has 777 permissions, all the users have
read, write, and execute permissions on that
particular directory. They can add, delete, or modify
any file present in that directory

How are default file and directory permissions


changed?
Ans.
The default file and directory permissions can be
changed using the umask command. For example,
umask 022
The above command sets the following permissions
on a newly created files:
 Read and Write permissions for file owner.
 Read permission for group owner.
 Read permission for other users.

How are hard links created?


Ans.
The hard links are created using the ln command.
8. What are the uses of hard links?
Ans.
The uses of hard links are:
a. Hard links prevent accidental deletion of files.
b. Hard links can make the files available to the
users, when files in a directory are shifted to
another directory.
How do you order the list of files by their
modification time?
Ans.
The command to list the files based on their
modification time is:
$ ls -t

11. Find all the directories in the /usr directory?


Ans.
The command to find all the directories in the /usr
directory is:
find /usr -type d -print

1. How do you do the following using vi:


a. delete a line
b. overwrite text
c. move the cursor four lines down
d. add a new line above a line of text
e remove two lines from the end of a text and add it
to the beginning of the file
f. open a file and move to the fifteenth line in the
file
Ans.
a. dd
b. R
c. 4j
d. O
e. Keep the cursor at the second last line and in the
escape mode press 2Y, press 1G, and press P.
f. Type vi <file name> at the shell prompt, press
15G in the escape mode.
3. How do you replace all the occurrences of the
word printf with fprintf in a file?
Ans.
The following command needs to be given in the vi
editor in escape mode to replace the word printf
with fprintf in a file:
:1, $s/printf/fprintf/gp
4. What are the different ways of coming out of vi
after saving the file?
Ans.
There are three different ways to quit vi after saving
the file:
a. :wq
b. :x
c. ZZ5. How do you yank and paste lines?
Ans.
To yank and paste the lines, perform the following
steps:
a. Keep the cursor at the line you want to copy.
b. Press Y or <n>Y, where n is the total number of
lines that you want to copy.
c. Place the cursor at the line, where you want to
paste the copied lines.
d. Press p to paste the line after the cursor or press P
to paste the lines before the cursor.
4. How do you run a process in the background?
Ans.
To run a process in the background, you need to
append & symbol to the command. For example,
$ wc Report &
The above command will count the characters,
words, and lines in the Report file in the
background.

You might also like