Administration

Linux system administration involves managing and maintaining Linux systems to ensure they run efficiently, securely, and reliably. It includes managing user accounts by creating, modifying, and deleting them, as well as setting permissions and group memberships using commands like adduser, passwd, and usermod. Administrators manage the file system by monitoring disk usage, mounting/unmounting file systems, and setting file permissions with tools like chmod, chown, df, and mount.

Process management involves monitoring and controlling system processes using commands such as ps, top, kill, and systemctl for managing services. Package management ensures software is installed, updated, or removed as needed using package managers like apt for Debian-based systems or yum/dnf for Red Hat-based distributions. Network configuration involves setting up IP addresses, troubleshooting connectivity, and managing open ports using tools like ip, ping, and netstat.

Security management focuses on configuring firewalls with tools like ufw or iptables, managing SSH access, and applying updates to secure the system. Backups are handled using tools like rsync, tar, and scheduled with cron, ensuring data is safe and recoverable. Administrators monitor logs stored in directories like /var/log using commands like cat and journalctl and use logrotate to manage log file sizes.

Automation and scripting are integral, with repetitive tasks automated using Bash scripts and scheduled via cron. Performance monitoring is conducted with tools like top, htop, and vmstat to track resource usage and optimise performance. System and kernel updates are applied using package managers, followed by reboots if necessary.

Best practices include documenting changes, regularly applying updates, maintaining backups, minimizing root access through sudo, and continuously monitoring systems with tools like Nagios or Prometheus. Mastering these tasks forms the foundation of effective Linux system administration.

  • Posted on
    Featured Image
    Monitoring and restarting failed services with a Bash script is a practical way to maintain service uptime. Here's a step-by-step guide: The systemctl command is used to monitor services: Check if a service is active: systemctl is-active <service_name> Returns active if the service is running, or inactive/failed otherwise. Check if a service is failed: systemctl is-failed <service_name> Returns failed if the service has failed, or active/inactive otherwise. 2.
  • Posted on
    Featured Image
    Network diagnostics are vital for troubleshooting and maintaining system connectivity. Bash scripts can simplify tasks like checking connectivity, diagnosing network issues, and gathering performance metrics. In this guide, we will create a custom Bash script for network diagnostics. Here is a foundational Bash script to perform essential network diagnostic tasks: #!/bin/bash # Variables LOG_FILE="/var/log/network_diagnostics.log" # Log file for diagnostics PING_TARGET="8.8.8.8" # Default target for connectivity test INTERFACE="eth0" # Network interface to monitor # Function to check connectivity check_connectivity() { if ping -c 4 "$PING_TARGET" &>/dev/null; then echo "[$(date)] INFO: Connectivity to $PING_TARGET is successful.
  • Posted on
    Featured Image
    Log file management is essential for maintaining a healthy system, especially when dealing with large volumes of log data. Bash scripts can automate tasks like log rotation, archiving, and cleanup to ensure disk space is conserved and logs remain organized. This guide provides a step-by-step approach to creating a script for managing log files. Here’s a foundational Bash script to handle basic log file management tasks such as archiving and cleanup: #!/bin/bash # Variables LOG_DIR="/var/log/myapp" # Directory containing log files ARCHIVE_DIR="/var/log/archive" # Directory for archived logs RETENTION_DAYS=30 # Number of days to retain logs LOG_FILE="/var/log/log_management.
  • Posted on
    Featured Image
    Managing user accounts is a critical administrative task in Linux systems. Automating these tasks with Bash scripts can save time and reduce errors. In this guide, we will walk through creating a Bash script to handle common user account operations such as creating users, deleting users, and modifying user attributes. Here’s a foundational Bash script to manage user accounts: #!/bin/bash # Variables LOG_FILE="/path/to/user_management.log" # Log file for user management actions # Function to create a user create_user() { local USERNAME=$1 if id "$USERNAME" &>/dev/null; then echo "[$(date)] ERROR: User $USERNAME already exists.
  • Posted on
    Featured Image
    Monitoring system resources is vital for ensuring stable and efficient system performance. Bash scripts offer a lightweight and customizable way to track CPU usage, memory consumption, disk space, and more. This guide walks you through creating a Bash script to monitor these resources and explores advanced customizations for enhanced functionality. Here's a fundamental Bash script for monitoring CPU, memory, and disk usage: #!/bin/bash # Variables LOG_FILE="/var/log/system_monitor.
  • Posted on
    Featured Image
    Monitoring disk usage is essential for maintaining system health and ensuring adequate storage space. Here’s how you can monitor disk usage using various Bash commands: Command: df Usage: View disk usage for all mounted filesystems: df -h -h: Displays output in human-readable format (e.g., GB, MB). Filter for a specific filesystem or directory: df -h /path/to/directory 2. Analyze Directory Sizes Command: du Usage: Display the size of a directory and its subdirectories: du -h /path/to/directory Show only the total size of a directory: du -sh /path/to/directory -s: Summarize the total size. -h: Human-readable format. Command: watch Usage: Use watch to run df repeatedly at intervals: watch -n 5 df -h -n 5: Refresh every 5 seconds. 4.