2.0 Operating Systems & Linux Basics Flashcards

(167 cards)

1
Q

2.0 Operating Systems & Linux Basics

What is the role of an operating system in relation to applications and hardware?

A

The OS acts as an abstraction layer between applications and hardware, allowing apps to function without directly interacting with CPU, memory, disk, or devices.

This enables applications to run smoothly across different hardware configurations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

2.0 Operating Systems & Linux Basics

Why can’t applications like browsers be installed directly on hardware?

A

Hardware only understands low-level machine operations.

The OS provides the environment, services, and APIs apps need to run. This separation allows for greater flexibility and compatibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

2.0 Operating Systems & Linux Basics

What does the OS manage as software resources?

8 things. Try to name 5 of them.

A
  • CPU processes
  • RAM allocation
  • Disk storage
  • File systems
  • Devices
  • Networking
  • Users
  • Security

Effective management of these resources is crucial for system performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

2.0 Operating Systems & Linux Basics

How does the OS manage the CPU when only one CPU core can run one process at a time?

A

The OS schedules which process gets CPU time, for how long, and switches rapidly between processes to create the illusion of parallelism.

This technique is known as time-sharing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

2.0 Operating Systems & Linux Basics

What is RAM and why must the OS manage it?

A

Rapid Access Memory is fast working volatile memory; it is limited, so the OS decides how much memory each process receives and reclaims unused memory.

Efficient memory management is essential to prevent memory leaks and system slowdowns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

2.0 Operating Systems & Linux Basics

What is secondary memory and what is stored there?

A

The hard drive/SSD; used for long-term storage like files, configurations, images, and application data.

Secondary memory retains data even when the computer is turned off.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

2.0 Operating Systems & Linux Basics

How is the file system structured in Unix/Linux versus Windows?

A

Unix uses a single-root tree structure (/)

Windows uses multiple root drives (C:\, D:\, etc.).

This difference affects how files are organized and accessed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

2.0 Operating Systems & Linux Basics

How does the OS manage devices such as keyboards, disks, and network adapters?

A

Through device drivers

The OS tracks devices, decides which process can access each device, and for how long.

Device drivers act as translators between the OS and hardware.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

2.0 Operating Systems & Linux Basics

What are the OS’s responsibilities for security?

just name a few…

A

An operating system is responsible for enforcing the fundamental security boundaries on a machine. This includes:

  • authenticating users
  • enforcing permissions
  • isolating processes
  • protecting system resources
  • logging activity

At a high level, the OS must:

Manage user authentication & identities
- Validate users (passwords, keys, tokens) and control who can log in.

Enforce authorization & permissions
- File permissions, process rights, SELinux/AppArmor, ACLs—deciding who can do what.

Isolate processes
- Prevent processes from interfering with each other (memory isolation, namespaces, cgroups).

Protect system resources
- CPU, memory, storage, and networking are allocated and guarded from misuse.

Maintain system integrity
- Kernel protections, secure boot, system libraries, and integrity checks.

Provide auditing & logging
- Track security events, log access attempts, and enable incident investigation.

Apply updates & patches
- Keep the kernel and system components secure through timely patching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

2.0 Operating Systems & Linux Basics

How does the OS manage networking?

3 things…

A
  • assigns ports/IPs
  • handles outgoing data
  • forwards incoming packets to the correct process

Networking management is vital for communication between devices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

2.0 Operating Systems & Linux Basics

What is the kernel in an OS?

A

The core program that…
- controls hardware
- manages devices
- runs processes
- assigns resources
- provides low-level services

The kernel is essential for the overall functionality of the operating system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

2.0 Operating Systems & Linux Basics

Why is the kernel one of the first programs loaded at startup?

A

Because without the kernel, the OS cannot function

All hardware control and resource management depend on it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

2.0 Operating Systems & Linux Basics

What does the kernel do when an application starts and ends?

A

It starts the process, allocates CPU/RAM, provides I/O access, and cleans up resources when the app closes.

This process is crucial for efficient resource management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

2.0 Operating Systems & Linux Basics

What sits on top of the kernel in an OS?

A

The application layer, including both GUI and CLI interfaces.

This layer allows users to interact with the system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

2.0 Operating Systems & Linux Basics

Why do different Linux distributions still share the same kernel?

A

Distros customize user applications and tooling, but all rely on the same underlying Linux kernel.

This shared foundation allows for compatibility and community support.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

2.0 Operating Systems & Linux Basics

What is the difference between a client OS and a server OS?

A

Client OS includes GUI and user apps; server OS focuses on performance, security, and typically has no GUI.

This distinction affects how systems are used in different environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

