Lec3_Intro_to_Linux
Lec3_Intro_to_Linux
system
Introduction to Linux
´ Overview:
´ Linux: A powerful operating system based on Unix, widely used due to its flexibility
and robustness.
´ History: Developed by Linus Torvalds in 1991, Linux has become a key player in
operating systems.
´ Features:
´ Open-source: The source code is freely available for anyone to view, modify,
and distribute. This fosters a large community contributing to its development.
´ Secure: Linux is known for its strong security features, including robust user
permissions and regular security updates.
´ Versatile: Runs on a variety of hardware, from servers and desktops to
smartphones and embedded devices. Linux powers much of the internet
infrastructure and is popular in cloud computing.
Linux File System
´ Structure:
´ Hierarchical Directory: Linux uses a tree-like structure starting at the root directory (/).
All files and directories are contained within this hierarchy.
´ Root Directory (/): The top-level directory where the entire file system hierarchy starts.
´ Key Directories:
´ /home: Contains personal directories for each user, where users can store personal
files and settings.
´ /etc: Holds configuration files for the system and installed applications. It's where
system-wide configuration files reside.
´ /var: Contains variable data like logs, caches, and temporary files that change over
time.
´ /bin: Includes essential binary executables needed for booting and system operation,
such as basic commands and utilities.
Navigating the File System
´ Command: ls
´ Usage: Lists files and directories.
´ Options:
´ -l: Detailed view (permissions, owner, size).
´ -a: Includes hidden files (files starting with a dot).
´ Command: pwd
´ Usage: Displays current directory path.
Viewing and Editing Files
´ Command: cat
´ Usage: Concatenates and displays file contents.
´ Command: nano or vi
´ Usage: Text editors within the terminal.
´ nano: User-friendly with on-screen help.
´ vi: More powerful, but steeper learning curve.
File Management
´ Command: cp
´ Usage: Copies files or directories.
´ Example: cp source.txt destination.txt.
´ Command: mv
´ Usage: Moves or renames files.
´ Example: mv oldname.txt newname.txt.
´ Command: rm
´ Usage: Removes files.
´ Example: rm file.txt.
Directory Management
´ Command: mkdir
´ Usage: Creates a new directory.
´ Example: mkdir new_folder.
´ Command: rmdir
´ Usage: Removes an empty directory.
´ Example: rmdir old_folder.
Permissions and Ownership
´ Command: chmod
´ Usage: Changes file permissions.
´ Example: chmod 755 script.sh.
´ Command: chown
´ Usage: Changes file owner.
´ Example: chown user:group file.txt.
System Information
´ Command: uname
´ Usage: Displays system information.
´ Example: uname -a for all details.
´ Command: df
´ Usage: Shows disk space usage.
´ Example: df -h for human-readable format.
Process Management
´ Command: ps
´ Usage: Displays current processes.
´ Example: ps aux for detailed view.
´ Command: kill
´ Usage: Terminates a process.
´ Example: kill 1234 (where 1234 is the process ID).
Networking Commands
´ Command: ifconfig or ip
´ Usage: Configures network interfaces.
´ Example: ip addr for IP addresses.
´ Command: ping
´ Usage: Tests connectivity to a host.
´ Example: ping google.com.
Package Management
´ Command: touch
´ Usage: Create an empty file.
´ Example: touch newfile.txt.
´ Command: grep
´ Usage: Search text using patterns.
´ Example: grep 'pattern' file.txt.
´ Command: find
´ Usage: Search for files in a directory.
´ Example: find / -name filename.
Comparing Linux Distributions
´ Overview:
´ Linux Distributions (Distros): Variants of Linux tailored for different user needs,
each with unique features and objectives.
´ Purpose of Distros: Provide users with specific tools, interfaces, and configurations
suited to different use cases, from desktops to servers.
´ Common Features:
´ Kernel: All distributions are based on the Linux kernel, which manages hardware
resources and system processes.
´ Package Manager: Each distro comes with a package manager to install,
update, and manage software. Examples include apt for Debian-based systems
and yum/dnf for Red Hat-based systems.
Cont.
´ Common Features:
´ Desktop Environment: The graphical interface users interact with. Options include
GNOME, KDE, XFCE, and others, providing various levels of customization and
resource usage.
´ Types of Distributions:
´ General-purpose: Suitable for everyday use, such as Ubuntu and Fedora, offering
a balance of features and ease of use.
´ Enterprise: Focused on stability and long-term support, such as CentOS and Red
Hat Enterprise Linux, often used in corporate environments.
´ Lightweight: Designed for performance on older or resource-constrained
hardware, such as Lubuntu or Puppy Linux.
Cont.
´ Types of Distributions:
´ Security-focused: Tailored for security professionals, featuring tools for
penetration testing and forensics, like Kali Linux.
´ Choosing a Distribution:
´ User Experience: Consider ease of use, community support, and available
documentation.
´ Purpose: Match the distribution to your specific needs, whether it's for personal
use, development, servers, or security.
´ Support and Community: Larger communities offer more resources, forums, and
tutorials, which can be crucial for troubleshooting and learning.
Popular Linux Distributions
´ Overview:
´ Services (daemons) are background processes that perform essential tasks.
´ Linux services provide essential capabilities for server and network management.
´ Understanding and configuring these services is crucial for system administrators.
´ Purpose:
´ Enable functionality like web hosting, file sharing, and system monitoring.
´ Advice:
´ Evaluate your needs to choose the right services.
´ Regularly monitor and update services for security and efficiency.
Web Server Services
´ Apache:
´ Function: Hosts websites and serves web pages over HTTP/HTTPS.
´ Features:
´ Modular Architecture: Highly customizable with modules for authentication, SSL, URL rewriting,
and more.
´ Supports Dynamic Content: Modules like mod_php allow integration with PHP, Python, and Perl.
´ Popular for Static and Dynamic Content: Used widely for both static sites and dynamic
applications.
´ Commands:
´ Install:
´ sudo apt install apache2 (Debian/Ubuntu),
´ Commands:
´ Start Service:
´ sudo systemctl start apache2 (Ubuntu)
´ sudo systemctl start httpd (CentOS)
´ Commands:
´ Install:
´ sudo apt install nginx (Debian/Ubuntu)
´ sudo yum install nginx (CentOS/RHEL)
´ MySQL/MariaDB:
´ Function: Relational database management system for handling structured data.
´ Features:
´ High Performance and Scalability: Widely used for websites and applications requiring high transaction
rates.
´ Supports Replication and Clustering: Ensures high availability and load balancing.
´ SQL Compatibility: Runs SQL queries for database operations.
´ Commands:
´ Install:
´ sudo apt install mysql-server (Debian/Ubuntu)
´ sudo yum install mariadb-server (CentOS/RHEL)
´ PostgreSQL:
´ Function: Advanced open-source relational database system supporting complex operations.
´ Features:
´ Supports Advanced Queries: Suited for large datasets with complex queries.
´ Extensible: Supports custom functions, data types, and indexing techniques.
´ ACID Compliant: Reliable data transactions, widely used in analytics and scientific applications.
´ Commands:
´ Install:
´ sudo apt install postgresql (Debian/Ubuntu)
´ Commands:
´ Start Service: sudo systemctl start ssh
´ Connect to Remote System: ssh user@hostname
´ Generate SSH Key Pair: ssh-keygen -t rsa -b 4096
Cont.
´ Firewall (iptables/nftables):
´ Function: Controls network traffic, manages rules for incoming/outgoing
connections.
´ Features:
´ Rule-based Traffic Control: Configure specific traffic rules to protect servers.
´ Highly Configurable: Supports complex rule sets for different network zones.
´ Commands:
´ Add Rule: sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT (for iptables)
´ List Rules: sudo iptables -L (iptables), sudo nft list ruleset (nftables)
´ Save Rules: sudo iptables-save > /etc/iptables/rules.v4
Conclusion
´ These slides provide foundational knowledge about what Linux is, its core
attributes, and how its file system is organized, setting the stage for
understanding basic commands and distributions.
´ Also we have an overview of key Linux services, explaining their functions
and features, which are crucial for managing and deploying Linux systems
effectively.
´ This slide provides a comprehensive overview of what Linux distributions are
and how they differ, helping users understand the landscape and make
informed choices.
References
´ Online Resources:
´ Linux Documentation Project
´ Ubuntu Official Documentation
´ ArchWiki
´ Books:
´ "The Linux Command Line" by William Shotts
´ "Linux Pocket Guide" by Daniel J. Barrett