Skip to main content
  1. Resources/
  2. Study Materials/
  3. Information Technology Engineering/
  4. IT Semester 3/
  5. Linux Operating System (4331602)/

Linux Operating System (4331602) - Summer 2025 Solution

·
Study-Material Solutions Linux 4331602 2025 Summer
Milav Dabgar
Author
Milav Dabgar
Experienced lecturer in the electrical and electronic manufacturing industry. Skilled in Embedded Systems, Image Processing, Data Science, MATLAB, Python, STM32. Strong education professional with a Master’s degree in Communication Systems Engineering from L.D. College of Engineering - Ahmedabad.
Table of Contents

Question 1(a) [3 marks]
#

Define Operating System and explain the need of OS.

Answer:

Operating System is a system software that acts as an intermediary between computer hardware and application software. It manages hardware resources and provides services to user programs.

Need of Operating System:

  • Resource Management: Manages CPU, memory, storage, and I/O devices efficiently
  • User Interface: Provides command-line and graphical interfaces for user interaction
  • Program Execution: Loads and executes user programs safely

Mnemonic: “RUP - Resource, User, Program management”

Question 1(b) [4 marks]
#

Write a short note on Process Control Block (PCB).

Answer:

Process Control Block (PCB) is a data structure maintained by the operating system for each running process.

PCB ComponentDescription
Process IDUnique identifier for the process
Process StateCurrent state (ready, running, waiting)
Program CounterAddress of next instruction to execute
CPU RegistersValues of CPU registers when process is suspended
Memory ManagementBase and limit registers, page tables
I/O StatusList of open files and I/O devices

Key Functions:

  • Process Identification: Stores unique process ID and parent process ID
  • State Information: Maintains current execution state and context
  • Resource Allocation: Tracks allocated resources and memory usage

Mnemonic: “PIS - Process ID, Information, State tracking”

Question 1(c) [7 marks]
#

List different types of Operating systems. Explain the working of batch operating systems with a suitable example.

Answer:

Types of Operating Systems:

TypeDescription
Batch OSGroups similar jobs and executes them together
Time-sharing OSMultiple users share system simultaneously
Real-time OSProvides guaranteed response time
Distributed OSManages multiple interconnected computers
Network OSProvides network services and resource sharing
Mobile OSDesigned for mobile devices

Batch Operating System Working:

CPEJOrxoBoCebOgPcLrUu1atmosrBatFPcMJOrhMaoRoenbTgQmaRruog2AaereNmuyrseManagerPHJraoCoInb+g/d+rOl3aemrsPJJroAobVgAr4ams

Example: Bank transaction processing where all day’s transactions are collected and processed together at night for efficiency.

Key Features:

  • Job Grouping: Similar jobs executed together for efficiency
  • No User Interaction: Jobs run without user intervention once submitted
  • High Throughput: Maximizes system utilization

Mnemonic: “JNH - Jobs grouped, No interaction, High throughput”

Question 1(c) OR [7 marks]
#

List different types of Operating systems. Explain the real time operating systems in detail.

Answer:

Types of Operating Systems: (Same table as above)

Real-Time Operating System (RTOS):

Real-time OS provides guaranteed response within specified time constraints for critical applications.

Types of RTOS:

TypeDeadlineExample
Hard Real-timeMust meet deadlineAir traffic control, pacemaker
Soft Real-timeCan tolerate some delayVideo streaming, online gaming
Firm Real-timeOccasional deadline miss acceptableLive audio processing

Characteristics:

  • Deterministic: Predictable response time for all operations
  • Priority-based Scheduling: High-priority tasks get immediate attention
  • Minimal Interrupt Latency: Fast context switching capabilities
  • Memory Management: Real-time memory allocation without delays

Applications:

  • Medical devices, automotive systems, industrial automation, aerospace control systems

Mnemonic: “DPMA - Deterministic, Priority-based, Minimal latency, Applications critical”

