Module 3 Part I
Module 3 Part I
EK-AP_SJCET 1
Computer System Software
• System software is a program designed to
run a computer's hardware and applications
and manage its resources, such as its
memory, processors, and devices.
• System software manages a computer's
resources and provides standard functions
for computer programs.
• The operating system, as well as a range of
utility programs that manage a computer's
resources and provide basic services for
computer programs, are common
components of system software.
EK-AP_SJCET 2
Operating Systems
• The operating system acts as a system manager, controlling both hardware
and software and acting as an interface between the user and the system. The
operating system itself consists of a collection of programs that work
together collectively to accomplish these tasks.
• An operating system may be defined as
✓ the operating system is a collection of program it acts as an intermediary
between the user and the user’s programs and the hardware of the computer.
It makes the resources available to the user and the user’s programs in a
convenient way, and controls and manages the hardware.
• In other words,
➢ Operating system manages a computer’s hardware.
➢ Provides a basis for application programs.
➢ Acts as an interface between the computer user and the computer
hardware.
EK-AP_SJCET 3
• The user interacts with the computer system,
typically using an interface (keyboard, mouse,
etc.).
• Application Programs are software programs
that users use to perform specific tasks (e.g.,
web browsers, word processors, video editors).
• The OS acts as a bridge between application
programs and hardware. It manages resources,
runs applications, and handles input/output
operations.
• Modern computing environments are
connected to networks for communication.
This includes servers, clouds etc.
EK-AP_SJCET 4
• Diagram illustrates the simplified structure
of operating system services and how they
interact with different components in a
computer system.
• The user interacts with the application
program (e.g., web browser, text
editor).The application program sends
requests to the operating system to perform
various tasks.
• The OS acts as a bridge between
applications and hardware, providing
essential services.
EK-AP_SJCET 5
Key Components
• Kernel: Kernel is the core of the OS that directly manages hardware resources such
as CPU, memory, and input/output devices. It is a memory resident components of
an operating system.
• Shell: The shell acts as an interface between the user and the kernel. It interprets
user commands and translates them into actions that the kernel can execute. Shells
can be Command-Line Interface or Graphical User Interface. The shell is not
always required for system operations but is needed for user interaction.
• File System: It organizes and manages files on storage devices, providing a way to
read, write, and store data.
• Device Drivers: They facilitate communication between the OS and hardware
devices such as printers, graphics cards, and network adapters.
• User Interface (UI): The User Interface (UI) allows users to interact with the
operating system, and in many cases, this interaction occurs through the shell,
which acts as an intermediary between the user and the kernel.
EK-AP_SJCET 6
Multitasking and Multiprogramming in OS
• Modern computer systems enable users to work
with more than one program at the same time as a
way to improve their efficiency
• Multi-programming increases CPU utilization by
organizing jobs (code and data) so that the CPU
always has one to execute. The idea is to keep
multiple jobs in the main memory. If one job gets
occupied with IO, the CPU can be assigned to
another job.
• Multi-tasking is a logical extension of
multiprogramming. In multi-tasking systems, the
CPU executes multiple jobs by switching among
them typically using a small time interval, and the
switches occur so quickly that the users feel like
interact with each executing task at the same time.
EK-AP_SJCET 7
Functions of Operating Systems
The primary functions of an operating system are:
• Process Management: Process is a program in execution. The OS is
responsible for managing processes, which includes the creation, scheduling,
and termination of processes.
• Memory Management: The OS manages the computer’s main memory, by
allocating and deallocating memory space for processes as they run.
• File System Management: The OS organizes files and directories on storage
devices (e.g., hard drives, SSDs). It provides functions for file creation,
deletion, reading, writing. and access control.
• Device Management: The OS manages input and output devices such as
printers, keyboards, mice, and storage devices. It acts as an intermediary
between hardware and software, ensuring that hardware devices are utilized
correctly.
EK-AP_SJCET 8
• Security and Access Control: The OS provides security features such as
authentication, authorization, and encryption to protect data and system
resources. It ensures that users can only access resources for which they have
permission, and it manages access to sensitive data.
• User Interface (UI): The OS provides an interface through which users can
interact with the system (e.g., command-line interface or graphical user
interface).
• Storage Management: the computer system must provide secondary
storage to back up main memory. Disks can be used as a storage medium.
Proper management of disks are important. OS is responsible for the
following disk management activities: Free space management, Storage
allocation, Disk scheduling etc
EK-AP_SJCET 9
• Networking: The OS manages network connections, enabling
communication between computers and devices over a network. It supports
protocols such as TCP/IP to facilitate data exchange between systems.
• Resource Allocation: The OS is responsible for efficiently allocating system
resources, such as CPU time, memory, and 1/O devices, based on demand
from various processes. It optimizes resource usage and ensures fair
distribution among running tasks.
• Error Detection and Handling: The OS continuously monitors system
operations to detect hardware or software errors and handles them
appropriately.
• System Performance Monitoring: The OS monitors system performance,
keeping track of CPU usage, memory usage, disk usage, etc. It may provide
tools or utilities to allow users or administrators to assess system
performance and make adjustments when necessary.
EK-AP_SJCET 10
Basic commands in Linux / Windows
• The basic syntax of a user input command on shell prompt is comprised of
the name of the command followed by various associated options with the
command and then a list of arguments. The command syntax is given as
follows:
$<command_name> <-options> <List_of_arguments>
ls (List Directory Contents)
• The ls command is used to list files and directories in a specified location.
• Syntax: ls [options] [directory]
• Common Options:
• ls → Lists files and directories in the current directory.
• ls -l → Displays detailed information (permissions, ownership, size, and
modification date).
• ls -a → Lists all files, including hidden files (files that start with .).
• ls -R → Recursively lists all subdirectories
EK-AP_SJCET
and their contents. 11
mkdir (Make Directory)
• The mkdir command is used to create new directories.
• Example : mkdir new → Creates a single directory named new.
cd (Change Directory)
• The cd command allows users to navigate between directories.
• Syntax: cd [directory]
• Common Usages:
• cd dirname → Moves into the specified directory.
• cd .. → Moves one level up to the parent directory.
• cd / → Moves to the root directory.
• cd ~ or cd → Moves to the user's home directory.
pwd (Print Working Directory)
• The pwd command displays the current working directory (i.e., the full
path of the directory you are in). EK-AP_SJCET 12
cp (Copy Files and Directories)
• The cp command is used to copy files and directories from one location to
another.
• Syntax: cp [options] source destination
• Common Options:
• cp file1 file2 → Copies file1 to file2.
• cp -r dir1 dir2 → Recursively copies a directory along with its
contents.
• cp -i file1 file2 → Asks for confirmation before overwriting an existing
file.
mv (Move or Rename Files and Directories)
• The mv command is used to move or rename files and directories.
• Syntax: mv [options] source destination
EK-AP_SJCET 13
• Common Usages :
• mv oldname newname → Renames a file or directory.
• mv file.txt /home/user/docs/ → Moves file.txt to the docs directory.
EK-AP_SJCET 16
Basic commands in Windows
Windows Command Prompt (CMD) is a powerful tool that allows users to interact with
the operating system directly. Learning basic commands can enhance troubleshooting
skills and improve productivity.
1. Opening Command Prompt
• Command: cmd
• Explanation: Opens the Command Prompt.
• Example:
Press Windows + R.
Type cmd and press Enter.
2. Displaying Current Directory
• Command: cd
• Explanation: Displays or changes the current directory.
• Example:
cd Documents
Changes to the Documents directory.
EK-AP_SJCET 17
3. Viewing Files and Folders
• Command: dir
• Explanation: Lists files and directories in the current directory.
• Example:
dir
Shows all files and folders in the current location.
4. Creating a New Folder
• Command: mkdir
• Explanation: Creates a new directory.
• Example:
mkdir NewFolder
Creates a folder named NewFolder.
5. Deleting a Folder
• Command: rmdir
• Explanation: Removes a directory (must be empty).
• Example:
rmdir OldFolder
Deletes the OldFolder directory.
EK-AP_SJCET 18
6. Deleting Files
• Command: del
• Explanation: Deletes files.
• Example:
del file.txt
Deletes the file named file.txt.
7. Renaming Files or Folders
• Command: rename
• Explanation: Renames a file or folder.
• Example:
rename oldfile.txt newfile.txt
Renames oldfile.txt to newfile.txt.
8. Copying Files
• Command: copy
• Explanation: Copies files from one location to another.
• Example:
copy file.txt D:\Backup
Copies file.txt to the Backup folder in drive D.
EK-AP_SJCET 19
9. Moving Files
• Command: move
• Explanation: Moves files to a new location.
• Example:
move file.txt D:\Documents
Moves file.txt to the Documents folder in drive D.
10. Clearing the Screen
• Command: cls
• Explanation: Clears the Command Prompt screen.
• Example:
cls
Clears the current screen.
11. Viewing Network Information
• Command: ipconfig
• Explanation: Displays IP address and network details.
• Example:
ipconfig
Shows network configuration and IP address.
EK-AP_SJCET 20
12. Checking Connectivity (Ping)
• Command: ping
• Explanation: Tests connectivity to a website or IP address.
• Example:
ping google.com
Checks if Google is reachable.
13. Shutting Down the Computer
• Command: shutdown
• Explanation: Shuts down or restarts the computer.
• Example:
shutdown /s /t 60
Shuts down the computer in 60 seconds.
14. Exiting Command Prompt
• Command: exit
• Explanation: Closes the Command Prompt.
• Example:
Exit (Exits the terminal.)
EK-AP_SJCET 21
Shell Scripting
• Shell Scripting Introduction
• Interpretive Cycle of Shells
• Shell Variables
• Types of Shell Variables
✓ Global Variables
✓ Local Variables
• Shell Variables and their Characteristics
✓ Variable "Type" in Shell
✓ Creating and Setting User-Defined Variables
✓ Exporting and Unsetting Variables
• Command Execution in Shell
• Special Characters in Shell
✓ Sequence Commands
✓ Grouped Commands
✓ Conditional Commands
✓ Conditional Loops
EK-AP_SJCET 22
Shell Scripting
• A shell is a command language interpreter that provides a command-line
user interface (CUI) for interacting with the Linux/Unix system.
• It acts as an interface between the kernel (the core of the operating system)
and the end user, enabling system interaction and administration.
What is a Command-Line Interpreter?
• A command-line interpreter (CLI) is a program that allows users to interact
with the operating system using text-based commands.
• Instead of using a graphical interface (GUI), users type commands at a
command prompt, and the shell processes and executes them.
EK-AP_SJCET 23
Functions of a Shell
• Command Execution: Accepts and processes user commands.
• Command Interpretation: Translates human-readable commands into
system instructions.
• Shell Scripting: Allows users to write shell scripts, which are sequences of
commands stored in a file for automation.
• Interactive Mode: The shell waits for user input, executes commands, and
displays the output.
• Batch Mode: Executes multiple commands from a script without user
intervention.
• Process Management: Controls and manages processes in the operating
system.
EK-AP_SJCET 24
• Types of Shells:
• Bourne Shell (sh): The first Unix shell, developed by Stephen Bourne.
• Bourne Again Shell (bash): An improved GNU version of sh, widely
used in Linux distributions.
• How a Shell Works in Linux?
• When the system boots, Linux verifies the user's username and password.
• After successful login, the shell starts and provides a command prompt
(text-based interface).
• The user enters commands (e.g., ls, cd, mkdir), which the shell interprets
and sends to the kernel for execution.
• The output of the command is displayed on the terminal.
• The shell again displays the command prompt, ready for new commands.
EK-AP_SJCET 25
Why Use a Shell in Linux?
• The shell provides a powerful programming environment that allows users
to automate tasks and efficiently interact with the Linux system. Some key
reasons to use a shell are:
• Direct system access: Shells access system calls directly through
command names.
• Multi-user support: Multiple users can log in and perform tasks
independently.
• Automation: Shell scripts allow users to store and execute multiple
commands in a file, reducing repetition.
• Flexibility: Each shell has its own syntax, semantics, and built-in
functions for scripting.
• Modularity: The shell is not a part of the kernel, but it works with it to
execute applications. Users can choose and install different shells based
on their preferences.
EK-AP_SJCET 26
The Login Shell (Shell Prompt)
• After a successful login, the shell prompt appears on the console:
$ → for a regular user
# → for a root (administrator) user
• Although the prompt seems idle, a Unix process is running, which is the
shell itself (e.g., bash). You can verify the currently running shell using:
$ ps
$ echo $SHELL
$ ps $$
• The output may vary depending on the installed shell (e.g., /bin/bash for
bash, /bin/sh for sh, /bin/ksh for Korn shell).
EK-AP_SJCET 27
Command-Line Editing Shortcuts:
• The shell supports various keyboard shortcuts for efficient command-line editing:
• Ctrl+L: Clear the screen (similar to the clear command).
• Ctrl+W: Delete the word before the cursor.
• Ctrl+U: Delete the line before the cursor.
• Up/Down Arrow Keys: Navigate through command history.
• Ctrl+R: Search for previously used commands.
• Ctrl+C: Kill the currently running command.
• Ctrl+A: Move to the beginning of the line.
• Ctrl+E: Move to the end of the line.
• Alt+F: Move the cursor forward by one word.
• Alt+B: Move the cursor backward by one word.
• Ctrl+H: Acts like the Backspace key.
• Ctrl+T: Swap the last two characters before the cursor.
• Esc+T: Swap the last two words before the cursor.
• Ctrl+K: Delete the line after the cursor
EK-AP_SJCET 28
Interpretive Cycle of Shells
• The shell is a common feature in all Linux distributions, with GNU bash being
the default shell.
• Various Linux shells exist, with continuous improvements for better system
interaction.
• Interpretive Cycle of Shell as follows-
• Accepting a command – The shell displays a prompt ($ or # in bash) and waits
for user input.
• Interpreting the command – The shell processes metacharacters, expands
abbreviations, and reconstructs the command.
• Executing the command – The shell sends the simplified command to the kernel
for execution.
• Giving output – The shell receives and displays the output after execution.
• Waiting for the next command – The shell returns to the prompt, ready for
further commands.
EK-AP_SJCET 29
Shell Variables
• Shell scripting allows users to automate tasks and create custom commands
for efficient workflows.
• Like other programming languages, Bash supports variables, which store
data in memory for further processing.
• Variables provide a way to store, retrieve, and manipulate data in shell
scripts.
Types of Shell Variables
Global Variables (Environment Variables)
• Global variables are accessible across all active shell sessions, including
subshells.
• They are essential for running applications and processes, as they allow
child processes to access parent process data.
• Linux sets many predefined environment variables when a shell session
starts. EK-AP_SJCET 30
• Use the following commands to display global environment variables:
$ printenv # Display all global environment variables
EK-AP_SJCET 32
2) Creating and Setting User-Defined Variables
Declaring and Assigning Values
• Variables are created and assigned using the = operator:
my_var="Hello, World!" # Assigning a string value
num_var=100 # Assigning a number (still treated as a string)
• No spaces are allowed around =.
Accessing Variables
• Use the $ symbol to retrieve a variable’s value:
echo $my_var # Output: Hello, World!
echo $num_var # Output: 100
EK-AP_SJCET 33
3) Exporting and Unsetting Variables
• Exporting a variable makes it available to subshells (Globally Accessible):
export my_var="Hello"
• Unsetting (removing) a variable:
unset my_var
echo $my_var # Output: (empty)
EK-AP_SJCET 34
Special Characters in Shell
• Special characters have specific meanings in the shell.
EK-AP_SJCET 35
Sequence Commands (;)
• Commands separated by ; are executed sequentially, regardless of success
or failure.
• Example:
echo "Hello"; ls; date
This will print "Hello", list files, and show the date even if ls fails.
EK-AP_SJCET 37
EK-AP_SJCET 38
Conditional loops
• while command: It repeats the execution as long as its test condition is true.
while command
do
command
done
• until command: It repeats the execution as long as its test condition is false
until command
do
command
done
• for ((expression; expression; expression)): It starts the loop by evaluating the first
arithmetic expression; repeats the loop as long as the second expression condition is
successful; and at the end of each loop, evaluates the third arithmetic expression.
for ((i = 1; i <= 5; i++))
do
echo "Iteration number: $i"
done EK-AP_SJCET 39