2.0 Operating Systems & Linux Basics

Why are macOS and Linux similar at the CLI level?

A

Both follow Unix concepts and are POSIX-compliant, making their command-line behavior and file structures similar.

This similarity facilitates user transition between the two systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

2.0 Operating Systems & Linux Basics

What is POSIX?

A

A standard ensuring compatibility and uniform behavior across Unix-like operating systems.

POSIX compliance is crucial for software portability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

2.0 Operating Systems & Linux Basics

How was Linux created and how does it relate to Unix?

A

Created in 1991 by Linus Torvalds as a Unix-like OS clone since Unix code wasn’t available. Both are POSIX compliant.

This historical context highlights the evolution of operating systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

2.0 Operating Systems & Linux Basics

Why must DevOps engineers learn Linux?

A

Because Linux powers most servers, cloud platforms, and DevOps tooling; DevOps engineers must install, configure, and manage Linux-based systems.

Proficiency in Linux is essential for effective DevOps practices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

2.0 Operating Systems & Linux Basics

Why is Linux used for servers more than Windows or macOS?

A

It’s lightweight, efficient, highly configurable, secure, and widely supported in cloud and container environments.

These attributes make Linux a preferred choice for server environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

2.0 Operating Systems & Linux Basics

What is virtualization?

A

The process of creating a virtual computer using software that borrows CPU, RAM, and storage from a physical host.

Virtualization allows for efficient resource utilization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

2.0 Operating Systems & Linux Basics

What is a virtual machine (VM)?

A

An isolated virtual computer running on top of a host machine, with virtualized hardware.

VMs enable running multiple operating systems on a single physical machine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

2.0 Operating Systems & Linux Basics

Why can any OS run inside a VM, regardless of the host OS?

A

Because virtualization abstracts hardware, letting the guest OS think it’s running on real hardware.