Question 2(a) [3 marks]
#

Differentiate between program and process.

Answer:

AspectProgramProcess
DefinitionStatic code stored on diskProgram in execution
StatePassive entityActive entity
MemoryNo memory allocationAllocated memory space
LifetimePermanent until deletedTemporary during execution
ResourcesNo resource consumptionConsumes CPU, memory, I/O

Key Differences:

  • Static vs Dynamic: Program is static file, process is dynamic execution
  • Resource Usage: Process consumes system resources, program doesn’t
  • Multiple Instances: One program can create multiple processes

Mnemonic: “SDR - Static vs Dynamic, Resource usage, Multiple instances”

Question 2(b) [4 marks]
#

Explain the different states of a process with the help of a process state diagram.

Answer:

stateDiagram-v2
    [*] --> New: Program loaded
    New --> Ready: Admitted to ready queue
    Ready --> Running: CPU allocated
    Running --> Ready: Time quantum expires
    Running --> Waiting: I/O request
    Waiting --> Ready: I/O completed
    Running --> Terminated: Process completes
    Terminated --> [*]: Resources deallocated

Process States:

StateDescription
NewProcess being created
ReadyWaiting for CPU assignment
RunningCurrently executing on CPU
WaitingBlocked for I/O or event
TerminatedProcess execution completed

State Transitions:

  • Ready to Running: Process scheduler assigns CPU
  • Running to Ready: Time slice expires or higher priority process arrives
  • Running to Waiting: Process requests I/O operation
  • Waiting to Ready: I/O operation completes

Mnemonic: “NRWRT - New, Ready, Waiting, Running, Terminated states”

Question 2(c) [7 marks]
#

Describe the Round Robin algorithm. Calculate the average waiting time & average turn-around time along with Gantt chart for the given data. Consider context switch = 01 ms and quantum time = 04 ms.

Answer:

Round Robin Algorithm: Round Robin is a preemptive scheduling algorithm where each process gets equal CPU time (quantum) in circular manner.

Given Data:

  • Quantum Time = 4 ms
  • Context Switch = 1 ms
ProcessArrival TimeBurst Time
P108
P233
P3110
P445

Gantt Chart:

0   4  5   8  9  13 14  18 19  22 23  26 27  29
|P1 |CS|P3|CS|P1|CS|P2|CS|P3|CS|P4|CS|P3|CS|P4|

Calculations:

ProcessCompletion TimeTurnaround TimeWaiting Time
P113135
P2181512
P3262515
P4292520

Average Waiting Time = (5 + 12 + 15 + 20) / 4 = 13 ms Average Turnaround Time = (13 + 15 + 25 + 25) / 4 = 19.5 ms

Key Features:

  • Fair Scheduling: Each process gets equal CPU time
  • Preemptive: Running process is interrupted after quantum expires
  • Context Switching: Overhead included in calculations

Mnemonic: “FPC - Fair, Preemptive, Context switching overhead”

Question 2(a) OR [3 marks]
#

Differentiate: CPU bound process v/s I/O bound process.

Answer:

AspectCPU Bound ProcessI/O Bound Process
Primary ActivityIntensive calculationsFrequent I/O operations
CPU UsageHigh CPU utilizationLow CPU utilization
Burst TimeLong CPU burstsShort CPU bursts
Waiting TimeLess I/O waitingMore I/O waiting
ExamplesMathematical calculations, image processingFile operations, database queries

Key Differences:

  • Resource Consumption: CPU-bound uses more processor, I/O-bound uses more input/output
  • Performance Impact: CPU-bound affected by processor speed, I/O-bound by storage speed
  • Scheduling Priority: Different algorithms favor each type differently

Mnemonic: “CIR - CPU intensive, I/O intensive, Resource usage differs”

Question 2(b) OR [4 marks]
#

What is a deadlock? Explain the necessary conditions for a deadlock to occur.

Answer:

