0% found this document useful (0 votes)
19 views

Unix Answers 2023

Uploaded by

Anjan Mistry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Unix Answers 2023

Uploaded by

Anjan Mistry
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Q) What do you mean by OS?

→ An operating system is a set of program which coordinates


between system and different applications programs and
hardware instructed by user. It interact with two components- i)
Applications that run under it ii) Users who pass commands to
it using a command line interpreter.
Q) What is Kernel ?

→ The kernel is the center of the operating system , a


collection of program mostly written in ‘c’ which communicates
with the hardware directly. It manages the system resources ,
allocates time between user and processes and perform other
task. It directly interact with the machines hardware.
Q) What are the functions of the commands
‘who’, ’Date’?
→ Who → we must know the total number of users and the
current user using the unix system. To know this we use Who
command.

$who ←

BCA tty 1 june 05 15:10


BBA tty 2 june 08 16:10
$

Date→ this command is used to display the system date.

$date ←
Wednesday November 20 7:41:32 est 2023
$
Q) What do you mean by filter in Unix?

→ Filters are programs that takes plain text as standard input,


transforms it into a meaningful format and then returns it as
standard output. Examples of some filters are cat, head, tail,
sort, grep, wc, sed etc.
Q) What are the various modes of Vi editor ?

→ Vi editor is a command-line text based editor that’s


commonly used in Unix operating system. Vi can be
represented in three mode –
i) Command mode
ii) Input mode
iii) Execution mode.

Q) What is the function of ‘Chmod’ command ?

→ The chmod command in Unix is used to change the file


system mode of files and directories. This means it can adjust
permissions, such as who can read, write and execute the file.
Example- $ chmod 755 Tandra
This command sets the permission for the file named
“Tandra” so that the owner can read, write and execute it.
Q) What
expr stands is shell programming?
for “expression” and allows for the evaluation of values and returns th
result to standard output. It is particularly useful in scripts for handling both
→ Shell programming
numerical in Unix
and string involves writing
data efficiently. scripts
In short, usingin:
it helps the
shell, which is a command-line interpreter. It allows for task
 Basic operations like addition, subtraction, multiplication, division, and
automation and execution of complex commands in a
modulus on integers.
sequence.
 Evaluating regular expressions, string operations like substring, length of string
Example-
etc.
#!/bin/bash
echo “Hello world”
Q) What do you mean by Zombie process?
→ A zombie process in Unix is a process that has completed
execution but still has an entry in the process table. This is
happened because the process’s parent has not read its exit
status. A child process always first becomes a zombie before
being remove from the process table.
Q) What is the significance of ‘expr’ command?

→ expr stands for “expression” and the expr command in


Unix is a versatile tool used for evaluation of values and returns
the result to standard output. It performs a wide range of
functions, including arithmetic calculations, string operations,
and comparisons based on regular expressions.
Syntax
$ expr expression.
Q) Write the function of cat command.

→ The cat command is a universal file viewer and file creator


in Linux. Using cat command we can create any kind of file
which has some set of words or characters inside it.

$ cat > tandra ←

My name is Tandra. I live in Ambona.


[ctrl+d]
$ cat tandra ←
My name is Tandra. I live in Ambona.
Q) What are daemons?


Daemons in Unix are background processes that run inde
pendently of user control, performing system tasks like ha
ndling requests and managing system resources. They usua
lly start at boot time and operate silently, ensuring smooth
system operations. They are typically identified by a "d" at
the end of their names.
Q) What is the syntax of ‘while’ command?
→ The “while” command is a powerful tool in the Linux shell
that allows you to execute a series of commands repeatedly
based on a given condition. It is commonly used in shell scripts
to create loops.
Synyax-
while [condition]
do
# commands to be executed
done

Q) Explain the Unix architecture with a proper diagram.

 → Layer-1: Hardware: It consists of all hardware related


information.
 Layer-2: Kernel: This is the core of the Operating
System. It is a software that acts as the interface between
the hardware and the software. Most of the tasks like
memory management, file management, network
management, process management, etc., are done by the
kernel.
 Layer-3: Shell commands: This is the interface between
the user and the kernel. When you type in a command at
the terminal, the shell interprets the command and calls
the program that you want. There are various commands
like cp, mv, cat, grep, id, wc, nroff, a.out and more.
 Layer-4: Application Layer: It is the outermost layer that
executes the given external applications.
Q) Explain different blocks in file system.

NAME DESCRIPTION
/ The slash / character alone denotes the root of the
filesystem tree.
/boot Contains all the files that are required for successful
booting process.
/home Contains the home directories for the users.
/lib Contains system libraries, and some critical files such as
kernel modules or device drivers.
/var A short for “variable.” A place for files that may change
often – especially in size,
/media Default mount point for removable devices, such as USB
sticks, media players, etc.
/usr/lib Stores the required libraries and data files for programs
stored within /usr or elsewhere.

The Unix file system is a hierarchical file system used by Unix-based


operating systems to store and organize files and directories. It is a tree-
like structure that starts with a single directory called the root directory,
which is denoted by a forward slash (/) character.

Q) Explain the ‘ls’ command with different options.

→ The ls command in Unix lists files and directories in a


directory.
Options Description

-l It displays the file attributes.

Represent all files include hidden files and


-a directories in the listing.

Sort files and directories by their last modification


-t time.

known as reverse order which is used to reverse the


-r default order of listing.

Sort files and directories by their sizes, listing the


-S largest ones first.

-h Print file sizes in human-readable format.

List directories themselves, rather than their


-d contents.

Example-

$ ls -l ←

Total 30
-rw-r--r-- 1 romeo metal 19514 May 10 13:45 chap01
-rw-r--r-- 1 romeo metal 4174 May 10 15:10 chap02
-rw-rw-rw- 1 romeo metal 84 Feb 12 12:30 chap03
…..

Q) Distinguish between time-sharing and client/server


environment.

Time-Sharing Environment Client/Server Environment

Multiple users share system resources Clients request services from a server
Simultaneous user access Interaction is client-initiated
Centralized resource management Server manages resources for multiple clients
Users access a central computing system. Distributed computing between client and server
Examples: Early mainframe systems Examples: Web services and database systems
Limited by central system's capacity High scalability due to distributed architecture
Centralized control, potential for shared access Improved isolation and security per client
Performance can degrade with multiple users Better performance with dedicated server resources
Varies, higher for dedicated servers
Lower initial cost.

Q) Write the use of ‘Head’ and ‘Tail’ commands.


→ Head command :- The head command display the top
of the files. When used without an option it displays first 10
lines of the argument file.
Example=
$ cat > A.txt ←
ab
cd
ef
gh
ij
kl
mn
op
qr
st
uv
wx
yz
[ctrl+d]
$ head A.txt←
ab
cd
ef
gh
ij
kl
mn
op
qr
st
[displays first 10 lines of the file]

Tail command:-
Displaying the end of a file. Complementing its head
command, the tail command display the last 10 lines of
the argument file.
Example –
The last three lines are displayed in this way
$ tail -3 A.txt ←
yz
wx
uv

$ tail +9 A.txt ←
qr
st
uv
wx
yz
[displays the content of a file starting from the 9th
line to the end of the file.]

Q) Write the command for the following:


i) To display time in GMT ii) To display time in
format= hour: minute: second
→ i) To display time in GMT:-
$ date -u
This will show the current time in GMT (UTC).
Example:
$ date -u ←
Tue Oct 22 18:29:00 UTC 2024

ii) To display time in the format hour: minute:


second:
$ date +%r
This will show the current time in format hour:
minute: second:
Example:
$ date +%r←
12:48:56 AM

You might also like