This flexibility is a key advantage of virtualization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
# 2.0 Operating Systems & Linux Basics What is the difference between a **host OS** and a **guest OS**?
The host OS runs directly on the physical machine; the guest OS runs inside a VM managed by a hypervisor. ## Footnote Understanding this distinction is important for virtualization concepts.
26
# 2.0 Operating Systems & Linux Basics What is a **Type 1 hypervisor**?
A hypervisor that runs directly on the hardware, managing guest OSes without a host OS layer. ## Footnote Type 1 hypervisors are often used in enterprise environments.
27
# 2.0 Operating Systems & Linux Basics When are **Type 1 hypervisors** typically used?
Cloud providers, data centers, and high-performance virtualization environments. ## Footnote Their efficiency makes them suitable for resource-intensive applications.
28
# 2.0 Operating Systems & Linux Basics What is a **Type 2 hypervisor**?
A hypervisor that runs inside a host OS as an application, adding another software layer. ## Footnote Type 2 hypervisors are often used for personal or development purposes.
29
# 2.0 Operating Systems & Linux Basics When are **Type 2 hypervisors** typically used?
Local development, learning, testing multiple OSes, and running portable VM images. ## Footnote They provide flexibility for users experimenting with different operating systems.
30
# 2.0 Operating Systems & Linux Basics What are the main **benefits of virtualization**?
* Hardware efficiency * Agility * Portability (VM image files) * Easy backups * Cost savings * Environment isolation ## Footnote These benefits contribute to the popularity of virtualization in modern IT.
31
# 2.0 Operating Systems & Linux Basics Why is virtualization **safer for experimentation**?
The VM is isolated; mistakes do not impact the main OS. ## Footnote This isolation allows for safe testing of new software or configurations.
32
# 2.0 Operating Systems & Linux Basics What are the steps to set up a **Linux VM**?
* Install VirtualBox * Create an Ubuntu VM * Allocate CPU/RAM/disk from host * Install Linux inside the VM * Remember: resources are shared with the host ## Footnote Following these steps ensures a successful VM setup.
33
# 2.0 Operating Systems & Linux Basics What structure does the **Linux file system** use?
A single-root hierarchical tree structure starting at `/`. ## Footnote This structure allows for organized file storage and access.
34
# 2.0 Operating Systems & Linux Basics How does the **Linux file system** differ from Windows in terms of roots?
Linux has one root (`/`); Windows has multiple root drives (`C:\`, `D:\`, etc.). ## Footnote This affects how files are organized and accessed.
35
# 2.0 Operating Systems & Linux Basics What principle does **Linux** follow regarding files and devices?
**Everything in Linux is a file**, including text files, commands, directories, and devices. ## Footnote This unifies the way resources are handled in the system.
36
# 2.0 Operating Systems & Linux Basics What is a **file descriptor** in Linux?
A reference to any resource treated as a file (documents, devices, directories, commands). ## Footnote File descriptors are essential for managing input/output operations.
37
# 2.0 Operating Systems & Linux Basics Why can **Linux** have multiple user accounts?
Each user gets isolated disk space and their own configurations and permissions. ## Footnote This enhances security and customization for each user.
38
# 2.0 Operating Systems & Linux Basics What is a **binary** in Linux?
A computer-readable executable file. ## Footnote Binaries are essential for running applications and commands.
39
# 2.0 Operating Systems & Linux Basics Why are **binaries** split across system folders in Linux?
Historically due to storage constraints, leading to separation between root binaries and user-installed binaries. ## Footnote This organization helps manage system resources effectively.
40
# 2.0 Operating Systems & Linux Basics What is stored in **/usr/local**?
Software installed by the user, such as Docker, Minikube, Java; available to all users. ## Footnote This directory is for user-installed software that is not part of the default system.
41
# 2.0 Operating Systems & Linux Basics Why do **/usr/local** and **/opt** both exist?
* `/usr/local`: for programs split into multiple components * `/opt`: for programs not split (self-contained) ## Footnote This distinction helps in managing software installations.
42
# 2.0 Operating Systems & Linux Basics What is stored in **/dev**?
Device files that apps and drivers use to communicate with hardware. ## Footnote This directory is crucial for hardware interaction.
43
# 2.0 Operating Systems & Linux Basics What is stored in **/var/log**?
System and application log files. ## Footnote Logs are essential for monitoring system performance and troubleshooting.
44
# 2.0 Operating Systems & Linux Basics What is stored in **/var/cache**?
Cached data generated by applications. ## Footnote Caching improves performance by reducing the need to regenerate data.
45
# 2.0 Operating Systems & Linux Basics What is **/media** used for?
Automatically created mount points for removable devices like USB drives or CDs. ## Footnote This directory simplifies access to external storage.
46
# 2.0 Operating Systems & Linux Basics What is **/mnt** used for?
Temporary mount points, historically used by sysadmins for manual mounts. ## Footnote This allows for flexible management of file systems.
47
# 2.0 Operating Systems & Linux Basics What defines a **hidden file** in Linux?
File names beginning with a dot (`.`), also called dotfiles. ## Footnote Hidden files are often used for configuration settings.
48
# 2.0 Operating Systems & Linux Basics Why are **hidden files** used?
To avoid accidental deletion and store system or application configuration. ## Footnote This helps maintain system stability.
49
# 2.0 Operating Systems & Linux Basics What is the difference between **CLI** and **Terminal**?
CLI is the interface where commands are entered; the Terminal is the GUI window displaying the CLI. ## Footnote Understanding this distinction is important for effective command line usage.
50
# 2.0 Operating Systems & Linux Basics Why is **CLI** preferred over **GUI** for DevOps?
It’s faster, more efficient for bulk tasks, supports more formats, and servers often lack a GUI. ## Footnote CLI tools are essential for automation and remote management.
51
# 2.0 Operating Systems & Linux Basics What is the difference between a **regular user** and **root**?
Root has full system privileges; regular users are limited for safety. ## Footnote This separation enhances security and prevents accidental system damage.
52
# 2.0 Operating Systems & Linux Basics What does **sudo** do?
Allows a regular user to temporarily run commands with root privileges. ## Footnote This is crucial for performing administrative tasks without logging in as root.
53
# 2.0 Operating Systems & Linux Basics What is a **software package** on Linux?
A compressed archive containing the program and metadata about its dependencies. ## Footnote Packages simplify software installation and management.
54
# 2.0 Operating Systems & Linux Basics Why do Linux packages have **dependencies**?
Most apps require other libraries to function; the package manager installs them automatically. ## Footnote This ensures that all necessary components are available for software to run.
55
# 2.0 Operating Systems & Linux Basics What tasks does a **package manager** perform?
* Downloads and installs software * Resolves dependencies * Ensures package authenticity * Places files in correct directories * Updates installed software ## Footnote Package managers streamline software management.
56
# 2.0 Operating Systems & Linux Basics What is **APT**?
A user-friendly package manager (Advanced Package Tool) preinstalled on Ubuntu. ## Footnote APT simplifies the installation and management of software on Debian-based systems.
57
# 2.0 Operating Systems & Linux Basics Why must you run **sudo apt update** before installing packages?
To refresh the local package index with the latest changes from repositories. ## Footnote This ensures you are installing the most current versions of software.
58
# 2.0 Operating Systems & Linux Basics What is the **APT package index**?
A database storing metadata about available packages. ## Footnote This index is essential for the package manager to function correctly.
59
# 2.0 Operating Systems & Linux Basics How does **APT** compare to **APT-GET**?
APT is more user-friendly with cleaner output; APT-GET has more commands but requires additional flags for nicer output. ## Footnote Both tools serve similar purposes but differ in usability.
60
# 2.0 Operating Systems & Linux Basics What is the **Ubuntu Software Center**?
A GUI-based app store for installing, removing, and updating software on Ubuntu. ## Footnote This provides a user-friendly interface for software management.
61
# 2.0 Operating Systems & Linux Basics What is **Snap**?
A universal Linux packaging system where each snap includes its app and all dependencies. ## Footnote Snap packages simplify installation across different Linux distributions.
62
# 2.0 Operating Systems & Linux Basics What are advantages of **Snap**?
* Self-contained packages * Works across distros * Automatic updates ## Footnote These features enhance usability and convenience.
63
# 2.0 Operating Systems & Linux Basics What are drawbacks of **Snap**?
* Larger installation size * Additional runtime overhead ## Footnote These factors can affect system performance.
64
# 2.0 Operating Systems & Linux Basics How does **Snap** differ from **APT**?
* Snap includes dependencies; APT shares dependencies * Snap is universal; APT is distro‑specific * Snap auto‑updates; APT updates manually ## Footnote Understanding these differences is crucial for effective package management.
65
# 2.0 Operating Systems & Linux Basics Why add a **repository** to APT?
To install software not available in official repositories or newer versions. ## Footnote This expands the available software options for users.
66
# 2.0 Operating Systems & Linux Basics What does adding a **repository** do?
Adds a new source to `/etc/apt/sources.list`, allowing APT to install from it. ## Footnote This is essential for accessing additional software packages.
67
# 2.0 Operating Systems & Linux Basics What is a **PPA**?
A community-run repository allowing developers to distribute updated or experimental software. ## Footnote PPAs provide access to software that may not be in the official repositories.
68
# 2.0 Operating Systems & Linux Basics What risks come with using **PPAs**?
* Potential security issues * Quality concerns * Upgrade problems during major Ubuntu releases ## Footnote Users should exercise caution when adding PPAs.
69
# 2.0 Operating Systems & Linux Basics What package managers are used by **Debian-based distributions**?
APT and APT-GET. ## Footnote These tools are essential for managing software on Debian systems.
70
# 2.0 Operating Systems & Linux Basics What package managers are used by **Red Hat-based distributions**?
YUM (or DNF in newer versions). ## Footnote These tools facilitate software management on Red Hat systems.
71
# 2.0 Operating Systems & Linux Basics Why do sysadmins choose specific **Linux distros**?
Primarily based on the package manager ecosystem they prefer to maintain. ## Footnote This choice impacts system administration practices.
72
# 2.0 Operating Systems & Linux Basics How different are **distributions** within the same family (Debian/RHEL)?
Only minor differences; they share most concepts and tools. ## Footnote This similarity simplifies the learning curve for users transitioning between distros.
73
# 2.0 Operating Systems & Linux Basics Why is **CLI** indispensable when working on servers?
Servers typically do not have a GUI; all tasks must be done through command line. ## Footnote Mastery of CLI is essential for effective server management.
74
# 2.0 Operating Systems & Linux Basics Why does **CLI** make small file edits faster?
It allows quick, efficient edits without opening GUI tools. ## Footnote This efficiency is crucial for productivity in development environments.
75
# 2.0 Operating Systems & Linux Basics What are examples of scenarios where **CLI** is more efficient?
* Writing Git commit messages * Editing Kubernetes YAML * Searching logs * Bulk operations * One-line script fixes ## Footnote CLI excels in situations requiring speed and precision.
76
# 2.0 Operating Systems & Linux Basics What are **Vi and Vim** in Linux?
Built‑in command‑line text editors. Vi is the most widely distributed; Vim (“Vi IMproved”) is an enhanced version. ## Footnote Vim is designed for efficient text creation and editing.
77
# 2.0 Operating Systems & Linux Basics Why is **Vim** useful?
It is designed to make creating and editing text highly efficient using modes and keyboard shortcuts. ## Footnote Vim's efficiency is a key reason for its popularity among developers.
78
# 2.0 Operating Systems & Linux Basics What are the **two modes** of Vim?
* Command Mode * Insert Mode ## Footnote These modes dictate how users interact with the text editor.
79
# 2.0 Operating Systems & Linux Basics What happens in Vim’s **Command Mode**?
You cannot type text; keystrokes are interpreted as commands (navigate, delete, search, undo, etc.). ## Footnote Command Mode is essential for executing commands without inserting text.
80
# 2.0 Operating Systems & Linux Basics What happens in Vim’s **Insert Mode**?
You can type and edit text freely; pressing `Esc` returns to Command Mode. ## Footnote Insert Mode is where actual text editing occurs.
81
# 2.0 Operating Systems & Linux Basics What are common **Vim use cases** in DevOps?
* Saving/quitting files * Editing configs * Searching and replacing text * Editing scripts on servers ## Footnote Vim is often used for quick edits in server environments.
82
# 2.0 Operating Systems & Linux Basics What two unique identifiers does each **Linux user** have?
* Username * UID (User Identifier) ## Footnote These identifiers are crucial for user management and permissions.
83
# 2.0 Operating Systems & Linux Basics Which user attribute can be changed—**username** or **UID**?
Username can change; UID is fixed permanently. ## Footnote This distinction is important for user management.
84
# 2.0 Operating Systems & Linux Basics What is **UID** used for?
System-level authentication and tracking user activity. ## Footnote UID plays a critical role in security and user identification.
85
# 2.0 Operating Systems & Linux Basics What is the UID of the **root user**?
Always UID 0. ## Footnote The root user has unrestricted access to the system.
86
# 2.0 Operating Systems & Linux Basics What is a **service account** in Linux?
A non-human system user created to run specific services or applications (e.g., mysql user). ## Footnote Service accounts enhance security by limiting access.
87
# 2.0 Operating Systems & Linux Basics Why should services not run as **root**?
For security—root has unrestricted access; compromising a root-running service compromises the system. ## Footnote Running services as root increases vulnerability.
88
# 2.0 Operating Systems & Linux Basics How does Linux user management differ from **Windows domain accounts**?
Linux users are local to each machine; Windows domain accounts are centrally managed. ## Footnote This difference impacts how user permissions are handled.
89
# 2.0 Operating Systems & Linux Basics Why should teams avoid **shared user accounts** on servers?
For traceability and per-user permission control. ## Footnote Shared accounts can lead to security and accountability issues.
90
# 2.0 Operating Systems & Linux Basics What does **/etc/passwd** contain?
A list of all user accounts, one per line; readable by all users but writable only by root. ## Footnote This file is essential for user management in Linux.
91
# 2.0 Operating Systems & Linux Basics How can **permissions** be granted in Linux?
At user level or group level (recommended for multiple users). ## Footnote Group-level permissions simplify management for teams.
92
# 2.0 Operating Systems & Linux Basics What is the **GID** of the root group?
Always GID 0. ## Footnote The root group has special privileges in the system.
93
# 2.0 Operating Systems & Linux Basics What is the difference between **useradd** and **adduser**?
* `useradd`: low-level, requires manual options * `adduser`: interactive, user‑friendly, autogenerates configs/home directory ## Footnote Understanding these commands is crucial for user management.
94
# 2.0 Operating Systems & Linux Basics What are the commands to **create** and **delete** users and groups?
* Create: `adduser`, `addgroup`, `useradd`, `groupadd` * Delete: `deluser`, `delgroup`, `userdel`, `groupdel` ## Footnote These commands are fundamental for user and group management.
95
# 2.0 Operating Systems & Linux Basics What types of **ownership** does each file have?
An owning user and an owning group. ## Footnote Ownership is critical for file permissions and security.
96
# 2.0 Operating Systems & Linux Basics What are the **three permission types** in Linux?
* Read (r) * Write (w) * Execute (x) ## Footnote Understanding these permissions is essential for file security.
97
# 2.0 Operating Systems & Linux Basics What three **user categories** can have permissions assigned?
* Owner * Group * Others ## Footnote These categories help define access levels for files.
98
# 2.0 Operating Systems & Linux Basics Which command changes **file ownership**?
`chown : ` ## Footnote This command is essential for managing file permissions.
99
# 2.0 Operating Systems & Linux Basics How do you **view permissions** of files?
`ls -l` ## Footnote This command provides detailed information about file permissions.
100
# 2.0 Operating Systems & Linux Basics What is the **symbolic way** to add or remove permissions?
Example: `chmod g-w file.txt` (remove write from group). ## Footnote Symbolic permissions are intuitive for managing access.
101
# 2.0 Operating Systems & Linux Basics How do you set entire permission sets **symbolically**?
Example: `chmod g=rwx file.txt` ## Footnote This method allows for precise permission management.
102
# 2.0 Operating Systems & Linux Basics What is the **numeric chmod** example for full owner perms, read-only group, no others?
`chmod 740 file` ## Footnote Numeric permissions provide a compact way to set access levels.
103
# 2.0 Operating Systems & Linux Basics What is the purpose of the **pipe operator** (`|`)?
Sends one program's output into another program as input. ## Footnote This operator is essential for chaining commands.
104
# 2.0 Operating Systems & Linux Basics What does the **redirect operator** (`>`) do?
Sends command output to a specified file (overwrites it). ## Footnote Redirecting output is a common practice in scripting.
105
# 2.0 Operating Systems & Linux Basics What does **less** do?
Displays file content one page at a time and allows scrolling. ## Footnote This tool is useful for viewing large files.
106
# 2.0 Operating Systems & Linux Basics Why is **less** useful for large files?
It loads only what’s needed—does not read the entire file at once. ## Footnote This efficiency is crucial for performance.
107
# 2.0 Operating Systems & Linux Basics What does **grep** do?
Searches text for patterns and outputs matching lines. ## Footnote Grep is a powerful tool for text processing.
108
# 2.0 Operating Systems & Linux Basics What are the **three standard streams**?
* stdin: input * stdout: output * stderr: error output ## Footnote Understanding these streams is fundamental for command-line operations.
109
# 2.0 Operating Systems & Linux Basics Why use **shell scripts**?
Automate repetitive tasks, maintain configuration history, and perform bulk logic. ## Footnote Shell scripts enhance productivity in system administration.
110
# 2.0 Operating Systems & Linux Basics What is a **shell script file extension**?
.sh ## Footnote This extension indicates that the file is a shell script.
111
# 2.0 Operating Systems & Linux Basics What is the **shebang** and why is it used?
`#!` — tells the OS which shell interpreter to run the script with. ## Footnote The shebang is crucial for script execution.
112
# 2.0 Operating Systems & Linux Basics Why must scripts be made **executable**?
To allow the OS to run them as programs. ## Footnote Making scripts executable is a necessary step in script deployment.
113
# 2.0 Operating Systems & Linux Basics What are common **shell types**?
* `sh` (Bourne shell) * `bash` (Bourne Again shell) ## Footnote Different shells offer various features and capabilities.
114
# 2.0 Operating Systems & Linux Basics How are **variables** created in bash?
`variable=value` ## Footnote Variable assignment is fundamental in scripting.
115
# 2.0 Operating Systems & Linux Basics How do you store **command output** in a variable?
`var=$(command)` ## Footnote This technique is essential for capturing results in scripts.
116
# 2.0 Operating Systems & Linux Basics What do **[ ... ]** brackets represent in conditionals?
A shorthand for the `test` command. ## Footnote This syntax simplifies conditional expressions.
117
# 2.0 Operating Systems & Linux Basics What types of **operators** exist for conditionals?
* Numeric * String * File test operators ## Footnote Understanding these operators is crucial for effective scripting.
118
# 2.0 Operating Systems & Linux Basics How are **positional parameters** referenced?
$1, $2, $3, etc. ## Footnote Positional parameters allow scripts to handle input arguments.
119
# 2.0 Operating Systems & Linux Basics What does **$*** represent?
All passed arguments as a single string. ## Footnote This is useful for processing multiple arguments.
120
# 2.0 Operating Systems & Linux Basics What does **$#** represent?
The number of arguments passed into the script. ## Footnote This allows scripts to adapt based on input size.
121
# 2.0 Operating Systems & Linux Basics What types of **loops** exist in shell scripting?
* `for` * `while` * `until` * `select` ## Footnote Loops are essential for repetitive tasks in scripts.
122
# 2.0 Operating Systems & Linux Basics What does a **for loop** do?
Iterates over a list and runs commands for each item. ## Footnote For loops are commonly used for processing lists.
123
# 2.0 Operating Systems & Linux Basics What does a **while loop** do?
Repeats commands until a condition becomes false. ## Footnote While loops are useful for conditional repetition.
124
# 2.0 Operating Systems & Linux Basics Why use **functions** in shell scripts?
To break scripts into reusable, logical code blocks. ## Footnote Functions enhance code organization and readability.
125
# 2.0 Operating Systems & Linux Basics How are **function parameters** referenced?
$1, $2, etc., within the function. ## Footnote This allows functions to accept and process input.
126
# 2.0 Operating Systems & Linux Basics What scripting principle should functions follow?
Single Responsibility Principle—each function should do one thing. ## Footnote This principle promotes cleaner and more maintainable code.
127
# 2.0 Operating Systems & Linux Basics What is recommended for **readability** when using positional parameters in functions?
Assign meaningful variable names inside the function. ## Footnote Meaningful names improve code clarity.
128
# 2.0 Operating Systems & Linux Basics How do you diagnose a server with **high CPU usage**?
Use `top` or `htop` to identify processes with high %CPU, then inspect logs or kill/restart the offending process. ## Footnote This helps in pinpointing resource hogs affecting server performance.
129
# 2.0 Operating Systems & Linux Basics What is a common cause of **100% CPU usage** by a single process?
* An infinite loop * Runaway script * Memory leak triggering excessive garbage collection * Misconfigured service ## Footnote Identifying the root cause is essential for resolution.
130
# 2.0 Operating Systems & Linux Basics How do you **kill a hung process**?
`kill ` for graceful termination; if it does not stop, use `kill -9 ` for forceful termination. ## Footnote This ensures that the process is terminated properly.
131
# 2.0 Operating Systems & Linux Basics What indicates a **memory leak** on Linux?
Gradually increasing RAM usage for a single process and heavy swap usage over time. ## Footnote Monitoring memory usage is crucial for system stability.
132
# 2.0 Operating Systems & Linux Basics How do you check which processes use the most **memory**?
Use `top` sorted by `%MEM` or `ps aux --sort=-%mem`. ## Footnote This helps in identifying memory-intensive applications.
133
# 2.0 Operating Systems & Linux Basics What happens when a Linux filesystem becomes **100% full**?
* Services crash * Logging stops * Applications fail to write * Some commands may hang ## Footnote This can lead to significant system instability.
134
# 2.0 Operating Systems & Linux Basics How do you find what’s consuming **disk space**?
`du -sh *` or `du -sh /var/*` to inspect directories; `df -h` for filesystem usage. ## Footnote Understanding disk usage is vital for maintenance.
135
# 2.0 Operating Systems & Linux Basics What is a common cause of a suddenly full **/var** partition?
Log files growing indefinitely (e.g., `/var/log/syslog`, application logs). ## Footnote Regular log management is necessary to prevent this issue.
136
# 2.0 Operating Systems & Linux Basics Why does reclaiming disk space not immediately reduce usage when deleting logs?
A process still holds the file handle open. Restart the service or run `lsof | grep deleted`. ## Footnote This is important for effective disk space management.
137
# 2.0 Operating Systems & Linux Basics What is the safest directory to delete temporary files from?
/tmp and /var/tmp, but only remove files not actively in use. ## Footnote Caution is advised to avoid disrupting running applications.
138
# 2.0 Operating Systems & Linux Basics How do you test if **DNS** is the cause of a connectivity issue?
Ping by IP. If IP works but hostname fails, DNS is the problem. ## Footnote This method helps isolate DNS-related issues.
139
# 2.0 Operating Systems & Linux Basics If pinging **8.8.8.8** works but pinging a domain does not, what is broken?
DNS resolution. ## Footnote This indicates that the DNS settings may need to be checked.
140
# 2.0 Operating Systems & Linux Basics If no outbound traffic works, what’s a common cause?
Incorrect default route or gateway. Check with `ip route`. ## Footnote Proper routing configuration is essential for network connectivity.
141
# 2.0 Operating Systems & Linux Basics What causes **“Connection refused”**?
The service is not running or not listening on that port. ## Footnote This requires checking the service status and configuration.
142
# 2.0 Operating Systems & Linux Basics What causes **“Connection timed out”**?
Firewall blocking the port or unreachable destination. ## Footnote This necessitates firewall rule verification.
143
# 2.0 Operating Systems & Linux Basics How do you check which process is **listening on a specific port**?
`sudo netstat -tulpn | grep ` or `ss -tulpn`. ## Footnote This is crucial for troubleshooting network services.
144
# 2.0 Operating Systems & Linux Basics What does it mean if a port is listening on **127.0.0.1** but not **0.0.0.0**?
Service is bound to localhost only; it won’t accept external connections. ## Footnote This indicates a need for reconfiguration for external access.
145
# 2.0 Operating Systems & Linux Basics What causes **“Permission denied”** even when permissions look correct?
Parent directory permissions may not allow traversal (`x` flag missing). ## Footnote This highlights the importance of checking directory permissions.
146
# 2.0 Operating Systems & Linux Basics Why does a script fail with **“command not found”** even though the file exists?
Missing execute permission (`chmod +x script.sh`) or missing shebang. ## Footnote Ensuring proper permissions and shebang lines is essential for script execution.
147
# 2.0 Operating Systems & Linux Basics What causes **“Operation not permitted”** for root?
Filesystem mounted with `nosuid` or `immutable`. Check with: `lsattr file` → immutable flag (`i`). ## Footnote This requires checking filesystem attributes.
148
# 2.0 Operating Systems & Linux Basics Why does a user suddenly lose **sudo access**?
Removed from `sudo` or `wheel` group, or `/etc/sudoers` misconfigured. ## Footnote Regular audits of user permissions are advisable.
149
# 2.0 Operating Systems & Linux Basics What causes SSH **“Permission denied (publickey)”** errors?
Wrong permissions on `~/.ssh` or on key files. Required: `chmod 700 ~/.ssh`, `chmod 600 ~/.ssh/authorized_keys`. ## Footnote Correct permissions are critical for SSH access.
150
# 2.0 Operating Systems & Linux Basics What is the first thing to check when a **service fails to start**?
`systemctl status ` for immediate error output. ## Footnote This provides insight into the failure reason.
151
# 2.0 Operating Systems & Linux Basics Where do you find detailed logs for a failing **systemd service**?
`journalctl -u -xe`. ## Footnote This is essential for diagnosing service issues.
152
# 2.0 Operating Systems & Linux Basics Why might a systemd service say **“Exec format error”**?
The script lacks a valid shebang or uses Windows line endings (CRLF). ## Footnote Ensuring correct script formatting is crucial.
153
# 2.0 Operating Systems & Linux Basics What causes **“Unit not found”**?
The service file is missing or not reloaded. Run: `sudo systemctl daemon-reload`. ## Footnote This is important for ensuring service availability.
154
# 2.0 Operating Systems & Linux Basics Why does a systemd service **restart repeatedly**?
Crash loop due to bad configuration, missing dependencies, or failing health checks. ## Footnote This requires reviewing service configuration and dependencies.
155
# 2.0 Operating Systems & Linux Basics What causes **“command not found”** after installing a package?
PATH not updated; may need to restart terminal or check `/usr/local/bin`. ## Footnote This is important for ensuring command availability.
156
# 2.0 Operating Systems & Linux Basics What causes **“package not found”** when using a package manager?
Outdated package index. Fix: `sudo apt update`. ## Footnote Keeping the package index updated is essential for package management.
157
# 2.0 Operating Systems & Linux Basics Why might a package still not be found after updating?
The repository is missing or disabled; needs to be added to `/etc/apt/sources.list`. ## Footnote Ensuring repository availability is crucial for package installation.
158
# 2.0 Operating Systems & Linux Basics What causes **“disk full”** errors during package installation even when `df -h` shows space?
The `/var` partition specifically is full; apt stores packages in `/var/cache/apt/`. ## Footnote Monitoring partition usage is vital for package management.
159
# 2.0 Operating Systems & Linux Basics What causes **“read‑only filesystem”** errors?
Kernel remounted the filesystem read‑only due to corruption or disk errors. ## Footnote This requires immediate attention to filesystem health.
160
# 2.0 Operating Systems & Linux Basics How do you check whether a filesystem is mounted **read-only**?
`mount | grep `. ## Footnote This helps in diagnosing filesystem issues.
161
# 2.0 Operating Systems & Linux Basics What causes a drive to fail **mounting at boot**?
Incorrect entries in `/etc/fstab`, wrong UUID, or missing device. ## Footnote Proper configuration of `/etc/fstab` is essential for boot processes.
162
# 2.0 Operating Systems & Linux Basics What does **“too many open files”** indicate?
The process hit its file descriptor limit. Increase with `ulimit -n`. ## Footnote This is important for managing resource limits.
163
# 2.0 Operating Systems & Linux Basics What causes **“device or resource busy”** when unmounting a disk?
A process is using that mount. Check with `lsof +D `. ## Footnote Identifying active processes is crucial for unmounting.
164
# 2.0 Operating Systems & Linux Basics What causes **“No space left on device”** when disk has free space?
The filesystem is out of inodes — too many small files. ## Footnote Monitoring inode usage is essential for filesystem health.
165
# 2.0 Operating Systems & Linux Basics What causes **slow shell commands** or tab‑completion delays?
DNS lookup delays in SSH session; fix by editing `/etc/hosts`. ## Footnote This can significantly improve command response times.
166
# 2.0 Operating Systems & Linux Basics Why does **cron fail** to run a script that works manually?
Cron runs with a limited PATH; absolute paths must be used. ## Footnote This is important for ensuring scripts run as expected.
167
# 2.0 Operating Systems & Linux Basics What causes **“text file busy”** when editing a running script?
The script is currently being executed; Linux locks it until done. ## Footnote This is a normal behavior in Linux to prevent execution issues.