Deadlock is a situation where two or more processes are permanently blocked, each waiting for resources held by others.

Necessary Conditions (Coffman Conditions):

ConditionDescription
Mutual ExclusionResources cannot be shared simultaneously
Hold and WaitProcess holds resources while waiting for others
No PreemptionResources cannot be forcibly taken from processes
Circular WaitCircular chain of processes waiting for resources

Example Scenario:

PwRraeoisctoesusrsfcoeAr2-h-ohlodlsd-s------>P-r-Ro-ec-se-os-us-r|cBe1

Deadlock Prevention:

  • Eliminate Mutual Exclusion: Make resources shareable when possible
  • Prevent Hold and Wait: Require all resources at once
  • Allow Preemption: Forcibly take resources when needed
  • Prevent Circular Wait: Order resources and request in sequence

Mnemonic: “MHNC - Mutual exclusion, Hold-wait, No preemption, Circular wait”

Question 2(c) OR [7 marks]
#

Describe the FCFS algorithm. Calculate the average waiting time and average turn-around time along with Gantt chart for the given data.

Answer:

First Come First Serve (FCFS) Algorithm: FCFS is a non-preemptive scheduling algorithm where processes are executed in arrival order.

Given Data:

ProcessArrival TimeBurst Time
P107
P236
P359
P464

Gantt Chart:

0        7        13        22        26
|   P1   |   P2   |    P3   |   P4   |

Calculations:

ProcessStart TimeCompletion TimeTurnaround TimeWaiting Time
P10770
P2713104
P31322178
P422262016

Average Waiting Time = (0 + 4 + 8 + 16) / 4 = 7 ms Average Turnaround Time = (7 + 10 + 17 + 20) / 4 = 13.5 ms

Characteristics:

  • Simple Implementation: Easy to understand and implement
  • Non-preemptive: Once started, process runs to completion
  • Convoy Effect: Short processes wait for long processes

Mnemonic: “SNC - Simple, Non-preemptive, Convoy effect possible”

Question 3(a) [3 marks]
#

Explain single-level directory structure.

Answer:

Single-level directory structure is the simplest file organization where all files are stored in one directory.

fpdidiramoRlotacoegaguo1r.emt.ad.etmajnDx.tptiteg.rxpeedcftory

Characteristics:

  • Simple Structure: All files in one location
  • Unique Names: Each file must have unique name
  • No Organization: No grouping or categorization possible

Limitations:

  • Name collision when multiple users create files with same names
  • Difficult to organize large number of files
  • No privacy or access control between users

Mnemonic: “SUN - Simple, Unique names, No organization”

Question 3(b) [4 marks]
#

Explain the different file attributes.

Answer:

File attributes are metadata that provide information about files stored in the file system.

AttributeDescription
NameHuman-readable file identifier
TypeFile format (executable, text, image)
SizeCurrent file size in bytes
LocationPhysical address on storage device
ProtectionAccess permissions (read, write, execute)
Time stampsCreation, modification, access times
OwnerUser who created the file

Common File Attributes:

  • Identifier: Unique number for file system reference
  • Type Information: MIME type or file extension
  • Size and Allocation: Current size and allocated space
  • Access Control: User permissions and group access rights

Storage Location: File attributes are typically stored in directory entries or file allocation tables.

Mnemonic: “NTSLPTO - Name, Type, Size, Location, Protection, Time, Owner”

Question 3(c) [7 marks]
#

List the different file allocation methods and explain contiguous allocation with necessary diagram.

Answer:

File Allocation Methods:

MethodDescription
ContiguousFiles stored in consecutive blocks
LinkedFiles stored using linked list of blocks
IndexedUses index block to point to data blocks

Contiguous Allocation:

In contiguous allocation, each file occupies a set of contiguous blocks on the disk.

DDiis0rFFFFkeiiiicllllBFteeeel1ionol2raABCce-ymk3es2AT:ablS3et:a259rt4Fi5l-L5e7en231Bgt6h7F8il9e9C

