KEMBAR78
Linux Files, Inodes, File Systems, and Processes | PDF | File System | Computer File
0% found this document useful (0 votes)
10 views5 pages

Linux Files, Inodes, File Systems, and Processes

The document provides an overview of Linux files, inodes, file systems, and processes. It explains the types of files in Linux, the structure of inodes, and the components of file systems, including superblocks and data blocks. Additionally, it covers the definition and management of processes, including job control and scheduling tasks using at, batch, and cron.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Linux Files, Inodes, File Systems, and Processes

The document provides an overview of Linux files, inodes, file systems, and processes. It explains the types of files in Linux, the structure of inodes, and the components of file systems, including superblocks and data blocks. Additionally, it covers the definition and management of processes, including job control and scheduling tasks using at, batch, and cron.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Linux Files, Inodes, File Systems, and Processes

1. Linux Files, Inodes, and Structure

Files in Linux

●​ Everything in Linux is treated as a file (including devices, processes, and directories).


●​ File Types:
○​ Regular Files (-): Contains text, data, or binary.
○​ Directory Files (d): Special files that contain lists of filenames and metadata.
○​ Special Files:
■​ Character Device Files (c): Represent character-oriented devices.
■​ Block Device Files (b): Represent block-oriented devices.
■​ FIFO Files (p): Named pipes.
■​ Socket Files (s): For inter-process communication.
■​ Symbolic Links (l): Shortcut-like links to other files.

Inodes (Index Nodes)

●​ An inode is a data structure that stores metadata about a file or directory, excluding its
name or content.
●​ Information stored in an inode:
○​ File type and permissions.
○​ Owner and group IDs.
○​ File size.
○​ Timestamps: creation, modification, and access.
○​ Link count (number of hard links).
○​ Pointers to data blocks (where the file data is stored).
●​ The ls -i command shows inode numbers.

File System Structure

●​ Hierarchical Structure: Organized as a tree starting from the root (/).


●​ Key Directories:
○​ /: Root directory.
○​ /home: User home directories.
○​ /bin and /sbin: Essential binaries.
○​ /etc: Configuration files.
○​ /var: Variable files (e.g., logs).
○​ /usr: User-installed software and libraries.
○​ /dev: Device files.

2. File System and Its Components

File System Components

1.​ Superblock:​

○​ Contains metadata about the filesystem (size, block size, number of inodes, etc.).
○​ Essential for mounting and accessing the filesystem.
2.​ Inodes:​

○​ Refer to the previous section for details.


3.​ Data Blocks:​

○​ Store the actual content of files.


○​ File data may span multiple blocks, linked via the inode.
4.​ Directories:​

○​ Map filenames to inode numbers.


5.​ Journal (Optional):​

○​ Found in journaling filesystems like ext3 and ext4.


○​ Logs changes before applying them to reduce corruption risks.

Standard File Systems in Linux

●​ ext2: Second Extended Filesystem (non-journaling).


●​ ext3: Adds journaling to ext2.
●​ ext4: Enhanced version of ext3 with larger file and partition support.
●​ XFS: High-performance journaling filesystem.
●​ Btrfs: Modern filesystem with advanced features (e.g., snapshots, pooling).
●​ FAT32: Compatible across multiple OS but lacks Linux permissions.
●​ NTFS: Commonly used in Windows.

File System Types

●​ Journaling File Systems: Ext3, Ext4, XFS, Btrfs.


●​ Distributed File Systems: NFS, GlusterFS, CephFS.
●​ Special Purpose File Systems:
○​ tmpfs: In-memory temporary filesystem.
○​ proc: Virtual filesystem for process and kernel info.
○​ sysfs: Provides device and driver info.
3. Processes in Linux

Definition of a Process

●​ A process is an instance of a running program.


●​ Processes are identified by a unique Process ID (PID).
●​ Types:
○​ Foreground: Runs interactively.
○​ Background: Runs independently of the terminal.

Starting and Stopping Processes

●​ Starting:
○​ Run a command directly (e.g., ls, nano).
○​ Run in the background using & (e.g., sleep 100 &).
●​ Stopping:
○​ Ctrl+C: Stops a foreground process.
○​ kill [PID]: Sends a signal to stop a process.
○​ killall [name]: Stops all processes with a given name.
○​ Signals:
■​ SIGTERM: Graceful termination.
■​ SIGKILL: Forceful termination.

Initialization Processes

●​ init: The first process started by the kernel.


○​ Modern systems use systemd, which replaces init.
○​ Responsible for starting services and managing processes.

Mechanism of Process Creation

1.​ Fork:​

○​ A process creates a copy of itself using the fork() system call.


○​ Parent and child processes share the same code but have separate memory
spaces.
2.​ Exec:​

○​ Replaces the process’s memory with a new program.


3.​ Wait:​

○​ Parent process waits for child processes to terminate.


4.​ Exit:​

○​ Terminates the process and releases resources.

Job Control in Linux

●​ Job Control Commands:


○​ jobs: Lists current jobs.
○​ fg: Brings a job to the foreground.
○​ bg: Resumes a job in the background.
○​ &: Runs a command in the background.
○​ Ctrl+Z: Suspends a foreground job.

Using at, batch, cron, and time

●​ at:​

○​ Runs a task at a specific time.

Usage:​
echo "command" | at HH:MM

○​
●​ batch:​

○​ Runs tasks when the system load is low.

Usage:​
echo "command" | batch

○​
●​ cron:​

○​ Runs tasks periodically as specified in crontab.

Crontab format:​
* * * * * command

○​
■​ Fields: minute, hour, day of month, month, day of week.
●​ time:​

○​ Measures the execution time of a command.


Usage:​
time command

○​

You might also like