0% found this document useful (0 votes)
2 views4 pages

UNIX_All_Units_Answers

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

Sub-UNIX Important Questions - Detailed Answers

UNIT 1

1. What is UNIX? Write about UNIX commands.


UNIX is a multi-user, multitasking operating system that is widely used for its simplicity,
power, and flexibility. It serves as the foundation for many other operating systems like
Linux and macOS. UNIX provides a stable environment for both personal and server use,
with features like networking capabilities and a hierarchical file system.
UNIX Commands:
1. `ls`: Lists files and directories.
2. `cd`: Changes the current directory.
3. `pwd`: Prints the current working directory.
4. `chmod`: Changes file permissions.
5. `grep`: Searches for patterns in files.
6. `awk`: A scripting language for text processing.
7. `find`: Locates files and directories.
These commands are executed in a shell, making it easy to manage files and processes.

2. What are the types of file systems in UNIX?


UNIX supports different types of file systems that organize and store data efficiently.
Common types include:
1. Regular Files: Store data, text, or program instructions.
2. Directory Files: Contain references to other files and directories.
3. Special Files: Represent hardware devices like printers and drives (character and block
files).
4. Pipe Files: Enable interprocess communication by passing data between processes.
5. Socket Files: Used for network communication.
6. Symbolic Links: Shortcuts or pointers to other files or directories.

3. Explain about security levels and file permissions.


UNIX provides robust security through user authentication and file permissions. Security
levels include:
1. User Level: Permissions for the file owner.
2. Group Level: Permissions for a specific group of users.
3. Others Level: Permissions for all other users.

File permissions are displayed as a set of characters (e.g., `-rw-r--r--`) that indicate:
1. Read (r): Allows reading the file.
2. Write (w): Allows modifying the file.
3. Execute (x): Allows executing the file as a program.
4. Write about grep, regular expressions, and awk in UNIX.
grep: A command-line utility to search for patterns in files. Example: `grep 'pattern' file.txt`.
Regular Expressions: Patterns used for matching text. Example: `[a-z]+` matches lowercase
words.
awk: A programming language for pattern scanning and processing. Example: `awk '{print
$1}' file.txt`.

5. Discuss briefly the different shells and shell programming.


A shell is a command-line interpreter that executes user commands. Common UNIX shells
include:
1. Bourne Shell (sh): Basic shell with essential features.
2. C Shell (csh): Syntax similar to C programming.
3. Korn Shell (ksh): Combines features of Bourne and C shells.
4. Bash Shell: Popular shell with advanced features like scripting.

Shell Programming: Writing scripts in shell languages to automate tasks. Example: Creating
a shell script to back up files.

UNIT 2

1. What is the UNIX model? Explain about signals and process control.
The UNIX model is based on a simple design philosophy: 'Everything is a file.' It uses a
hierarchical file system and allows for processes and devices to be treated as files, making
the system consistent and flexible.

Signals: Signals are software interrupts used to communicate with processes. Examples
include `SIGINT` (interrupt signal) and `SIGKILL` (terminate signal). Signals can be sent
using the `kill` command or system calls.

Process Control: UNIX provides system calls like `fork()`, `exec()`, and `wait()` to create and
manage processes. `fork()` creates a new process, `exec()` replaces the current process with
a new one, and `wait()` pauses the parent process until the child process finishes.

2. Write about the daemon process.


A daemon is a background process that runs independently of user interaction. It provides
essential services, such as logging, scheduling, and networking. Examples include `cron` for
scheduling tasks and `httpd` for web servers.

Features of Daemons:
1. Run in the background.
2. Do not have a controlling terminal.
3. Start at system boot and continue running until shutdown.
3. What is interprocess communication? Explain file and record locking.
Interprocess Communication (IPC) allows processes to exchange data and synchronize their
actions. IPC methods include pipes, message queues, shared memory, and semaphores.

File and Record Locking: Prevents simultaneous access to files or specific parts of files by
multiple processes.
1. File Locking: Locks the entire file.
2. Record Locking: Locks specific parts (records) of a file for finer control.

Locking can be implemented using system calls like `fcntl()` or `lockf()`.

4. Write about pipes and FIFOs.


Pipes and FIFOs are IPC mechanisms in UNIX.

Pipes: Temporary, unidirectional communication channels between related processes.


Created using the `pipe()` system call.
FIFOs: Similar to pipes but persistent and bidirectional. Created using the `mkfifo`
command, they allow unrelated processes to communicate.

5. Explain namespaces and message queues.


Namespaces: Allow processes to have isolated views of system resources, such as files,
processes, and network interfaces. This isolation is a core feature of containers like Docker.

Message Queues: Provide a mechanism for processes to exchange messages


asynchronously. They are created and managed using system calls like `msgget()`,
`msgsnd()`, and `msgrcv()`.

6. Discuss briefly about semaphores and shared memory.


Semaphores: Synchronization tools used to control access to shared resources by multiple
processes. They are implemented using `semget()`, `semop()`, and `semctl()`.

Shared Memory: Fast IPC mechanism that allows multiple processes to access the same
memory space. Created and managed using `shmget()`, `shmat()`, and `shmdt()`.

7. Explain about UNIX streams and messages.


Streams in UNIX are a standardized way to handle input and output. They represent data
flow between processes or devices.

Messages refer to structured data units exchanged between processes using message
queues or other IPC mechanisms.
UNIT 3

1. What is a socket? Explain about socket and socket address.


A socket is an endpoint for communication between two machines over a network. It
provides an interface for sending and receiving data using protocols like TCP and UDP.

Socket Address: Consists of an IP address and port number, which uniquely identifies a
socket.

Types of Sockets:
1. Stream Sockets (TCP): Reliable and connection-oriented.
2. Datagram Sockets (UDP): Unreliable but faster, connectionless.

You might also like