Advantages:

  • Fast Access: Direct calculation of block addresses
  • Minimal Seek Time: Consecutive blocks reduce head movement
  • Simple Implementation: Easy to implement and manage

Disadvantages:

  • External Fragmentation: Unused spaces between files
  • File Size Limitation: Difficult to extend files
  • Compaction Needed: Periodic reorganization required

Mnemonic: “FMS vs EFC - Fast access, Minimal seek, Simple vs External fragmentation, File size limits, Compaction needed”

Question 3(a) OR [3 marks]
#

Explain the different types of Linux file systems in brief.

Answer:

File SystemDescription
ext2Second extended filesystem, no journaling
ext3Third extended filesystem with journaling
ext4Fourth extended filesystem, improved performance
XFSHigh-performance 64-bit journaling filesystem
BtrfsB-tree filesystem with advanced features
ZFSCopy-on-write filesystem with data integrity

Key Features:

  • Journaling: ext3, ext4, XFS provide crash recovery
  • Performance: ext4, XFS optimized for large files
  • Advanced Features: Btrfs, ZFS offer snapshots and compression

Selection Criteria: Different filesystems suit different use cases based on performance, reliability, and feature requirements.

Mnemonic: “EEXBZ - ext2/3/4, XFS, Btrfs, ZFS options”

Question 3(b) OR [4 marks]
#

Explain the different file operations.

Answer:

OperationDescription
CreateMake new file with specified name and attributes
OpenPrepare file for reading/writing operations
ReadRetrieve data from file at current position
WriteStore data to file at current position
SeekMove file pointer to specific position
CloseRelease file resources and update metadata
DeleteRemove file and deallocate storage space

File Operation Sequence:

graph LR
    A[Create File] --> B[Open File]
    B --> C[Read/Write]
    C --> D[Seek if needed]
    D --> C
    C --> E[Close File]
    E --> F[Delete if needed]

Important Considerations:

  • Error Handling: Each operation can fail and must be checked
  • Permissions: User must have appropriate access rights
  • Concurrent Access: Multiple processes may access same file

Mnemonic: “CORWSCD - Create, Open, Read, Write, Seek, Close, Delete”

Question 3(c) OR [7 marks]
#

List the different file allocation methods and explain indexed allocation with necessary diagram.

Answer:

File Allocation Methods:

OperationDescription
CreateMake new file with specified name and attributes
OpenPrepare file for reading/writing operations
ReadRetrieve data from file at current position
WriteStore data to file at current position
SeekMove file pointer to specific position
CloseRelease file resources and update metadata
DeleteRemove file and deallocate storage space

Indexed Allocation:

In indexed allocation, each file has an index block containing pointers to data blocks.

IDDniid2s0rFFekeiixcllBteeB5l1onloraAocymckFek8s2iT:lafeboAlIr93|en:dFeixl41eBlAo:5|cFkil6eA78F9ileA|FileA|

Types of Indexed Allocation:

  • Single-level: One index block per file
  • Multi-level: Index blocks point to other index blocks
  • Combined: Mix of direct and indirect pointers

Advantages:

  • No External Fragmentation: Blocks can be anywhere on disk
  • Dynamic File Size: Easy to extend files
  • Fast Random Access: Direct access to any block

Disadvantages:

  • Index Block Overhead: Extra space for storing pointers
  • Multiple Disk Access: Two accesses needed (index + data)
  • Small File Inefficiency: Overhead high for small files

Mnemonic: “NDF vs IMI - No fragmentation, Dynamic size, Fast access vs Index overhead, Multiple access, Inefficient for small files”

Question 4(a) [3 marks]
#

Define System threats and explain its types.

Answer:

System Threats are malicious attempts to disrupt or damage computer system operations, steal information, or gain unauthorized access.

