Day: July 9, 2025

  • Mastering the ‘top’ Command: Tips for Efficient Linux Server Monitoring

    Mastering the ‘top’ Command: Tips for Efficient Linux Server Monitoring

    When it comes to monitoring the health and performance of your Linux servers, the "top" command is often one of the first tools in an administrator’s arsenal. It provides a real-time, dynamic view of what’s happening on your system, including which processes are consuming the most resources and overall system load. Yet, many users only scratch the surface of what "top" can do. This article explores some practical tips and advanced usage that can help you get the most out of the "top" command.

    Basic Usage

    Simply typing top in your terminal brings up a continually updating table of processes. Here you’ll see columns for PID, user, CPU and memory usage, and more. The header section shows system uptime, load averages, and summary information about memory and processes.

    Navigating and Customizing the Display

    • Sorting by column: You can change how processes are sorted. Press P to sort by CPU usage or M to sort by memory usage. For other columns, press Shift + <column key> and watch the table update accordingly.
    • Changing update interval: Press d and enter a new number of seconds to set the screen refresh rate. A longer interval can lessen system load on heavily used servers.
    • Filtering processes: Hit o (lowercase letter o), then type a filter (e.g., USER=apache to see only apache processes).
    • Killing a process: Press k, type the PID of the process, and then the signal (usually 15 for gracefully terminating, or 9 for forcefully ending).

    Useful Command-Line Options

    • Display specific user’s processes: top -u someuser
    • Show only processes with high resource use: Combine with grep or use interactive filters in "top" to focus on processes hogging resources.

    Saving Custom Options

    You can customize the top interface (like adjusting columns and sorting), then press W (capital w) to save your preferred configuration for future sessions.

    Advanced Tips

    • Batch mode (for logs and scripting): top -b -n 1 > top-output.txt runs top in batch mode, which is useful for logging system state or integrating into other scripts.
    • Highlighting active processes: Press z to toggle color highlighting of the most active processes.
    • Tree view: Press V to view the processes in a hierarchical tree mode, showing parent/child relationships.

    Conclusion

    The "top" command is a foundational monitoring tool for Linux server administrators. By mastering its interactive features, command-line options, and customizations, you can gain critical insights into your server’s health and performance—ensuring your hosted web sites and services run smoothly.

    Whether you’re a beginner or a seasoned sysadmin, spending some time with "top" can make all the difference in proactive server management.

  • Securing Apache Web Server: Essential Command-Line Techniques

    Securing Apache Web Server: Essential Command-Line Techniques

    When it comes to hosting web sites on Linux servers, security is always a top priority. While Apache is a robust and reliable web server, its security out-of-the-box typically needs enhancement to withstand modern threats. In this article, I’ll walk you through essential command-line techniques to secure your Apache installation and reduce potential attack surfaces, drawing on my experience managing Linux-based web hosting environments.

    1. Keep Apache and Dependencies Updated

    Running outdated software is a common vulnerability. Update your Apache installation and its dependencies with:

    sudo apt update && sudo apt upgrade apache2   # Debian/Ubuntu
    sudo yum update httpd                        # CentOS/RedHat
    

    Automate this with unattended-upgrades or a systemd timer (see my article on systemd timers for more details).

    1. Disable Unused Apache Modules

    Apache has a modular architecture. Only load what you need:

    sudo apache2ctl -M                      # List enabled modules
    sudo a2dismod autoindex                 # Example for Debian/Ubuntu
    

    After disabling, reload:

    sudo systemctl reload apache2
    

    On RHEL/CentOS, you may need to comment out modules in httpd.conf.

    1. Restrict Directory Permissions

    Use minimal permissions and ownership for web directories. For example:

    sudo chown -R www-data:www-data /var/www/html
    sudo find /var/www/html -type d -exec chmod 750 {} \;
    sudo find /var/www/html -type f -exec chmod 640 {} \;
    
    1. Configure Apache Security Settings

    Edit your main config (often /etc/apache2/apache2.conf or /etc/httpd/conf/httpd.conf) and consider:

    # Hide server version details
    ServerSignature Off
    ServerTokens Prod
    
    # Limit request size to mitigate some DoS attacks
    LimitRequestBody 1048576
    
    # Disable directory listing
    <Directory /var/www/html>
        Options -Indexes
    </Directory>
    
    1. Enable TLS/SSL

    Secure traffic with HTTPS using Let’s Encrypt:

    sudo apt install certbot python3-certbot-apache
    sudo certbot --apache
    

    Certbot configures SSL automatically, but be sure to set strong ciphers and protocols. Example in ssl.conf:

    SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite HIGH:!aNULL:!MD5
    SSLHonorCipherOrder on
    
    1. Monitor Logs Regularly

    Automate log checks with tools like fail2ban, and inspect logs on the command line:

    tail -f /var/log/apache2/access.log /var/log/apache2/error.log
    

    Conclusion

    By applying these straightforward command-line techniques, you can lock down your Apache web server and help protect your web sites against common vulnerabilities. Stay proactive—monitor updates, prune what’s unnecessary, and automate where possible for a safer, more resilient hosting environment.

  • Customizing the Drupal Admin UI with Admin Toolbar and Beyond

    Customizing the Drupal Admin UI with Admin Toolbar and Beyond

    As a Drupal developer, one of my favorite tricks to improve both my workflow and my clients’ satisfaction is refining the Drupal admin interface. While Drupal’s default admin backend is powerful, it can be overwhelming—or a bit inefficient—out of the box. Today, I’ll walk you through practical enhancements you can make to the admin UI, focusing on the must-install Admin Toolbar module and a few other helpful tweaks.

    1. Install and Configure the Admin Toolbar Module

    The Admin Toolbar is an almost mandatory module for any serious Drupal site. It builds upon the standard Toolbar module, transforming the top navigation into a hierarchical drop-down menu that dramatically reduces clicks to access deep configuration pages.

    How to Install:

    1. Use Drush: drush en admin_toolbar admin_toolbar_tools -y
    2. Or, use Extend in the UI to enable both Admin Toolbar and Admin Toolbar Tools.

    Bonus: When working in a development or staging environment, enable admin_toolbar_search for quick admin page access. (Don’t forget to disable it in production for performance reasons.)

    2. Streamline Navigation with Shortcuts

    Customizing your shortcut bar to include most-used items (like Content, Structure, and Configuration pages) can save minutes every day. Go to Manage > Shortcuts to add or reorder relevant links. Encourage your clients to curate their shortcut sets as well!

    3. Clean Up the Dashboard

    The dashboard can be made less overwhelming by hiding or rearranging blocks. Use the Block Layout configuration in the UI or the contributed module Adminimal Admin Toolbar for a cleaner look.

    4. Use the "Coffee" Module for Power Users

    For keyboard-centric navigation, the Coffee module is a revelation: hit Alt+D+F (or Alt+Shift+D depending on your OS), start typing the name of any admin page, and jump directly there. Your admins will thank you for introducing this time-saving power tool.

    5. Simplify and Personalize the Interface

    Help editors by hiding unnecessary menu items and permissions. The Admin Menu Per Role module or careful user permissions configuration ensures each user only sees what they really need.

    In Summary:
    By taking a few minutes to install and configure key UI modules—and tailoring the admin interface to your (and your clients’) needs—you’ll make Drupal both more powerful and more pleasant to use. For me, Admin Toolbar is always the first step, but there’s so much more you can do. Happy site building!

    — Drew

  • Getting Started with Material Design in Angular: Styling Your First Component

    Getting Started with Material Design in Angular: Styling Your First Component

    As a web designer, I’m always on the lookout for ways to create visually appealing and user-friendly interfaces. Material Design, developed by Google, provides a cohesive design language and a vast set of UI components, making it a popular choice for Angular developers. In this article, I’ll guide you through the basics of implementing Material Design in your Angular app and offer styling tips for your first component.

    Why Material Design?

    Material Design offers:

    • Consistency across your app
    • A wide variety of ready-made UI components
    • Responsiveness and accessibility

    Setting up Angular Material

    To start using Material Design in Angular, follow these steps:

    1. Install Angular Material
    ng add @angular/material
    
    1. Choose a Prebuilt Theme
      During installation, you’ll be prompted to select a prebuilt theme. For beginners, I recommend starting with Indigo/Pink for its balanced contrast.

    2. Import Material Modules
      Open your app.module.ts and import the necessary Material modules. For instance, to use buttons and cards:

    import { MatButtonModule } from '@angular/material/button';
    import { MatCardModule } from '@angular/material/card';
    
    @NgModule({
      imports: [
        MatButtonModule,
        MatCardModule,
        // other modules
      ]
    })
    

    Styling Your First Material Component

    Let’s create a simple, eye-catching card component.

    1. Update your template:
    <mat-card class="custom-card">
      <mat-card-title>Welcome to Material Design</mat-card-title>
      <mat-card-content>
        <p>This is your first styled Material component!</p>
      </mat-card-content>
      <button mat-raised-button color="primary">Get Started</button>
    </mat-card>
    
    1. Add custom SCSS styling:
    .custom-card {
      max-width: 400px;
      margin: 2rem auto;
      padding: 1rem;
      background: linear-gradient(135deg, #ece9f7 0%, #e1f5fe 100%);
      box-shadow: 0 4px 20px rgba(0,0,0,0.1);
      border-radius: 16px;
    
      mat-card-title {
        color: #3f51b5;
        font-weight: 700;
      }
    }
    

    Pro Tip: Responsive Typography

    Material Design components scale beautifully, but you can further enhance responsiveness by using Angular Material’s typography config. Check the documentation to set up custom breakpoints and typography styles.

    Conclusion

    With Angular and Material Design, it’s easy to build stunning interfaces efficiently. Experiment with different components and SCSS customizations to match your brand and UX goals. Have fun designing, and stay tuned for more tips!

    — Maddie