Linux Basics
Linux Basics
OS Information
Linux is an open-source, Unix-like operating system kernel initially created by Linus Torvalds in
1991. It is widely used for servers, desktops, mobile devices, and embedded systems due to its
flexibility, stability, and security. Linux distributions (distros) include a Linux kernel combined
with supporting software and package management systems.
• Ubuntu
• CentOS/Red Hat Enterprise Linux (RHEL)
• Debian
• Fedora
• Arch Linux
• Kali Linux
2. OS Architecture
• Kernel: Core of the OS that interacts with hardware, manages system resources, and
provides essential services.
o Process management
o Memory management
o Device drivers
• System Libraries: Provide standard functions and interfaces for applications (e.g., libc).
• System Utilities: Essential tools for managing the system, such as shell commands and
configuration utilities.
• User Space: Applications and user interfaces that interact with the system.
3. OS Components
1. Kernel: The core part of Linux managing hardware resources and system calls.
2. Shell: Command-line interface (CLI) that interprets user commands (e.g., Bash, Zsh).
3. File System: Organizes and stores data (e.g., ext4, NTFS, XFS).
4. System Services: Background processes, also called daemons, such as cron and sshd.
5. Package Manager: Tool for managing software packages (e.g., apt, yum, dnf).
6. Networking Components: Manage communication (e.g., TCP/IP stack).
7. User Interfaces: GUI systems like GNOME, KDE, or CLI-based tools.
System Information
Networking Commands
Package Management
Firewalld
• Description: A dynamic firewall management tool with support for network zones and
firewall policies.
• Key Features:
o Provides a higher-level abstraction for managing firewall rules.
o Supports runtime and permanent configurations.
o Zone-based configuration to simplify rule management.
• Common Commands:
o firewall-cmd --state - Check if firewalld is running.
o firewall-cmd --list-all - List all active rules.
o firewall-cmd --add-service=ssh - Allow SSH traffic.
o firewall-cmd --reload - Reload rules without restarting the service.
Iptables
• Description: A legacy command-line tool for configuring firewall rules at a lower level.
• Key Features:
o Operates on chains and tables (e.g., INPUT, FORWARD, OUTPUT).
o Provides fine-grained control over packet filtering.
o Rules are applied immediately but do not persist after a reboot without saving
them.
• Common Commands:
o iptables -L - List all current rules.
o iptables -A INPUT -p tcp --dport 22 -j ACCEPT - Allow SSH traffic.
o iptables -D INPUT 1 - Delete the first rule in the INPUT chain.
o iptables-save > /etc/iptables/rules.v4 - Save rules for persistence.
SELinux
Bash scripting is a powerful tool for automating tasks in Unix/Linux environments. It uses Bash
(Bourne Again Shell) to execute commands in sequence.
3. Conditions: Decision-making.
if [ "$name" == "Intern" ]; then
echo "Welcome!"
fi