Threat TypeDescription
WormsSelf-replicating programs that spread across networks
VirusesMalicious code that attaches to other programs
Trojan HorsesLegitimate-looking programs with hidden malicious functions
Denial of ServiceAttacks that overwhelm system resources
Port ScanningUnauthorized probing of network services

Categories of System Threats:

  • Network-based: Attacks through network connections and protocols
  • Host-based: Attacks targeting specific computer systems
  • Physical: Direct physical access to compromise systems

Impact: System threats can lead to data loss, system downtime, privacy breaches, and financial damage.

Mnemonic: “WVTDP - Worms, Viruses, Trojans, DoS, Port scanning”

Question 4(b) [4 marks]
#

Differentiate: User Authentication v/s User Authorization.

Answer:

AspectUser AuthenticationUser Authorization
PurposeVerify user identityDetermine user permissions
WhenBefore system accessAfter authentication
MethodsPasswords, biometrics, tokensAccess control lists, roles
Question“Who are you?”“What can you do?”
ProcessOne-time at loginContinuous during session

Authentication Methods:

  • Something you know: Passwords, PINs
  • Something you are: Fingerprints, retina scans
  • Something you have: Smart cards, tokens

Authorization Models:

  • Role-based Access Control (RBAC): Permissions based on user roles
  • Discretionary Access Control (DAC): Owner controls access
  • Mandatory Access Control (MAC): System-enforced security levels

Relationship: Authentication must occur before authorization. Both are essential for comprehensive security.

Mnemonic: “WHO vs WHAT - Authentication asks WHO, Authorization determines WHAT”

Question 4(c) [7 marks]
#

Discuss various operating system security policies and procedures.

Answer:

Security Policies:

Policy TypeDescription
Access ControlDefines who can access what resources
Password PolicyRules for password creation and management
Audit PolicyLogging and monitoring of system activities
Update PolicyRegular security patches and updates
Data ClassificationCategorizing data by sensitivity levels

Security Procedures:

1. User Account Management:

  • Regular review of user accounts and permissions
  • Immediate revocation of access for terminated employees
  • Principle of least privilege implementation

2. System Monitoring:

graph TD
    A[Log Collection] --> B[Analysis Engine]
    B --> C[Threat Detection]
    C --> D[Alert Generation]
    D --> E[Response Action]

3. Incident Response:

  • Detection: Identify security incidents quickly
  • Containment: Limit damage and prevent spread
  • Recovery: Restore normal operations safely

4. Backup and Recovery:

  • Regular data backups with tested restore procedures
  • Disaster recovery planning and testing
  • Business continuity measures

Implementation Framework:

  • Risk Assessment: Identify vulnerabilities and threats
  • Policy Development: Create comprehensive security guidelines
  • Training: Educate users on security practices
  • Compliance: Ensure adherence to regulations

Mnemonic: “AAPUD policies + UMSIR procedures - Access, Audit, Password, Update, Data classification + User management, Monitoring, System response, Incident handling, Recovery”

Question 4(a) OR [3 marks]
#

Define Program threats and explain its types.

Answer:

Program Threats are malicious software designed to disrupt, damage, or gain unauthorized access to computer programs and data.

Threat TypeDescription
MalwareMalicious software including viruses, worms
SpywarePrograms that secretly monitor user activities
AdwareUnwanted advertising software
RansomwareEncrypts data and demands payment
RootkitsHide malicious activities from detection

Program Threat Categories:

  • Executable Threats: Standalone malicious programs
  • Parasitic Threats: Attach to legitimate programs
  • Network Threats: Spread through network connections

Common Attack Vectors:

  • Email attachments and downloads
  • Infected removable media
  • Network vulnerabilities and exploits

Mnemonic: “MSARR - Malware, Spyware, Adware, Ransomware, Rootkits”

Question 4(b) OR [4 marks]
#

Explain the protection domain with a suitable example.

Answer:

