System Administration Theory Notes
System Administration Theory Notes
System
A system is a set of interrelated components working together towards a common goal by
accepting inputs and producing outputs in an organized transformation process. Systems can be
simple, like a thermostat, or complex, like a computer network. Systems are everywhere, and
their primary purpose is to solve problems or provide services by processing information or
controlling other systems.
3. Networking Components
3.1 Network Devices
• Switches: Connect multiple devices on a local network and use MAC addresses to
forward data to the correct destination.
• Routers: Connect different networks and route data between them, typically using IP
addresses.
• Firewalls: Protect the server environment by monitoring and controlling incoming and
outgoing network traffic based on predetermined security rules.
3.2 Transmission Media
• Wired Media: Includes Ethernet cables (Cat5e, Cat6, etc.) and fiber optic cables for high-
speed data transmission.
• Wireless Media: Includes Wi-Fi, Bluetooth, and cellular networks for wireless
connectivity.
4. Security Components
• Antivirus and Anti-malware Software: Protects servers from malicious software and
cyber threats.
• Intrusion Detection and Prevention Systems (IDS/IPS): Monitor network traffic for
suspicious activity and take action to prevent attacks.
• Access Control Systems: Manage user permissions and ensure that only authorized
individuals can access specific resources.
• Encryption Tools: Encrypt data to protect it from unauthorized access during
transmission or while at rest.
5. Management and Monitoring Tools
• Server Management Software: Tools like Microsoft System Center, VMware vCenter, and
Red Hat Satellite that help manage server resources, configurations, and updates.
• Monitoring Tools: Software like Nagios, Zabbix, and Prometheus that continuously
monitor server performance, resource usage, and health, providing alerts for any issues.
6. Backup and Recovery Solutions
• Backup Software: Solutions like Veeam, Acronis, and Bacula that automate the process
of backing up data and systems.
• Disaster Recovery Solutions: Plans and tools that ensure data and services can be quickly
restored in the event of a disaster.
7. Virtualization and Cloud Components
• Hypervisors: Software like VMware ESXi, Microsoft Hyper-V, and KVM that enable
multiple virtual machines to run on a single physical server.
• Cloud Services: Platforms like Amazon Web Services (AWS), Microsoft Azure, and Google
Cloud Platform (GCP) that provide scalable computing resources and services over the
internet.
By understanding and effectively managing these components, system administrators can
ensure a robust, secure, and efficient server environment that meets the needs of their
organization.
Microsoft Server Environment
Microsoft servers run on the Windows Server operating system. These environments are
commonly used in businesses due to their user-friendly interfaces, extensive support, and
integration with other Microsoft products.
1. File Sharing: Uses SMB (Server Message Block) protocol. Users can share files and
folders easily using Windows Explorer.
2. Boot Process: The boot process involves BIOS/UEFI, Boot Loader (Windows Boot
Manager), and OS Initialization.
3. Commands and Interfaces: Primarily managed using GUI (Graphical User Interface)
through tools like Server Manager. Command-line tools include PowerShell and
Command Prompt.
Firewall
A firewall is a network security device that monitors and filters incoming and outgoing network
traffic based on an organization’s previously established security policies.
Working
Firewalls establish a barrier between secured internal networks and untrusted external
networks. They analyze data packets and determine whether they should be allowed through
based on pre-configured rules.
Types
1. Packet-filtering Firewalls: Inspect packets and allow/block them based on
source/destination addresses, ports, and protocols.
2. Stateful Inspection Firewalls: Track the state of active connections and make decisions
based on the context of the traffic.
3. Proxy Firewalls: Act as intermediaries between end-users and the web services they
access.
4. Next-Generation Firewalls (NGFWs): Include advanced features such as deep packet
inspection, intrusion prevention systems (IPS), and application awareness.
Typical Costs
• Basic Support: May range from $300 to $1,000 annually for small businesses with
standard support hours.
• Enhanced Support: Can range from $1,000 to $5,000 annually, including faster response
times and more comprehensive services.
• Premium Support: Large enterprises may pay from $5,000 to $20,000 or more annually
for 24/7 support, immediate response times, and extensive coverage.
Spare Parts
Spare Parts are essential components kept on hand to replace failed parts quickly, minimizing
server downtime. Maintaining an inventory of spare parts ensures that critical hardware can be
replaced promptly, without waiting for shipments or repairs. Here are detailed notes on spare
parts management:
Client-Server OS Configuration
Configuring the operating system (OS) in a client-server environment involves setting up both
the server and client systems to communicate effectively and securely.
3. Package Management:
o Update System: Use package managers like apt, yum, or dnf to update the
system.
o Install Required Software: Install necessary packages and services.
4. Security Configuration:
o Configure Firewall: Use iptables, firewalld, or ufw to manage firewall rules.
o Enable SELinux/AppArmor: Enhance security with mandatory access controls.
o Set Up SSH: Configure /etc/ssh/sshd_config for secure remote access.
5. User and Group Management:
o Create and manage user accounts using useradd and usermod.
o Assign users to groups with appropriate permissions.
Providing Remote Console Access
Remote console access allows administrators to manage servers remotely, ensuring they can
perform maintenance, troubleshooting, and configuration tasks from anywhere.
1. Windows Server
Important Attributes
• Ease of Use: Windows Server offers a user-friendly interface with graphical management
tools.
• Compatibility: Widely compatible with various applications, especially those from
Microsoft.
• Integration: Seamless integration with other Microsoft products and services.
Key Features
• Active Directory: Centralized domain management service for user and resource
management.
• Hyper-V: Built-in hypervisor for virtualization.
• Internet Information Services (IIS): Web server role for hosting websites and web
applications.
• PowerShell: Command-line shell and scripting language for automation and
configuration management.
• Windows Admin Center: Centralized, browser-based management tool for servers.
Pros
• User-Friendly: Intuitive GUI and easy-to-use management tools.
• Enterprise Integration: Excellent integration with other Microsoft enterprise products.
• Support: Extensive official support and documentation.
• Security: Regular updates and robust security features like BitLocker and Windows
Defender.
Cons
• Cost: Higher licensing and operational costs compared to Linux.
• Resource Intensive: Requires more system resources (CPU, RAM) for comparable
performance.
• Closed Source: Proprietary software limits customization and flexibility.
2. Linux
Important Attributes
• Open Source: Source code is freely available, allowing for customization and
transparency.
• Stability: Known for its stability and reliability, especially in server environments.
• Security: Strong security model and community-driven updates.
Key Features
• Package Management: Tools like APT (Debian/Ubuntu) and YUM/DNF (Red Hat/CentOS)
for software management.
• Shell Scripting: Powerful command-line interface (CLI) and scripting capabilities.
• Systemd: Modern init system for managing system processes and services.
• Virtualization: Support for KVM, Xen, and other virtualization technologies.
• Networking: Advanced networking tools and configurations.
Pros
• Cost-Effective: Free to use and deploy, with no licensing fees.
• Performance: Efficient use of system resources, leading to better performance.
• Flexibility: Highly customizable to meet specific needs.
• Community Support: Large community of users and developers providing support and
updates.
Cons
• Learning Curve: Steeper learning curve for those unfamiliar with command-line
interfaces.
• Hardware Compatibility: May have compatibility issues with some hardware.
• Support: Reliance on community support, with limited official support options.
Key Differences
Attribute Windows Server Linux
Ease of Use User-friendly GUI, easy for beginners CLI-based, steeper learning curve
Cost Higher licensing and operational costs Free and open-source, lower costs
Integration Excellent with Microsoft products Flexible, integrates with various tools
Conclusion
Choosing between Windows Server and Linux depends on the specific needs and resources of
an organization:
• Windows Server is ideal for businesses heavily invested in the Microsoft ecosystem,
requiring ease of use and robust official support.
• Linux is preferred for its cost-effectiveness, performance efficiency, and flexibility,
making it suitable for organizations with technical expertise and a need for
customization.
Both operating systems have their strengths and weaknesses, and the choice should align with
the organization's infrastructure, budget, and technical capabilities.
Linux Installation and Verification
Steps for Installing Linux
2. Installation Process
1. Boot from Installation Media: Insert the bootable USB or DVD into the computer and
boot from it.
2. Start Installation: Select “Install” from the boot menu.
3. Language Selection: Choose the language for the installation process.
4. Preparing Disk:
o Partitioning: Choose how to partition the disk (e.g., automatic, manual).
o Filesystem: Select the filesystem (e.g., ext4, XFS).
5. User Information:
o Set up a user account and password.
o Configure the hostname for the system.
6. Software Selection: Choose the software packages to install (e.g., server packages,
desktop environment).
7. Installation: Begin the installation process and wait for it to complete.
8. Reboot: After installation, remove the installation media and reboot the system.
3. Post-Installation Verification
1. Login: Log in using the created user account.
2. Check System Information:
o Use uname -a to verify kernel version.
o Use lsb_release -a to verify distribution version (for distributions that support it).
3. Check Network Configuration:
o Use ip a to check network interfaces and IP addresses.
o Use ping to test network connectivity.
4. Verify Installed Packages:
o Use package manager commands (e.g., dpkg -l for Debian-based, rpm -qa for Red
Hat-based) to list installed packages.
• Red Hat-based:
sudo yum update
4. Removing Software
• Debian-based:
sudo apt remove package-name
sudo apt autoremove
• Red Hat-based:
sudo yum remove package-name
5. Package Search and Information
• Debian-based:
apt search package-name
apt show package-name
• Red Hat-based:
yum search package-name
yum info package-name
Managing Network Services
Network services are crucial for server functionality, enabling communication and resource
sharing. Proper management ensures these services are secure and performant.
1. Nagios
Nagios is a popular open-source network monitoring tool that provides comprehensive
monitoring of servers, switches, applications, and services.
• Features:
o Real-time monitoring
o Alerting and notification
o Performance graphing
o Customizable plugins
• Installation:
sudo apt install nagios-nrpe-server nagios-plugins # Debian-based
sudo yum install nagios nrpe nagios-plugins-all # Red Hat-based
2. Zabbix
Zabbix is another robust open-source monitoring tool, known for its scalability and rich feature
set.
• Features:
o Distributed monitoring
o Visualization and reporting
o Autodiscovery of network devices
o Customizable alerts and notifications
• Installation:
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent # Debian-based
sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent # Red Hat-based
3. Prometheus
Prometheus is a powerful open-source system monitoring and alerting toolkit, designed for
reliability and scalability.
• Features:
o Multi-dimensional data model
o Flexible query language (PromQL)
o Time series database
o Alertmanager for handling alerts
• Installation:
# Download and install Prometheus
wget
https://github.com/prometheus/prometheus/releases/download/v2.24.0/prometheus-
2.24.0.linux-amd64.tar.gz
tar -xvzf prometheus-2.24.0.linux-amd64.tar.gz
cd prometheus-2.24.0.linux-amd64
./Prometheus
IP Tables and Filtering: Detailed Notes
Introduction to IP Tables
IP Tables is a powerful firewall tool in Linux used for managing network packet filtering and NAT
(Network Address Translation). It allows administrators to set up, maintain, and inspect the
tables of IP packet filter rules in the Linux kernel. Each table contains chains, which are lists of
rules that match packets.
Key Concepts
Tables
There are several built-in tables in IP Tables, each serving a specific purpose:
• filter: The default table, used for packet filtering.
• nat: Used for network address translation.
• mangle: Used for specialized packet alteration.
• raw: Used for raw packet handling.
• security: Used for security purposes, SELinux extensions.
Chains
Each table contains built-in chains:
• INPUT: Incoming packets to the host.
• OUTPUT: Outgoing packets from the host.
• FORWARD: Packets being routed through the host.
• PREROUTING: Packets before routing.
• POSTROUTING: Packets after routing.
Rules
Rules specify criteria for packets and the action to take if a packet matches. Actions can include:
• ACCEPT: Allow the packet.
• DROP: Drop the packet silently.
• REJECT: Drop the packet and send an error.
• LOG: Log the packet.
Basic Commands
Viewing Rules
• List all rules:
sudo iptables -L
• List rules in a specific chain:
sudo iptables -L INPUT
Adding Rules
• Allowing traffic on a specific port:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
• Dropping traffic from a specific IP:
sudo iptables -A INPUT -s 192.168.1.100 -j DROP
Deleting Rules
• Delete a specific rule:
sudo iptables -D INPUT 1 # Deletes the first rule in the INPUT chain
Saving and Restoring Rules
• Save current rules:
sudo iptables-save > /etc/iptables/rules.v4
• Restore saved rules:
sudo iptables-restore < /etc/iptables/rules.v4
Advanced IP Tables Features
NAT (Network Address Translation)
NAT is used to modify network address information in IP packet headers.
• Masquerading (dynamic NAT):
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Port Forwarding
Forward traffic from one port to another.
• Forward port 80 to port 8080:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
Stateful Packet Filtering
Tracks the state of connections and allows or blocks traffic based on it.
• Allow established and related connections:
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Monitoring Tools
• IPTraf: A console-based network monitoring utility.
sudo apt install iptraf
sudo iptraf
• Wireshark: A GUI-based network protocol analyzer.
sudo apt install wireshark
sudo wireshark
Security Best Practices
Default Policies
Set default policies to DROP for security.
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT
Diagnostic Commands
• Check Rules:
sudo iptables -L -v -n
• Test Connectivity:
ping -c 4 google.com
Conclusion
IP Tables is a versatile and powerful tool for managing firewall rules and network packet filtering
in Linux. Proper understanding and management of IP Tables can significantly enhance the
security and functionality of a Linux server.
2. Secure Protocols
Using secure versions of protocols can significantly enhance security.
a. HTTPS (HyperText Transfer Protocol Secure)
• Purpose: Secure version of HTTP, encrypts data exchanged between web servers and
clients.
• Implementation: Requires an SSL/TLS certificate installed on the web server.
c. Access Control
• Purpose: Restricts access to network resources based on user roles and permissions.
• Types:
o Role-Based Access Control (RBAC): Users are assigned roles with specific
permissions.
o Mandatory Access Control (MAC): System-enforced policies restrict access based
on security labels.
d. Network Segmentation
• Purpose: Divides a network into segments to limit the spread of attacks and isolate
sensitive data.
• Implementation: Achieved using VLANs (Virtual Local Area Networks) or physical
segmentation.
4. Monitoring and Auditing
Regular monitoring and auditing of network traffic help detect and respond to security
incidents.
a. Network Monitoring Tools
• Tools:
o Wireshark: Network protocol analyzer for capturing and inspecting network
traffic.
o Nagios: Network monitoring tool that provides real-time alerts and performance
data.
b. Log Management
• Purpose: Collects, stores, and analyzes logs from network devices and systems.
• Tools:
o Syslog: Standard protocol for sending log or event messages to a logging server.
o ELK Stack (Elasticsearch, Logstash, Kibana): A popular stack for log management
and analysis.
b. Strong Authentication
• Purpose: Ensures that only authorized users can access network resources.
• Methods:
o Multi-Factor Authentication (MFA): Requires multiple forms of verification.
o Public Key Infrastructure (PKI): Uses cryptographic keys and certificates for
secure authentication.
Conclusion
Securing network traffic involves a multi-layered approach that includes encryption, secure
protocols, network security measures, monitoring, and proper configuration. By implementing
these practices, organizations can protect their data, maintain privacy, and ensure the integrity
of their network communications.
2. Metadata Management
• File systems store metadata for each file, including file size, creation date, modification
date, and access permissions.
• Example: In NTFS (used in Windows), each file has metadata such as file size and time
stamps visible via right-clicking on a file and selecting "Properties."
• Commands:
o Format: mkfs.ext4 /dev/sdX1
o Check: fsck.ext4 /dev/sdX1
o Resize: resize2fs /dev/sdX1
2. XFS
• Overview: XFS is a high-performance file system designed for handling large files and
high-capacity storage.
• Features:
o Scalability: Supports large file systems and files, ideal for high-performance
computing.
o Journaling: Ensures data integrity by maintaining a log of changes.
o Dynamic Allocation: Allocates space dynamically, which enhances performance.
o Online Defragmentation: Allows defragmentation while the file system is
mounted.
• Commands:
o Format: mkfs.xfs /dev/sdX1
o Check: xfs_repair /dev/sdX1
o Resize: xfs_growfs /mount/point
1. Types of Logs
• System Logs: Record system-level events, such as boot processes and hardware issues.
o Example: /var/log/syslog, /var/log/messages
• Application Logs: Record application-specific events and errors.
o Example: /var/log/apache2/access.log, /var/log/mysql/error.log
• Security Logs: Track security-related events, such as authentication attempts and access
control.
o Example: /var/log/auth.log, /var/log/secure
2. Log Rotation
Log rotation is the process of managing log files by regularly archiving old logs and creating new
ones to prevent logs from consuming too much disk space.
• Configuration:
o Logrotate: A utility that handles log rotation and archiving.
o Configuration File: /etc/logrotate.conf and /etc/logrotate.d/
• Basic Configuration:
/var/log/myapp/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 root root
sharedscripts
postrotate
/usr/libexec/rotate-logs
endscript}
4. Log Analysis
Analyzing logs helps identify issues and trends.
• Tools:
o grep: Search for specific patterns in log files.
grep "error" /var/log/myapp/*.log
o awk: Process and analyze log data.
awk '/error/ {print $0}' /var/log/myapp/*.log
o Logwatch: Provides daily summaries of log file activities.
sudo apt install logwatch
sudo logwatch --detail high --service all --mailto [email protected]
Introduction to Shell and Bash in Linux
Subtitle: Understanding Commands, Scripting,
and Usage
What is Shell?
• Definition: A shell is a command-line interpreter that provides a user interface for
accessing the services of the operating system.
• Function: It interprets user commands, executes them, and displays the results.
• Types of Shells:
o Bourne Shell (sh): One of the earliest Unix shells.
o C Shell (csh): Similar to C programming syntax, includes built-in arithmetic and
scripting.
o Korn Shell (ksh): Combines features of both Bourne and C Shell, adds more
functionality.
o Bourne Again Shell (bash): Enhanced version of the Bourne Shell with modern
features.
What is Bash?
• Definition: Bash (Bourne Again Shell) is a Unix shell and command language, an
enhanced version of the original Bourne Shell (sh).
• Features:
o Command history: Allows recalling previously executed commands.
o Command-line editing: Editing commands directly on the command line.
o Job control: Manages background and foreground processes.
o Shell functions and aliases: Customize commands and reuse code.
• Commonly Used:
o Default shell on many Linux distributions (e.g., Ubuntu, Fedora).
How Commands Work in Linux
• Process:
o User types a command in the shell.
o The shell interprets the command.
o The shell calls the appropriate program or utility.
o The program is executed and the result is returned to the shell.
• Example: ls -l
o ls: Command to list directory contents.
o -l: Option for long listing format, showing file details (permissions, size, etc.).
Shell Scripting
• Definition: A shell script is a file containing a series of commands to be executed by the
shell.
• Purpose: Automate tasks, manage system operations, and create custom tools or
workflows.
• Structure:
o Shebang: #!/usr/bin/env bash or #!/bin/bash defines the script interpreter.
o Commands: The body of the script includes the actual commands to execute.
o Logic: Conditional statements, loops, and functions can be used for dynamic
behavior.
Job Control
• Background Jobs: Commands can be run in the background using &.
o Example: sleep 60 & runs the sleep command in the background.
• Foreground and Background Control:
o Stop a Job: Use Ctrl+Z to pause a job.
o Bring to Foreground: Use fg to bring the job to the foreground.
o List Jobs: jobs command lists background jobs.
Bash Functions
• Definition: Functions in Bash allow reusability of code blocks.
o Example:
greet() {
echo "Hello, $1"
}
greet John
o The function greet takes an argument and outputs a greeting message.
These additional subtopics deepen the understanding of Shell and Bash in Linux by introducing
important concepts like job control, conditionals, loops, redirection, and more practical
examples.
FTP Server
Server-side (RHEL 8)
1. Install and Configure vsftpd:
dnf install vsftpd
systemctl start vsftpd
systemctl enable vsftpd
2. Configure vsftpd.conf:
Edit /etc/vsftpd/vsftpd.conf and ensure the following settings are applied:
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
listen_address=server_IP_address
3. Restart vsftpd:
systemctl restart vsftpd
Client-side (RHEL 8)
1. Install FTP Client:
dnf install ftp
2. Connect to FTP Server:
ftp server_IP_address
Login with ftpuser credentials.
NFS Server
Server-side (RHEL 8)
1. Install and Configure NFS:
dnf install nfs-utils
systemctl start nfs
systemctl enable nfs
2. Configure /etc/exports:
Edit /etc/exports and add the following:
/shared_dir 192.168.1.0/24(ro,async)
Options:
• ro (read-only)
• rw (read-write)
• async (asynchronous)
• sync (synchronous)
5. Restart NFS:
systemctl restart nfs
Client-side (RHEL 8)
1. Install NFS Client:
dnf install nfs-utils
Samba Server
Server-side (RHEL 8)
1. Install Samba:
yum install samba
systemctl start smb
systemctl enable smb
2. Configure /etc/samba/smb.conf:
Edit /etc/samba/smb.conf and add the following section:
[shared_dir]
path = /shared_dir
read only = no
guest ok = yes
3. Create Shared Directory:
mkdir /shared_dir
chmod 755 /shared_dir
5. Restart Samba:
systemctl restart smb
Client-side (RHEL 8)
1. Install Samba Client:
yum install samba-client
DHCP Server
Server-side (RHEL 8)
1. Install DHCP:
yum install dhcp
systemctl start dhcpd
systemctl enable dhcpd
2. Configure /etc/dhcp/dhcpd.conf:
Edit /etc/dhcp/dhcpd.conf and add the following:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
}
3. Restart DHCP:
systemctl restart dhcpd
Client-side (RHEL 8)
1. Configure Network Interface to Use DHCP:
nmcli con modify eth0 ipv4.method auto
Server-side (RHEL 8)
1. Install BIND:
yum install bind
systemctl start named
systemctl enable named
2. Configure /etc/named.conf:
Edit /etc/named.conf and add the following:
zone "example.com" IN {
type master;
file "/var/named/example.com.zone";
};
4. Restart BIND:
systemctl restart named