Category: General

  • Finally getting a chance to watch Invincible S2…

    … so far, not too impressed. The story telling is choppy. A lot of filler content with a thin story line.

  • MySQL CLI Quick Reference

    Connecting to MySQL

    • Login to MySQL:
      mysql -u username -p

    Prompts for a password.

    • Specify Database on Login:
      mysql -u username -p -D database_name

    Basic Commands

    • Show all databases:
      SHOW DATABASES;
    • Select a database:
      USE database_name;
    • Show all tables in the current database:
      SHOW TABLES;
    • Describe the structure of a table:
      DESCRIBE table_name;
    • Show the current MySQL user:
      SELECT USER();
    • Show current database:
      SELECT DATABASE();
    • Show process list:
      SHOW PROCESSLIST;
    • Show full process list (to see full queries):
      SHOW FULL PROCESSLIST;
    • Exit MySQL:
      EXIT;

    CRUD Operations

    • Create a new database:
      CREATE DATABASE database_name;
    • Create a new table:
      CREATE TABLE table_name (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(100),
        age INT
      );
    • Insert data into a table:
      INSERT INTO table_name (name, age) VALUES ('John', 30);
    • Select data from a table:
      SELECT * FROM table_name;
    • Update data in a table:
      UPDATE table_name SET age = 31 WHERE name = 'John';
    • Delete data from a table:
      DELETE FROM table_name WHERE name = 'John';
    • Drop a table:
      DROP TABLE table_name;

    Loading .sql Files

    To load and execute an SQL file that contains queries or database structure (e.g., schema.sql or data.sql):

    Method 1: From Inside the MySQL Prompt
    1. Open MySQL:
       mysql -u username -p
    1. Select the database you want to load the file into:
       USE database_name;
    1. Load the SQL file:
       SOURCE /path/to/your/file.sql;
    Method 2: Directly from the Command Line

    You can execute the SQL file directly from the command line without entering the MySQL prompt:

    mysql -u username -p database_name < /path/to/your/file.sql

    This method runs the .sql file directly into the specified database.

    Common Tips

    • View running MySQL queries:
      Use SHOW FULL PROCESSLIST; to view running queries, especially helpful for debugging long-running queries.
    • Check MySQL version:
      SELECT VERSION();
    • Enable SQL logging:
      Use SET GLOBAL general_log = 'ON'; to start logging all queries. To view the log, check the path from the following:
      SHOW VARIABLES LIKE 'general_log_file';

    These commands and tips should help you navigate MySQL efficiently!

  • Things that will never die…

    PHP, Ubuntu Desktop, and WordPress… and I’m perfectly happy with that.

    Fight me.

  • Edging Ubuntu 24.04 on a Thumb Drive

    Trying out running Ubuntu on my mid-2015 MacBook Pro. Except for some quirks (and some lag, due to…well, the os being mounted from a thumb drive), it’s remarkably enjoyable.

  • Uninstall Chrome on Linux

    1. Open a terminal window.
      • On GNOME, Unity, and Cinnamon environments, press Ctrl + Alt + t.
      • On KDE environments, go to Application Menu System Konsole.
    2. Enter the uninstall command:
      • Debian-based systems: Enter sudo dpkg -r google-chrome-stable.
      • Other systems: Enter sudo rpm -e google-chrome-stable.
    3. When prompted, enter your computer’s password.

    Sauce

    Uninstall Chrome on Linux
  • Code Block Pro adds tags to my posts

    Kind of lame. I don’t like it when plugins add fluff to my content/website. Aside from mentioning it here, I may submit a ticket for this to find out if it’s a bug or feature.

  • UFW Cheatsheet

    Here’s a comprehensive sudo ufw (Uncomplicated Firewall) cheatsheet for managing firewall rules on an Ubuntu server:

    Basic UFW Commands

    • Enable UFW:
      sudo ufw enable
    • Disable UFW:
      sudo ufw disable
    • Check UFW Status:
      sudo ufw status
    • Use sudo ufw status verbose for detailed output.
    • Reset UFW (removes all rules and disables UFW):
      sudo ufw reset

    Allowing Connections

    • Allow a Specific Port:
      sudo ufw allow <port>
    • Example: sudo ufw allow 22 (allows SSH)
    • Allow a Port with a Specific Protocol:
      sudo ufw allow <port>/<protocol>
    • Example: sudo ufw allow 80/tcp (allows HTTP)
    • Allow a Range of Ports:
      sudo ufw allow <start port>:<end port>/protocol
    • Example: sudo ufw allow 1000:2000/tcp
    • Allow Connections from a Specific IP:
      sudo ufw allow from <IP>
    • Example: sudo ufw allow from 192.168.1.100
    • Allow Connections from an IP to a Specific Port:
      sudo ufw allow from <IP> to any port <port>
    • Example: sudo ufw allow from 192.168.1.100 to any port 22
    • Allow Subnet:
      sudo ufw allow from <subnet>
    • Example: sudo ufw allow from 192.168.1.0/24

    Denying Connections

    • Deny a Specific Port:
      sudo ufw deny <port>
    • Example: sudo ufw deny 23 (denies Telnet)
    • Deny a Port with a Specific Protocol:
      sudo ufw deny <port>/<protocol>
    • Example: sudo ufw deny 80/tcp
    • Deny Connections from a Specific IP:
      sudo ufw deny from <IP>
    • Example: sudo ufw deny from 192.168.1.100

    Deleting Rules

    • Delete a Rule by Rule Number:
      sudo ufw status numbered
    • Then use sudo ufw delete <rule number>
    • Delete an Allow Rule:
      sudo ufw delete allow <port>
    • Example: sudo ufw delete allow 22
    • Delete a Deny Rule:
      sudo ufw delete deny <port>
    • Example: sudo ufw delete deny 23

    Advanced UFW Usage

    • Enable UFW Logging:
      sudo ufw logging on
    • off to disable logging.
    • Set Default Policies (Deny Incoming and Allow Outgoing):
      sudo ufw default deny incoming
      sudo ufw default allow outgoing
    • Set Default Policies (Allow Incoming and Deny Outgoing):
      sudo ufw default allow incoming
      sudo ufw default deny outgoing
    • Limit Connections (Rate Limiting):
      sudo ufw limit <port>
    • Example: sudo ufw limit ssh (limits SSH connections to prevent brute force attacks)
    • Allow Specific Service by Name:
      sudo ufw allow <service>
    • Example: sudo ufw allow OpenSSH
    • App Profiles (View Available Profiles):
      sudo ufw app list
    • Allow Application Profile:
      sudo ufw allow <app profile>
    • Example: sudo ufw allow 'Apache Full'

    Checking UFW Status and Rules

    • Check UFW Status:
      sudo ufw status
    • Check UFW Status in Verbose Mode:
      sudo ufw status verbose
    • Check UFW Status with Rule Numbers:
      sudo ufw status numbered

    Other Useful Commands

    • Reload UFW to Apply Changes:
      sudo ufw reload
    • Show Detailed Report:
      sudo ufw show raw
    • This displays the raw iptables rules used by UFW.

    This cheatsheet covers common UFW commands and options, providing a solid reference for managing firewall settings on Ubuntu.

    UFW Cheatsheet