Protection Domain is a set of objects and access rights that define what resources a process can access and what operations it can perform.

ComponentDescription
ObjectsResources like files, memory, devices
Access RightsPermissions like read, write, execute
SubjectsProcesses or users requesting access

Domain Structure:

PPrroO---oO---tbtbejFPMejFNDceireceieatclimtclttitenoitewaos1tros2obn:eyn:ra(r(ksDR(DReo,(Ro)(mWW,mR(a))Wa,Ri,iW)nXn))AB

Example - University System:

  • Student Domain: Read access to course materials, write access to assignments
  • Faculty Domain: Read/write access to grade databases, read access to student records
  • Admin Domain: Full access to system configuration, user management

Domain Switching: Processes can switch between domains based on:

  • User authentication and authorization
  • Program execution context
  • Security level requirements

Benefits:

  • Isolation: Prevents unauthorized access between domains
  • Flexibility: Allows controlled resource sharing
  • Security: Implements principle of least privilege

Mnemonic: “OAS - Objects, Access rights, Subjects define domains”

Question 4(c) OR [7 marks]
#

Explain Access Control List in detail.

Answer:

Access Control List (ACL) is a security mechanism that specifies which users or processes are granted access to objects and what operations are allowed.

ACL Structure:

ComponentDescription
SubjectUser, group, or process requesting access
ObjectResource being protected (file, device, etc.)
Access RightsSpecific permissions granted

ACL Implementation:

FilUabageslodr:eibmorciu/enph:odmeev/prPrrrroeeeeejraaaaemddddci,,,ts/swwwrirrreoiiipntttoseeer,t.dtexltete

Types of ACL:

  • Discretionary ACL (DACL): Owner controls access permissions
  • System ACL (SACL): System controls auditing and logging
  • Default ACL: Inherited permissions for new objects

ACL vs Capability Lists:

AspectACLCapability List
OrganizationPer objectPer subject
StorageWith objectWith subject
CheckingScan listPresent capability
RevocationEasyDifficult

Advantages:

  • Granular Control: Fine-grained permission management
  • Centralized Management: Easy to modify object permissions
  • Audit Trail: Clear record of who has access

Disadvantages:

  • Performance Overhead: Must check ACL for each access
  • Storage Requirements: Space needed for permission lists
  • Complexity: Difficult to manage for many users/objects

Real-world Example: Linux file permissions use simplified ACL with owner, group, and others having read, write, execute rights.

Mnemonic: “SOA structure + GDSC advantages - Subject, Object, Access rights + Granular, Distributed, Centralized, Audit capabilities”

Question 5(a) [3 marks]
#

Explain the following commands: (i) man (ii) cd (iii) ls

Answer:

CommandPurposeSyntax
manDisplay manual pages for commandsman [command]
cdChange current directorycd [directory]
lsList directory contentsls [options] [directory]

Command Details:

1. man (manual) command:

  • Function: Shows detailed documentation for Linux commands
  • Example: man ls shows manual page for ls command
  • Sections: Commands, system calls, library functions, etc.

2. cd (change directory) command:

  • Function: Navigate between directories in filesystem
  • Examples: cd /home, cd .. (parent), cd ~ (home)
  • Special: cd without arguments goes to home directory

3. ls (list) command:

  • Function: Display files and directories in current or specified location
  • Options: -l (long format), -a (hidden files), -h (human readable)
  • Example: ls -la shows detailed listing including hidden files

Mnemonic: “MCD - Manual pages, Change directory, Directory listing”

Question 5(b) [4 marks]
#

Write a shell script to find maximum number among three numbers.

Answer:

#!/bin/bash
# Script to find maximum among three numbers

echo "Enter three numbers:"
read -p "First number: " num1
read -p "Second number: " num2  
read -p "Third number: " num3

# Find maximum using nested if-else
if [ $num1 -gt $num2 ]; then
    if [ $num1 -gt $num3 ]; then
        max=$num1
    else
        max=$num3
    fi
