osy practical questions solved

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

### 1) What are different versions of Linux Operating System?

- **Red Hat Enterprise Linux (RHEL)**: Widely used in enterprise environments.


- **Ubuntu**: Popular among desktop users.
- **Debian**: Known for its stability and use as a base for other distributions.
- **Fedora**: Cutting-edge distribution backed by Red Hat.
- **Arch Linux**: Offers customization and control for advanced users.

### 2) Enlist the steps for booting the operating system.

- **Power On**: Hardware initialization begins.


- **POST (Power-On Self Test)**: Ensures all hardware components function.
- **Boot Loader Activation**: Loads the bootloader (e.g., GRUB).
- **Kernel Load**: The OS kernel is loaded into memory.
- **System Initialization**: System services and processes start.
- **Login Prompt**: User can now log in.

### 3) State names of latest multi-user operating system and its advantages.

- **Operating Systems**: Ubuntu Server, Windows Server 2022, CentOS Stream.


- **Advantages**:
- Resource sharing.
- Simultaneous multi-user access.
- Enhanced system management tools.

### 4) Differentiate between Command Line OS and GUI OS by giving example.

- **Command Line OS**: e.g., Linux Terminal. Users interact via text commands.
- **GUI OS**: e.g., Windows 10. Users interact through graphical icons.

### 5) Write and Execute general purpose commands:

- **date**: Displays current date and time.


- **time**: Displays and manages system time.
- **cal**: Shows calendar.
- **clear**: Clears terminal screen.
- **banner**: Prints a message in large letters.
- **tty**: Displays terminal type.
- **script**: Records terminal session.
- **man**: Displays manual for commands.

### 6) Write down different options for cal commands (Any 5):

- **cal -3**: Displays three months.


- **cal -j**: Julian calendar.
- **cal -y**: Full year display.
- **cal MM YYYY**: Displays a specific month of a specific year.
- **cal -m month**: Highlights a specific month.

### 7) Write options of date command (Any 5):

- **date +%D**: Displays date in MM/DD/YY.


- **date +%T**: Displays current time.
- **date +%F**: Full date in YYYY-MM-DD.
- **date +%s**: Unix timestamp.
- **date --set="2024-11-18"**: Sets the system date.
### 8) Write and Execute linux terminal and basic commands:

- **who**: Displays currently logged-in users.


- **who am i**: Shows current session information.
- **login**: Logs user into the system.
- **pwd**: Prints current working directory.
- **Present Working Directory Command**: `pwd`
- **Currently Logged-in Users Command**: `who`
- **Acquire Superuser Status**: `sudo -i`

### 9) Write and Execute process commands:

- **ps**: Shows running processes.


- **wait**: Waits for process completion.
- **sleep**: Delays command execution.
- **exit**: Exits terminal.
- **kill**: Terminates processes.

**Options for kill command**:


- `kill -9 [PID]`: Force stop process.
- `kill -l`: List signals.
- `kill -HUP [PID]`: Restarts process.

**Options for ps command**:


- `ps -aux`: Detailed process list.
- `ps -e`: Lists all processes.
- `ps -f`: Full format output.

**Process Management System Calls**:


- `fork()`, `exec()`, `wait()`, `exit()`.

### 10) Write and Execute file and directory manipulation commands:

- **ls**: Lists files.


- **rm**: Removes files.
- **cp**: Copies files.
- **cat**: Concatenates files.
- **head**: Displays start of a file.
- **tail**: Displays end of a file.

**Options for ls commands**:


- `ls -l`: Detailed listing.
- `ls -a`: Includes hidden files.
- `ls -h`: Human-readable sizes.
- `ls -R`: Recursive.
- `ls -t`: Sorts by modification time.

### 11) Create three files a1, a2, a3.

**Command**: `touch a1 a2 a3`

### 12) Write and Execute file and directory manipulation commands:

- **mkdir**: Creates a directory.


- **cd**: Changes directory.
- **rmdir**: Removes empty directory.
### 13) Difference between comm and cmp command:

- **comm**: Compares two sorted files line by line.


- **cmp**: Compares two files byte by byte.

### 14) Commands for file permissions:

- **Assign _rwxr_xr_**: `chmod 751 OSY`


- **Assign _rwxrwxrwx_**: `chmod 777 OSY`

### 15) Write and Execute text processing commands:

- **tr**: Translates characters.


- **wc**: Word count.
- **cut**: Removes sections.
- **paste**: Merges lines.
- **sort**: Orders content.

### 16) Options of wc command:

- `wc -l`: Line count.


- `wc -w`: Word count.
- `wc -c`: Byte count.
- `wc -m`: Character count.
- `wc -L`: Longest line length.

### 17) What is difference between Type o and type of O?

- **Type o**: Lowercase 'o'.


- **Type of O**: Uppercase 'O'.

### 18) Ways to quit the vi editor:

- `:q`: Quit.
- `:q!`: Force quit without saving.
- `:wq`: Save and quit.

### 19) Modes in VI editor:

- **Normal Mode**: For navigation.


- **Insert Mode**: For text input.
- **Command Mode**: For executing commands.

### 20) Shell script for greatest number:

```bash
#!/bin/bash
echo "Enter three numbers: "
read a b c
if [ $a -gt $b ] && [ $a -gt $c ]; then
echo "$a is greatest."
elif [ $b -gt $c ]; then
echo "$b is greatest."
else
echo "$c is greatest."
fi
```
### 21) Difference between If [condition] and If ((condition)):

- **If [condition]**: Used for string or integer comparisons.


- **If ((condition))**: Used for arithmetic expressions.

### 22) Shell script for Fibonacci series:

```bash
#!/bin/bash
echo "Enter n: "
read n
a=0
b=1
echo "Fibonacci series:"
for (( i=0; i<n; i++ ))
do
echo -n "$a "
fn=$((a + b))
a=$b
b=$fn
done
echo
```

### 23) Shell script for tables 2 to 10:

```bash
#!/bin/bash
for i in {2..10}; do
echo "Table of $i:"
for j in {1..10}; do
echo "$i * $j = $((i * j))"
done
echo
done
```

### 24) Difference between Iteration and Recursion:

- **Iteration**: Repeats a block of code using loops.


- **Recursion**: Function calls itself until a base condition is met.

### 25) Shell script for copying a file:

```bash
#!/bin/bash
echo "Enter source file name:"
read source
echo "Enter destination file name:"
read dest
cp $source $dest
echo "File copied."
```

### 26) Shell script to list directories in home directory:


```bash
#!/bin/bash
ls -d ~/*/
```

### 27) Permissions for a file:

- **Read (r)**, **Write (w)**, **Execute (x)**.

### 28) Test commands for checking permissions:

- `[ -r file ]`: Checks read permission.


- `[ -w file ]`:

You might also like