Let's dive into Linux Working
Understanding the Linux Operating System: A Deep Dive
1. Kernel Initialization
The kernel is the heart of the Linux operating system. During boot, several critical steps occur:
-
BIOS/UEFI and Bootloader:
- The BIOS or UEFI firmware initializes hardware components.
- The bootloader (e.g., GRUB) loads the Linux kernel (
vmlinuz
).
-
Kernel Initialization:
- The kernel initializes hardware devices (CPU, memory, storage, etc.).
- It sets up essential data structures (e.g., process tables, page tables).
- The root filesystem is identified and mounted.
2. Init Process
- The kernel starts the init process (traditionally
init
, but modern systems usesystemd
). - Init is responsible for:
- Starting system services and daemons.
- Managing user sessions and spawning user-space processes.
3. User Space Initialization
- Init spawns the first user-space process (usually
init
orsystemd
). - User sessions (e.g., graphical desktop environments) start from here.
4. Filesystem Hierarchy
- Linux follows a standard directory structure:
-
/
: Root directory. -
/bin
,/sbin
: Essential system binaries. -
/etc
: Configuration files. -
/home
: User home directories. -
/var
: Variable data (logs, caches). -
/tmp
: Temporary files. -
/usr
: User programs and libraries. -
/opt
: Optional software. -
/dev
: Device files. -
/proc
: Virtual filesystem for process information.
-
5. Processes and Scheduling
- The scheduler (e.g., Completely Fair Scheduler) manages process execution.
- Processes are created using
fork()
andexec()
system calls. - Priorities, nice values, and CPU affinity affect scheduling.
6. Memory Management
- Virtual memory management:
- Page tables map virtual addresses to physical memory.
- TLB (Translation Lookaside Buffer) caches page table entries.
- Demand paging and swapping optimize memory usage.
- Memory allocation:
-
malloc()
,free()
manage dynamic memory. - Kernel memory management handles system memory.
-
7. File I/O and System Calls
- File descriptors (stdin, stdout, stderr) facilitate I/O.
- System calls (e.g.,
open()
,read()
,write()
,close()
) interact with files.
8. Networking
- Network stack:
- IP, TCP, UDP protocols.
- Socket API for network communication.
- Network configuration:
-
ifconfig
,ip
commands. - Routing tables determine packet forwarding.
-
9. Security and Permissions
- Users, groups, and permissions control access.
-
sudo
allows privilege escalation. - File integrity checks (e.g.,
md5sum
,sha256sum
) verify file integrity.
10. Device Drivers
- Kernel modules manage hardware devices.
- Examples:
usb-storage
,e1000
(Ethernet),i915
(graphics).
11. Logging and Debugging
-
syslog
anddmesg
provide system logs. - Debugging tools (e.g.,
strace
,gdb
) help diagnose issues.
12. Shutdown and Reboot
- Init sends signals to processes.
- Filesystems are unmounted.
- The system halts or reboots.
π Cheatsheet Linuxπ§
-
Linux Basics:
-
Commands:
-
ls
: List files and directories. -
cd
: Change directory. -
pwd
: Print working directory. -
cp
: Copy files or directories. -
mv
: Move or rename files. -
rm
: Remove files or directories.
-
-
File Permissions:
-
chmod
: Modify file permissions. -
chown
: Change file ownership. -
chgrp
: Change group ownership.
-
-
Processes:
-
ps
: List running processes. -
top
: Monitor system processes. -
kill
: Terminate processes. -
nice
: Adjust process priority.
-
-
Package Management:
-
yum
(RPM-based systems): Install, update, and manage packages. -
apt-get
(Debian-based systems): Similar functionality.
-
-
Commands:
-
File System Hierarchy:
- Understand the directory structure:
-
/
: Root directory. -
/bin
: Essential system binaries. -
/etc
: Configuration files. -
/home
: User home directories. -
/var
: Variable data (logs, caches). -
/tmp
: Temporary files. -
/usr
: User programs and libraries. -
/opt
: Optional software. -
/dev
: Device files. -
/proc
: Virtual filesystem for process information.
-
- Understand the directory structure:
-
Networking:
-
ifconfig
orip
: Network configuration. -
ping
: Check network connectivity. -
netstat
: Network statistics. -
ssh
: Secure shell for remote access. -
iptables
: Firewall rules.
-
-
Shell Scripting:
- Create and execute shell scripts:
- Variables.
- Loops (for, while).
- Conditionals (if, else).
- Functions.
- Input/output redirection.
- Create and execute shell scripts:
-
System Administration:
- User management:
-
useradd
,userdel
,passwd
.
-
- Disk management:
-
df
,du
,mount
.
-
- Cron jobs:
-
crontab
.
-
- User management:
-
Security:
-
sudo
: Execute commands with superuser privileges. - File integrity checks:
-
md5sum
,sha256sum
.
-
- Firewalls and SELinux.
-
Sharing working overview, and there's much more to explore!
Feel free to ask questions and share with beginners starting with AWS DevOps. Happy learning! ππ§
Top comments (0)