else
    if [ $num2 -gt $num3 ]; then
        max=$num2
    else
        max=$num3
    fi
fi

echo "Maximum number is: $max"

Key Features:

  • Input Validation: Reads three numbers from user
  • Comparison Logic: Uses nested if-else for finding maximum
  • Output Display: Shows result with clear message

Alternative Approach:

max=$(echo "$num1 $num2 $num3" | tr ' ' '\n' | sort -nr | head -1)

Mnemonic: “ICD - Input, Compare, Display result”

Question 5(c) [7 marks]
#

Write a shell script to find the sum of all the individual digits in a given 5-digit number.

Answer:

#!/bin/bash
# Script to find sum of digits in a 5-digit number

echo "Enter a 5-digit number:"
read number

# Validate input
if [ ${#number} -ne 5 ] || ! [[ $number =~ ^[0-9]+$ ]]; then
    echo "Error: Please enter exactly 5 digits"
    exit 1
fi

sum=0
temp=$number

# Extract and sum each digit
while [ $temp -gt 0 ]; do
    digit=$((temp % 10))    # Get last digit
    sum=$((sum + digit))    # Add to sum
    temp=$((temp / 10))     # Remove last digit
done

echo "Number: $number"
echo "Sum of digits: $sum"

# Display breakdown
echo "Breakdown:"

# Display individual digits
original=$number
echo -n "Digits: "
for ((i=0; i<5; i++)); do
    digit=$((original % 10))
    if [ $i -eq 4 ]; then
        echo -n "$digit"
    else
        echo -n "$digit + "
    fi
    original=$((original / 10))
done | tac
echo " = $sum"

Algorithm Steps:

  • Input Validation: Check for exactly 5 digits
  • Digit Extraction: Use modulo and division operations
  • Sum Calculation: Add each extracted digit
  • Display Results: Show breakdown and final sum

Example Output:

Enter a 5-digit number: 12345
Number: 12345
Sum of digits: 15
Breakdown: 1 + 2 + 3 + 4 + 5 = 15

Mnemonic: “VEDS - Validate, Extract, Display, Sum digits”

Question 5(a) OR [3 marks]
#

Explain the following commands: (i) date (ii) top (iii) cmp

Answer:

CommandPurposeSyntax
dateDisplay or set system date/timedate [options] [format]
topDisplay running processes dynamicallytop [options]
cmpCompare two files byte by bytecmp [options] file1 file2

Command Details:

1. date command:

  • Function: Shows current system date and time
  • Examples: date, date +%Y-%m-%d, date +%H:%M:%S
  • Formatting: Custom output formats using + symbols

2. top command:

  • Function: Real-time display of system processes and resource usage
  • Interactive: Press ‘q’ to quit, ‘k’ to kill process
  • Information: CPU usage, memory usage, process list

3. cmp command:

  • Function: Compare two files and report differences
  • Output: Shows first differing byte position
  • Options: -s (silent), -l (verbose listing)

Mnemonic: “DTC - Date/time, Task monitor, Compare files”

Question 5(b) OR [4 marks]
#

Explain the installation steps of Linux.

Answer:

StepDescription
1. Download ISOGet Linux distribution image file
2. Create Bootable MediaBurn ISO to DVD or USB drive
3. Boot from MediaStart computer from installation media
4. Choose Installation TypeSelect install alongside or replace OS
5. Partition SetupConfigure disk partitions
6. User ConfigurationCreate user account and passwords
7. Package SelectionChoose software packages to install
8. Installation ProcessCopy files and configure system
9. Reboot SystemRestart into new Linux installation

Pre-installation Requirements:

  • Hardware Compatibility: Check system requirements
  • Backup Data: Secure important files before installation
  • Internet Connection: For updates and additional packages

Installation Process Flow:

graph TD
    A[Download ISO] --> B[Create Bootable Media]
    B --> C[Boot from Media]
    C --> D[Language/Keyboard Setup]
    D --> E[Disk Partitioning]
    E --> F[User Account Setup]
    F --> G[Package Selection]
    G --> H[Install System]
    H --> I[Configure Bootloader]
    I --> J[Reboot to Linux]

Post-installation Tasks:

  • System Updates: Install latest security patches
  • Driver Installation: Configure hardware drivers
  • Software Installation: Add required applications

Common Partition Scheme:

  • / (root): 20GB minimum for system files
  • /home: User data storage
  • swap: 1-2x RAM size for virtual memory

Mnemonic: “DCBCPUPI - Download, Create media, Boot, Choose type, Partition, User setup, Package selection, Install”

Question 5(c) OR [7 marks]
#

Write a shell script to find sum and average of N numbers.

Answer:

#!/bin/bash
# Script to find sum and average of N numbers

echo "How many numbers do you want to enter?"
read n

# Validate input
if ! [[ $n =~ ^[0-9]+$ ]] || [ $n -le 0 ]; then
    echo "Error: Please enter a positive integer"
    exit 1
fi

sum=0
echo "Enter $n numbers:"

# Read N numbers and calculate sum
for ((i=1; i<=n; i++)); do
    echo -n "Enter number $i: "
    read number
    
    # Validate each number
    if ! [[ $number =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then
        echo "Error: Invalid number format"
        exit 1
    fi
    
    sum=$(echo "$sum + $number" | bc -l)
done

# Calculate average
average=$(echo "scale=2; $sum / $n" | bc -l)

# Display results
echo ""
echo "Results:"
echo "========="
echo "Count of numbers: $n"
echo "Sum: $sum"
echo "Average: $average"

# Additional statistics
echo ""
echo "Summary:"
echo "Total numbers processed: $n"
echo "Sum of all numbers: $sum"
echo "Average value: $average"

Algorithm Features:

  • Input Validation: Checks for positive count and valid numbers
  • Flexible Input: Accepts integers and decimal numbers
  • Precision Handling: Uses bc calculator for accurate arithmetic
  • Error Handling: Validates each input and provides error messages

Example Execution:

How many numbers do you want to enter? 5
Enter number 1: 10
Enter number 2: 20
Enter number 3: 30
Enter number 4: 40
Enter number 5: 50

Results:
=========
Count of numbers: 5
Sum: 150
Average: 30.00

Alternative Simple Version:

#!/bin/bash
read -p "Enter count: " n
sum=0
for ((i=1; i<=n; i++)); do
    read -p "Number $i: " num
    sum=$((sum + num))
done
echo "Sum: $sum"
echo "Average: $((sum / n))"

Key Programming Concepts:

  • Loop Control: For loop for iterating N times
  • Arithmetic Operations: Addition and division
  • Input/Output: Reading user input and displaying results
  • Data Validation: Ensuring input correctness

Mnemonic: “VLAD - Validate input, Loop for numbers, Arithmetic calculation, Display results”

Related

Linux Operating System (4331602) - Summer 2024 Solution
Study-Material Solutions Linux 4331602 2024 Summer
Electronic Measurements and Instruments (4331102) - Summer 2025 Solution
Study-Material Solutions Electronic-Measurements 4331102 2025 Summer
Essentials of Digital Marketing (4341601) - Summer 2025 Solution
Study-Material Solutions Digital-Marketing 4341601 2025 Summer
Java Programming (4343203) - Summer 2025 Solution
25 mins
Study-Material Solutions Java-Programming 4343203 2025 Summer
Microprocessor & Microcontroller Systems (1333202) - Summer 2025 Solution
22 mins
Study-Material Solutions Microprocessor Microcontroller 8085 8051 1333202 2025 Summer
Microprocessor and Microcontroller (4341101) - Summer 2025 Solution
17 mins
Study-Material Solutions Microprocessor Microcontroller 4341101 2025 Summer