Security and System Administration
Open in the Padhaiko app6.1 OS security: Cryptography, multi-factor authentication (MFA), secure boot and sandboxing
An operating system is secure when its hardware, software, and stored data are accessed and used strictly as intended. OS security rests on the CIA Triad:
- Confidentiality: Preventing unauthorized disclosure of sensitive data (enforced via authentication and encryption).
- Integrity: Protecting data and system files from unauthorized or accidental modification (enforced via permissions, checksums, and digital signatures).
- Availability: Ensuring authorized users can reliably access systems and data without disruption (maintained via upgrades, redundancy, and DoS mitigation).
A vulnerability is a weakness in system code or policy, a threat is the potential for violation, and an attack is an active attempt (masquerade, replay, modification, denial of service) or passive attempt (eavesdropping, traffic analysis) to exploit a vulnerability—including insider threats (logic bombs, trap doors, login spoofing) and malware (Trojan horses, viruses, worms, spyware, botnets).
Cryptography
Cryptography transforms readable plaintext () into unreadable ciphertext () using an encryption algorithm and key so that only authorized parties can recover the plaintext.
Symmetric vs. Asymmetric Cryptography
- Secret-Key (Symmetric) Cryptography: Both sender and receiver share a single secret key for encryption and decryption:
- Classic example (Mono-alphabetic substitution): Using a -letter key
QWERTYUIOPASDFGHJKLZXCVBNMforA–Z, the plaintextATTACKencrypts toQZZQEA.- Trade-off: Very fast in computation (e.g., AES), but requires a secure channel to share the secret key in advance.
- Public-Key (Asymmetric) Cryptography: Each participant holds a mathematically linked key pair: a public key (, shared openly) and a private key (, kept strictly secret).
- Confidentiality mode: Anyone encrypts a message with the receiver's ; only the receiver can decrypt it with .
- Trade-off: Solves key distribution without a pre-shared secret, though slower than symmetric ciphers (e.g., RSA, ECC).
Cryptographic Hashing and Digital Signatures
A digital signature proves the sender's identity (authentication), guarantees non-repudiation, and detects tampering (integrity):
- The sender passes the document through a one-way cryptographic hash function that produces a fixed-size digest (e.g., MD5: , SHA-1: , SHA-256: , SHA-512: ; MD5 and SHA-1 are now deprecated for security-critical signing in favor of SHA-256/SHA-512).
- The sender encrypts (signs) the hash digest using their private key to produce a signature block, and attaches it to .
- The receiver recomputes independently, decrypts the signature block using the sender's public key to obtain , and verifies . Any mismatch means or the signature was altered.
Multi-Factor Authentication (MFA)
Authentication verifies a user's claimed identity before granting a login session. Relying on a username and password alone is vulnerable to phishing, guessing, and login spoofing. Multi-Factor Authentication (MFA) requires combining two or more independent categories of credentials:
| Factor Category | Basis | Examples |
|---|---|---|
| Knowledge (Something you know) | Secret memorized by the user | Passwords, PINs, security challenge answers |
| Possession (Something you have) | Physical or hardware-backed token | Smart cards, FIDO2/USB security keys, TOTP authenticator apps, hardware OTP tokens |
| Inherence (Something you are) | Biometric characteristic | Fingerprint scan, facial recognition, iris/retina pattern |
Two-factor authentication (2FA)—such as a password plus a challenge-response token or biometric check—is the most common deployment of MFA in modern OS logins and enterprise systems.
Secure Boot
Secure Boot is a firmware-level security standard (part of UEFI) that prevents rootkits, bootkits, and tampered OS kernels from loading before the operating system takes control.
UEFI Secure Boot Verification Chain
Secure Boot establishes a cryptographic chain of trust anchored in firmware key databases:
- Platform Key (
PK): Root of trust controlled by the hardware/platform owner. - Key Exchange Key (
KEK): Authorizes updates to the signature databases. - Signature Database (
db) & Forbidden Database (dbx): Lists of trusted signing keys/hashes (db) and revoked/known-malicious binaries (dbx).
At power-on, UEFI verifies the digital signature of the bootloader against db (and confirms it is not in dbx). The bootloader in turn verifies the OS kernel image, and the kernel verifies signed kernel modules/drivers before execution. Any unsigned or tampered component halts the boot sequence.
Sandboxing
Sandboxing isolates an untrusted or network-facing program inside a tightly constrained execution environment so that even if the application is compromised, it cannot harm the host OS or read other applications' data.
6.2 Access control: Policies, lists, and OS support
Once a user is authenticated, the OS must decide which process may perform which operation on which resource.
Protection Domains and the Access Matrix
A computer system consists of hardware and software objects (CPUs, memory segments, printers, files, databases, semaphores), each supporting a finite set of operations.
Protection Domain and Access Matrix
- A protection domain is a set of
(object, rights)pairs defining every object a process running in that domain may access and which operations (read,write,execute, etc.) are permitted. - An access (protection) matrix models system-wide permissions as a 2D table: rows represent domains (users/roles/processes), columns represent objects, and cell lists the rights of domain on object .
Because most domains have no rights on most objects, storing the full access matrix in memory or on disk wastes huge space. Operating systems therefore store only non-empty entries using Access Control Lists (ACLs) (by column) or Capability Lists (by row).
Access Control Lists (ACLs)
An Access Control List (ACL) stores one column of the access matrix directly with each object: an ordered list of (subject, rights) entries specifying which users or groups are allowed (or explicitly denied) specific permissions such as Read, Write, Execute, Delete, Create, Modify, List, or Full Control.
| Aspect | Access Control List (ACL) | Capability List |
|---|---|---|
| Matrix Decomposition | Stored per object (column of the matrix) | Stored per domain/process (row of the matrix) |
| Permission Lookup | OS checks the object's ACL when a subject requests access | Process presents an unforgeable capability ticket for the object |
| Revocation | Easy—edit or remove the entry in the object's ACL | Harder—must locate and invalidate distributed tickets |
| Typical OS Usage | UNIX/Linux POSIX ACLs, Windows NTFS DACLs | Microkernels, object-capability systems (e.g., seL4, Capsicum) |
Access Control Policies
DAC, MAC, and RBAC Policies
- Discretionary Access Control (DAC): The resource owner decides who may access the object and can transfer permissions (e.g., standard Linux
chmod/ Windows file sharing). Flexible, but vulnerable to Trojan horses acting with the owner's privileges. - Mandatory Access Control (MAC): A central system-wide security policy labels both subjects (clearance) and objects (classification); individual owners cannot override it (e.g., Bell–LaPadula confidentiality model, SELinux, AppArmor).
- Role-Based Access Control (RBAC): Permissions are assigned to organizational roles (e.g.,
DatabaseAdmin,Auditor,Student), and users are assigned to one or more roles. Simplifies administration in large organizations.
OS Support for Access Control
- Linux / UNIX: Every file stores basic permission bits (
rwxfor owner, group, and others, encoded in octal where ) plus special bits (SUID,SGID,sticky), managed withchmodandchown. For finer multi-user rules, Linux supports POSIX ACLs (getfacl/setfacl) and MAC frameworks (SELinux, AppArmor). - Windows: Every NTFS file/folder carries a Security Descriptor containing a Discretionary ACL (DACL) made of ordered Access Control Entries (
AllowandDeny, with explicitDenyevaluated first) and a System ACL (SACL) for auditing. User Account Control (UAC) ensures even administrators run routine apps with a filtered standard token until explicit elevation is approved.
6.3 System administration: User management, environment setup and tools (AWK, shell scripts, make)
System administration is the operational management of computers, operating systems, application software, networks, and users in an organization. Core administrator duties include applying OS updates and patches, installing hardware/software, managing user accounts, tuning performance, running backups, auditing security, inspecting system logs, and troubleshooting failures.
User Management
Multi-user operating systems isolate each person's workspace into an individual user account, each maintaining its own profile, application settings, private data folder, security privileges, and file system permissions.
| Account Type | Privilege Scope | Intended Use & Notes |
|---|---|---|
| Standard User | Can run apps, manage personal files/settings, connect to networks, and use external USB devices; cannot make system-wide changes or install drivers | Default account for everyday work (follows the principle of least privilege) |
Administrator (root / Admin) | Full system control: installs software/drivers, modifies OS files, configures firewalls/UAC, performs full backups, and creates/deletes user accounts | Used strictly for administrative tasks; on Linux invoked temporarily via sudo |
| Guest | Minimal temporary access with no persistent profile and no access to other users' files or system settings | Disabled by default for security |
On Linux, administrators manage accounts and groups from the CLI using useradd / adduser, usermod, passwd, userdel, and groupadd, backed by /etc/passwd, /etc/shadow (hashed passwords), and /etc/group. On Windows, account creation, password resets, account type changes, and deletion are performed via Control Panel / Settings or net user / PowerShell.
Environment Setup
When provisioning a new user or workstation, the administrator configures a working operational environment so users can log in and launch required tools without editing shell internals manually:
- Software baseline: Install the OS, essential packages, utilities, and custom menu wrappers (
user-setup) where appropriate. - Environment variables & startup scripts: On Linux/UNIX, system-wide defaults live in
/etc/profileand/etc/environment, while per-user configuration lives in~/.bashrcor~/.profile(settingPATH,HOME,SHELL,LANG,EDITOR, and aliases). On Windows, user and system environment variables are configured in System Properties or PowerShell ().
System Administration Tools: AWK, Shell Scripts, and Make
1. AWK
AWK (named after Aho, Weinberger, and Kernighan) is an interpreted pattern-scanning and text-processing language widely used by administrators to filter logs, extract columns, and generate formatted reports without compiling a program.
AWK Execution Model and Syntax
awk [options] 'pattern { action }' input-fileFor every input line (record), AWK automatically:
- Splits the line into whitespace-delimited fields (or using a custom delimiter via
-F fs): , , ..., , while holds the entire line. - Evaluates
pattern(a regex/text/or boolean condition like , orBEGIN/END). - Executes
{ action }on every matching line (-f prog.awkreads rules from a file). Built-in variables includeNR(current record/line number) andNF(number of fields in the current line).
# Print every line (default action when no pattern is given)
awk '{print}' employee.txt
# Print only lines matching the pattern "manager"
awk '/manager/ {print}' employee.txt
# Print columns 1 (Name) and 4 (Salary) using space or ':' delimiter
awk '{print $1, $4}' employee.txt
awk -F ':' '{print $1, $3}' /etc/passwdCompared to sed, AWK provides native numeric arithmetic, variables, control flow (if/for), built-in string/math functions, and automatic field splitting in a C-like syntax.
2. Shell Scripts
A shell script is a plain-text file containing a sequence of OS commands, variables, conditionals, and loops executed by a command interpreter (such as /bin/sh or /bin/bash) to automate repetitive administration tasks (backups, log rotation, bulk account creation).
#!/bin/bash
# backup_check.sh - Archive /home and warn if disk usage exceeds 80%
BACKUP_DIR="/var/backups"
DATE_TAG=$(date +%F)
tar -czf "$BACKUP_DIR/home-$DATE_TAG.tar.gz" /home
USAGE=$(df / | awk 'NR==2 {gsub(/%/, "", $5); print $5}')
if [ "$USAGE" -gt 80 ]; then
echo "WARNING: Root filesystem at ${USAGE}% capacity"
exit 1
fi
echo "Backup complete; disk usage normal (${USAGE}%)."
exit 03. Make
make is a build-and-task automation utility driven by a file named Makefile. Instead of running every compile or setup command blindly from scratch, make builds a dependency graph and compares file modification timestamps—re-executing only the steps whose inputs (prerequisites) are newer than their output (target).
CC = gcc
CFLAGS = -Wall -O2
app: main.o utils.o
$(CC) $(CFLAGS) -o app main.o utils.o
main.o: main.c defs.h
$(CC) $(CFLAGS) -c main.c
utils.o: utils.c defs.h
$(CC) $(CFLAGS) -c utils.c
clean:
rm -f *.o appEach rule has the form target: prerequisites followed by tab-indented recipe commands. If only utils.c is edited, running make recompiles utils.o and relinks app, skipping main.o. Beyond C builds, administrators use Makefiles to automate configuration regeneration (e.g., rebuilding /etc/aliases or deploying config templates).
Worked Out Examples
6.1
In a small-scale RSA public-key cryptosystem, choose primes and with public exponent .
- Compute the modulus , Euler's totient , and the private exponent .
- Encrypt the plaintext integer to obtain ciphertext , and verify decryption back to .
Computing and :
Finding the private exponent : is the modular inverse of modulo , satisfying :
Public key is and private key is .
Encrypting and decrypting :
- Encryption: (since and ).
- Decryption: . Since :
Dividing , we recover .
, , ; ciphertext is , which decrypts back to .
6.2
- Convert the following Access Matrix into Access Control Lists (ACLs) per object:
- Alice:
report.doc(Read, Write),backup.sh(Read, Write, Execute),printer(Use) - Bob:
report.doc(Read),backup.sh(Execute) - Charlie:
printer(Use)
- Alice:
- Express the Linux permission strings
-rwxr-x---and-rw-r-----in octal form forchmod.
Deriving the ACL for each object (column-wise extraction):
ACL(report.doc):[(Alice: R, W), (Bob: R)]ACL(backup.sh):[(Alice: R, W, X), (Bob: X)]ACL(printer):[(Alice: Use), (Charlie: Use)]
Notice that empty cells (such as Charlie on report.doc) are omitted.
Computing octal chmod values ():
- For
-rwxr-x---:- Owner (
rwx): - Group (
r-x): - Others (
---): - Octal mode =
- Owner (
- For
-rw-r-----:- Owner (
rw-): - Group (
r--): - Others (
---): - Octal mode =
- Owner (
ACLs: report.doc (Alice: RW, Bob: R), backup.sh (Alice: RWX, Bob: X), printer (Alice: Use, Charlie: Use). Octal modes: -rwxr-x--- = 750, -rw-r----- = 640.
6.3
Given employee.txt with records:
ajay manager account 45000sunil clerk account 25000varun manager sales 50000amit manager account 47000tarun peon sales 15000
Write a single AWK command that prints each manager's name and salary, and at the end prints the total manager payroll. Trace its exact output.
Writing the pattern-action AWK command: We match /manager/ (or ) in the body rule, accumulate sum += ..., and print the accumulated total inside an END block:
awk '$2 == "manager" { print $1, $4; sum += $4 } END { print "Total:", sum }' employee.txtTracing line-by-line execution:
- Line 1 (
ajay manager ...): matches printsajay 45000,sum = 45000. - Line 2 (
sunil clerk ...): skipped. - Line 3 (
varun manager ...): matches printsvarun 50000,sum = 45000 + 50000 = 95000. - Line 4 (
amit manager ...): matches printsamit 47000,sum = 95000 + 47000 = 142000. - Line 5 (
tarun peon ...): skipped. - End of file (
ENDblock): printsTotal: 142000.
Output: ajay 45000, varun 50000, amit 47000, Total: 142000.
Exercises
Exercise — Security and System Administration
Differentiate between secret-key (symmetric) and public-key (asymmetric) cryptography, and explain how a digital signature verifies both authenticity and integrity. Using RSA with primes , , and , find the private key , encrypt message , and verify decryption.
Symmetric vs. asymmetric cryptography and digital signatures:
- Secret-key cryptography uses one shared secret key for encryption and decryption (fast, but requires secure key distribution).
- Public-key cryptography uses a public encryption key and a secret private decryption key.
- For a digital signature, the sender hashes the document (e.g., SHA-256) and signs the hash with their private key; the receiver hashes the received document and compares it with the digest decrypted by the sender's public key.
Computing RSA parameters ():
We solve : since , we get .
Encrypting and checking decryption:
- Ciphertext: .
- Decryption: . Using , , , :
Private key (with ); ciphertext is , which decrypts back to .
Explain Multi-Factor Authentication (MFA), Secure Boot, and Sandboxing, noting the specific OS threat each mechanism mitigates.
Multi-Factor Authentication (MFA): Requires credentials from at least two independent factors—knowledge (password/PIN), possession (hardware token/authenticator app), and inherence (biometrics). It mitigates password theft, brute-force cracking, and phishing.
Secure Boot: UEFI verifies cryptographic signatures (against PK/KEK/db and checking revocation list dbx) at every early boot stage from firmware to bootloader to OS kernel. It prevents bootkits and kernel-level rootkits from executing before the OS loads.
Sandboxing: Confines untrusted applications using syscall filtering (seccomp), isolated namespaces/filesystems, and minimal capabilities so a compromised program (e.g., a browser tab or mobile app) cannot tamper with the host OS or read other users' files.
MFA blocks credential theft by combining knowledge, possession, and biometric factors; Secure Boot prevents pre-OS bootkits via a firmware-to-kernel signature chain; Sandboxing contains compromised apps by restricting syscalls, namespaces, and file access.
Compare Discretionary Access Control (DAC), Mandatory Access Control (MAC), and Role-Based Access Control (RBAC), and explain why operating systems implement ACLs or Capability Lists instead of storing a full Protection Matrix.
Comparing access control policies:
- DAC: Resource owners control and share permissions on their own objects (e.g.,
chmod, NTFS permissions). - MAC: Central kernel policy enforces security labels regardless of owner wishes (e.g., SELinux, AppArmor).
- RBAC: Access rights are bundled into roles (
Admin,Instructor) and users inherit rights by role membership.
Why ACLs/Capabilities replace the full Protection Matrix: A full Protection Matrix of domains objects is mostly empty (sparse), wasting memory/disk space and lookup time. Storing non-empty entries by column yields an ACL (fast per-object auditing and easy revocation), whereas storing by row yields a Capability List (fast per-process token verification).
DAC is owner-controlled, MAC is system-enforced via labels, and RBAC maps rights to roles. ACLs (columns) and Capability Lists (rows) avoid storing the huge, sparse Protection Matrix.
Distinguish between Standard User, Administrator, and Guest accounts in OS user management. Also calculate the numeric chmod octal values for -rwxr--r-- and -rw-rw----, and explain what each digit grants.
Account types:
- Standard User: Runs applications and modifies personal files/settings only; cannot alter system files or install drivers.
- Administrator: Has unrestricted control over OS configuration, software installation, firewalls, backups, and all user accounts.
- Guest: Temporary, tightly restricted account without persistent profile storage (disabled by default for security).
Calculating octal permission modes ():
-rwxr--r--: Owner , Group , Others744(owner can read/write/execute; group and others can read only).-rw-rw----: Owner , Group , Others660(owner and group can read/write; others have no access).
Standard accounts perform daily non-system tasks, Administrator accounts control system-wide changes, and Guest accounts provide temporary minimal access. -rwxr--r-- = 744; -rw-rw---- = 660.
Suppose /etc/staff.csv uses : as a delimiter (name:role:dept:salary) and contains: ajay:manager:acct:45000, sunil:clerk:acct:25000, varun:manager:sales:50000, amit:manager:acct:47000, satvik:director:purch:80000. Write an AWK command to print the names of employees earning more than and compute their average salary. Verify the resulting average.
Constructing the AWK command with -F ':': We specify -F ':' so field is name and field is salary:
awk -F ':' '$4 > 30000 { print $1; sum += $4; count++ } END { if (count > 0) print "Average:", sum / count }' /etc/staff.csvComputing the matched rows and average: Four employees satisfy salary > 30000: ajay (), varun (), amit (), and satvik ().
Names printed: ajay, varun, amit, satvik; Average salary = 55500.
Explain the roles of shell scripts and make in system administration. Write a Makefile for a C program consisting of main.c, net.c, and net.h producing executable monitor, and explain what happens if only net.c is modified before running make.
Roles of shell scripts and make:
- Shell scripts automate sequential administrative tasks (backups, log checks, user provisioning) using OS commands, variables, conditionals, and loops.
makeautomates dependency-driven builds or configuration updates via aMakefile, comparing file timestamps so only out-of-date targets are rebuilt.
Writing the Makefile:
CC = gcc
CFLAGS = -Wall -O2
monitor: main.o net.o
$(CC) $(CFLAGS) -o monitor main.o net.o
main.o: main.c net.h
$(CC) $(CFLAGS) -c main.c
net.o: net.c net.h
$(CC) $(CFLAGS) -c net.cIncremental rebuild behavior when net.c changes: main.o is still newer than both main.c and net.h, so make skips recompiling main.o. Because net.c is newer than net.o, make recompiles net.o, and since net.o is now newer than monitor, make relinks monitor.
Shell scripts automate sequential workflows, while make performs timestamp-based incremental builds. Modifying net.c causes make to recompile only net.o and relink monitor, leaving main.o untouched.