Understanding UNIX Kernel and Shell Basics
Understanding UNIX Kernel and Shell Basics
Hard links directly associate a name with a file and share the same inode, meaning they are indistinguishable from the original file. They cannot span across file systems or link to directories. Soft links, or symbolic links, point to a file by name and use a different inode. If the target is deleted, the link breaks. Soft links can traverse different file systems and link to directories, offering greater flexibility .
Absolute pathnames in UNIX specify a complete directory path from the root (e.g., /home/user/docs), ensuring consistent file location regardless of current context. Relative pathnames derive from the current working directory (e.g., docs/file), affecting accessibility by requiring knowledge of the current directory for correct navigation .
In UNIX, fork() creates a new child process by duplicating the existing process. This child process has a unique process ID but shares the parent's memory until exec() is invoked. The exec() system call replaces the current process image with a new process image, enabling the execution of new programs. This interaction allows dynamic process creation and execution, forming the backbone of process management .
The nice command in UNIX modifies process priority, lowering it by increasing the niceness value, thereby reducing CPU usage priority. For example, nice -n 10 command lessens its execution precedence to favor other processes, balancing resource allocation and improving system responsiveness under load .
Environment variables in UNIX provide dynamic values that influence process behavior and configuration. They serve to pass essential information to processes spawned from the shell. Examples include PATH, which defines executable search paths; HOME, pointing to the user's home directory; USER, indicating the current logged-in user; and SHELL, specifying the default shell .
The UNIX kernel manages system resources by handling memory management, process scheduling, and file management, among other duties. Memory management ensures optimal utilization by allocating and deallocating memory to processes. Process scheduling determines the order and time processes are executed, optimizing CPU utilization. File management involves storing, retrieving, and organizing files, which are essential for data manipulation and storage .
A process enters a zombie state when it terminates, but its parent process has not yet read its exit status with wait(). Although the process has finished execution, it remains in a process table entry representing resource usage until the parent retrieves the status, resolving the issue .
UNIX supports multitasking by allowing processes to run in the background, freeing the terminal for other tasks. A background process is initiated by appending an ampersand (&) to the command line (e.g., sleep 100 &), which detaches the process from the terminal's standard input and outputs, allowing the user to execute additional commands concurrently .
Standard input (stdin) typically refers to keyboard input, standard output (stdout) to terminal screen output, and standard error (stderr) to error message display. Stdout and stderr are separable for capturing normal vs. error outputs. Redirection modifies their default targets, allowing inputs from files or outputs to be stored in files for efficient logging and debugging .
The UNIX system follows several key steps: the init process starts at boot time, spawning getty processes that manage terminals. When a user logs in, the login process authenticates them, and upon successful authentication, a shell process is started. This shell provides command interpretation and user interaction with the system .