Skip to main content

Posts

Showing posts from September, 2025

Linux Network Troubleshooting

If you've spent any time as a sysadmin — or honestly, just as someone who's had to fix their own home network at 11pm — you know that connectivity issues are one of the most common headaches out there. The good news is that a handful of core tools and a methodical approach can take you from "why isn't this working" to a root cause pretty quickly.  This guide walks through the essentials: configuring interfaces, managing routes, and diagnosing problems when things go sideways. Configuring Network Interfaces Your network interfaces are the actual bridge between your machine and the outside world, so getting them configured correctly is step one for any kind of reliable connectivity. Doing It Manually ifconfig is the old-school, tried-and-true tool for this on Unix-like systems. To see everything currently configured, run: ifconfig -a If you need to manually set up a specific interface — assigning an IP, a netmask, and bringing it online — it looks like this: ifconf...

Mail server

 Here's how to set up a mail server on Linux with Apache: Prerequisites and Components You'll need a Linux server (Ubuntu/CentOS), Apache web server, and mail server software like Postfix (SMTP) and Dovecot (IMAP/POP3).  Install these packages using your distribution's package manager. Basic Setup First, install required packages: sudo apt update sudo apt install postfix dovecot-imapd dovecot-pop3d apache2 Configure Postfix by editing /etc/postfix/main.cf : Set myhostname to your domain Configure mydomain and myorigin Set inet_interfaces = all Define mydestination with your domains Dovecot Configuration Edit /etc/dovecot/dovecot.conf : Enable protocols (imap, pop3) Set mail location ( mail_location = maildir:~/Maildir ) Configure authentication mechanisms Apache Integration Apache typically serves webmail interfaces like Roundcube or SquirrelMail. Install a webmail client: sudo apt install roundcube Configure Apache virtual host to serve the webmai...

Ruby data types

  Ruby Basic Data Types are fundamental building blocks that store different kinds of information. Ruby is dynamically typed, meaning variables don't need explicit type declarations, and everything in Ruby is an object with built-in methods. 1. Numbers: Ruby handles integers and floating-point numbers seamlessly: # Integers age = 25 big_number = 1_000_000 # Underscores for readability puts age.class # Integer # Floats height = 5.9 pi = 3.14159 puts height.class # Float # Number operations puts 10 + 5 # 15 puts 10.0 / 3 # 3.3333333333333335 puts 10 / 3 # 3 (integer division) puts 2 ** 8 # 256 (exponentiation) 2. Strings: Strings are sequences of characters with powerful manipulation methods: name = "Alice" greeting = 'Hello' # Single or double quotes message = "Hello, #{name}!" # String interpolation puts name.length # 5 puts name.upcase # ALICE puts name.downcase ...

Network monitoring with Ruby

This is all about using Ruby to check on network stuff — but the golden rule here is: only do this on networks and systems you own or have permission to test. Same idea as it being fine to check if your own front door is locked, but not okay to go around checking your neighbors' doors. Checking if a "port" is open Think of your computer or router like an apartment building with a bunch of numbered doors (called ports ). Some doors are unlocked (open) because a service is listening there — like a web server sitting behind door 80. Others are locked (closed). require 'socket' def scan_port(host, port) begin socket = TCPSocket.new(host, port) # try knocking on the door socket.close # say bye, we're just checking puts "Port #{port} is open on #{host}" true rescue false # if it errors out, the door's closed/locked end end Then this checks a handful of common "doors" on a device (here,...

Ruby OS Interaction

Ruby isn't just for shuffling numbers and text around — it can also reach out and poke the actual operating system: run commands, create files, check what machine it's running on, all that. Here's what that looks like, broken down simply. Running commands like you would in a terminal There are a few different ways to tell Ruby "hey, run this shell command for me": output = `ls -la` # backticks: run it, hand me back whatever it printed puts output Think of backticks like texting a friend "what's in your fridge?" and they text back the whole list. success = system("mkdir test_dir") # just tells you true/false: did it work? This one doesn't care what the command printed — just whether it succeeded or not. files = %x{find . -name "*.rb"} # same idea as backticks, just different-looking syntax require 'open3' stdout, stderr, status = Open3.capture3("ls /nonexistent") Open3 is the "gro...

Ruby

Ruby is a programming language made in 1995 by a Japanese guy nicknamed "Matz."  His whole goal was to make a language that makes programmers happy, not just computers. So Ruby reads almost like plain English and doesn't make you jump through a ton of hoops. Let's break down what that actually means, piece by piece. Getting it on your computer Windows: download something called RubyInstaller Mac: it's already there, but you'll want to grab a newer version using Homebrew ( brew install ruby ) Linux: use your normal package manager ( apt install ruby etc.) If you're doing a lot of Ruby stuff, there are tools (rbenv, RVM) that let you switch between different Ruby versions like changing outfits. The basics: storing information In Ruby, you just make up a name and shove a value into it — no need to say "this is a number" or "this is text" first: name = "Alice" # text (called a "string") age = 25 ...

HTML Attributes

  HTML Attributes are special properties that provide additional information about HTML elements.  They are written inside the opening tag and consist of a name-value pair, typically formatted as attribute="value" .  Attributes modify element behavior, appearance, or provide metadata that browsers and other tools can use. Common Global Attributes: id : Provides a unique identifier for an element class : Assigns CSS classes for styling style : Applies inline CSS styles title : Adds tooltip text on hover lang : Specifies the language of element content data-* : Creates custom data attributes Element-Specific Attributes: Different HTML elements have specialized attributes: <a> uses href for links and target for opening behavior <img> uses src for image source and alt for accessibility text <input> uses type , name , placeholder , and required <form> uses action and method Key Attribute Types Shown: Structural : id , class ...

packet-switching X.25

  X.25 is a packet-switching protocol suite developed by the ITU-T in the 1970s for wide area networking over unreliable communication links.  It operates at the first three layers of the OSI model and was widely used for connecting remote terminals and computers over public data networks, particularly before reliable digital infrastructure became commonplace. Architecture and Operation: X.25 uses virtual circuits to establish connections between endpoints.  It employs three protocol layers: X.25 Packet Layer Protocol (Layer 3), LAPB (Link Access Procedure Balanced) at Layer 2, and typically operates over serial interfaces at Layer 1.  The protocol provides both Switched Virtual Circuits (SVCs) that are established on-demand and Permanent Virtual Circuits (PVCs) that are pre-configured. Key Features: Built-in error detection and correction at multiple layers Flow control to prevent buffer overflow Virtual circuit multiplexing over single physical links Store...

encapsulation with aal5snap

  AAL5SNAP (ATM Adaptation Layer 5 Subnetwork Access Protocol) is an encapsulation method used to carry network layer protocols like IP over ATM networks.  It combines two key components: AAL5 for ATM cell adaptation and SNAP for protocol identification. ATM Adaptation Layer 5 (AAL5): AAL5 is one of several ATM Adaptation Layers that segment higher-layer data into 48-byte payloads for ATM cells.  Unlike other AALs, AAL5 uses a "null" header approach - it doesn't add overhead to each cell but instead adds an 8-byte trailer to the entire packet.  This trailer contains length and CRC information for error detection and packet reassembly. AAL5 is highly efficient and became the standard for data communications over ATM. SNAP (Subnetwork Access Protocol): SNAP is an IEEE 802.2 extension that identifies the network layer protocol being carried. It consists of a 5-byte header containing an Organizational Unique Identifier (OUI) and a protocol type field.  For IP t...

Asynchronous Transfer Mode (ATM)

  Asynchronous Transfer Mode (ATM) is a cell-switching network technology that transmits data in fixed-size 53-byte cells (48 bytes payload + 5 bytes header).  Developed in the late 1980s, ATM was designed to handle voice, video, and data traffic with guaranteed Quality of Service (QoS) over both LAN and WAN connections. Key Features: ATM uses virtual circuits established through signaling protocols. It supports both Permanent Virtual Circuits (PVCs) and Switched Virtual Circuits (SVCs).  The fixed cell size eliminates variable delay, making it ideal for real-time applications.  ATM provides multiple service classes including Constant Bit Rate (CBR), Variable Bit Rate (VBR), Available Bit Rate (ABR), and Unspecified Bit Rate (UBR). Architecture: ATM networks consist of ATM switches connected by high-speed links.  Virtual Path Identifiers (VPIs) and Virtual Channel Identifiers (VCIs) route cells through the network. The small, fixed cell size reduces bufferi...

Frame Relay

Frame Relay is a packet-switching wide area network (WAN) protocol that operates at the data link layer (Layer 2) of the OSI model.  It was widely used in the 1990s and early 2000s to connect remote offices and branch locations over carrier networks, though it has largely been replaced by MPLS and internet-based VPNs today. Key Characteristics: Frame Relay uses virtual circuits called Data Link Connection Identifiers (DLCIs) to establish connections between endpoints.  It provides statistical multiplexing, allowing multiple virtual circuits to share the same physical link.  The protocol is connection-oriented but connectionless in nature - permanent virtual circuits (PVCs) are pre-configured, while switched virtual circuits (SVCs) are established on-demand. Benefits: Cost-effective for connecting multiple sites Efficient bandwidth utilization through statistical multiplexing Built-in congestion control mechanisms Lower latency compared to X.25 Basic Configuratio...

Linux Standard Error (stderr)

Standard error (stderr) is one of the three standard data streams in Linux, specifically designed for error messages and diagnostic output.  It uses file descriptor 2 and by default displays on the terminal screen, separate from standard output (stdout). Purpose of stderr Unlike stdout (file descriptor 1) which carries normal program output, stderr handles error messages, warnings, and diagnostic information. This separation allows users to redirect normal output while still seeing error messages, or vice versa. Basic stderr Examples Viewing stderr Output ls /nonexistent_directory # Error message appears on screen via stderr ls: cannot access '/nonexistent_directory': No such file or directory Command with Both stdout and stderr find /home -name "*.txt" # Files found go to stdout # Permission denied errors go to stderr Redirecting stderr Redirect stderr to File ( 2> ) find /root -name "*.txt" 2> errors.log # Normal output to screen, errors to...

Linux Standard Input (stdin)

Standard input (stdin) is one of the three standard data streams in Linux, representing the default source from which programs read input data.  It's assigned file descriptor 0 and typically connects to the keyboard by default. Understanding stdin When you run a command, it expects input from somewhere. By default, this "somewhere" is your keyboard - this is stdin. Programs read data from stdin character by character or line by line, waiting for user input. Basic stdin Examples Interactive Command Input cat # After pressing Enter, cat waits for keyboard input Hello World # Press Ctrl+D to end input The cat command without arguments reads from stdin and echoes to stdout. Reading User Input in Scripts read name echo "Hello, $name" # Program waits for user to type their name Redirecting stdin From Files ( < ) sort < unsorted_data.txt # sort reads from file instead of keyboard From Here Documents ( << ) mysql -u root -p << EOF USE dat...

Linux, Redirecting Input and Output

Linux provides powerful redirection operators to control where commands read input from and send output to, instead of using the default keyboard (stdin) and terminal (stdout). Output Redirection Basic Output Redirection ( > ) ls -l > file_list.txt This redirects the output of ls -l to a file called file_list.txt , creating or overwriting it. Append Output ( >> ) echo "New entry" >> file_list.txt This appends text to the existing file without overwriting previous content. Error Redirection ( 2> ) find /root -name "*.txt" 2> errors.log This redirects error messages (stderr) to errors.log while normal output still goes to the terminal. Redirect Both Output and Errors ( &> ) command &> all_output.txt # or alternatively command > output.txt 2>&1 Input Redirection Basic Input Redirection ( < ) sort < unsorted_list.txt This feeds the contents of unsorted_list.txt as input to the sort command. Here ...

Python's os Module

The os module in Python provides a portable way to interact with the operating system. It offers functions for file and directory operations, environment variables, process management, and system information. Directory Operations Current Working Directory import os # Get current working directory current_dir = os.getcwd() print(f"Current directory: {current_dir}") # Change working directory os.chdir('/tmp') print(f"New directory: {os.getcwd()}") # Go back to previous directory os.chdir(current_dir) Creating and Removing Directories # Create a single directory os.mkdir('new_folder') # Create nested directories os.makedirs('parent/child/grandchild', exist_ok=True) # Remove empty directory os.rmdir('new_folder') # Remove directory tree os.removedirs('parent/child/grandchild') # Removes if empty # Alternative for non-empty directories import shutil shutil.rmtree('parent') # Removes entire tree Directory Lis...

Basic Insert data in SQLite

 Python's SQLite module provides multiple methods to insert data into database tables safely and efficiently. After creating a table, inserting data is the next fundamental operation for building functional database applications. Basic Insert Operations The most straightforward approach uses the execute() method with INSERT SQL statements: import sqlite3 conn = sqlite3.connect('example.db') cursor = conn.cursor() # Insert single record cursor.execute(''' INSERT INTO users (name, email, age) VALUES ('John Doe', '[email protected]', 25) ''') conn.commit() conn.close() Parameterized Queries (Recommended) Always use parameterized queries to prevent SQL injection attacks and handle special characters properly: # Using question mark placeholders user_data = ('Jane Smith', '[email protected]', 30) cursor.execute('INSERT INTO users (name, email, age) VALUES (?, ?, ?)', user_data) # Using named placehol...

Table in SQLite using Python

  Creating SQLite Tables in Python: A No-Jargon Guide If you've ever wanted to store data in your Python program but felt intimidated by the word "database," here's some good news: Python makes this almost embarrassingly easy, thanks to a built-in tool called sqlite3 . No installing anything extra, no servers, no setup wizard. Let's walk through exactly how it works. What You're Actually Doing At a high level, creating a table involves just two steps: connect to a database file, then tell it what kind of table you want. Python's sqlite3 module handles the heavy lifting — you just describe what you want in plain SQL. Here's the whole thing in action: import sqlite3 # Connect to database (creates file if it doesn't exist) conn = sqlite3.connect('example.db') cursor = conn.cursor() # Create table with SQL command cursor.execute(''' CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY AUTOINCREMENT, ...

SQLite3 in Python

Python's built-in sqlite3 module provides a straightforward interface for working with SQLite databases. No additional installation is required since it's included in Python's standard library. Basic Connection Setup To establish a connection, import the module and use sqlite3.connect() with either a database file path or :memory: for an in-memory database: import sqlite3 # Connect to a file-based database conn = sqlite3.connect('example.db') # Or create an in-memory database conn = sqlite3.connect(':memory:') Creating a Cursor After connecting, create a cursor object to execute SQL commands: cursor = conn.cursor() Executing SQL Commands Use the cursor to run SQL statements. For data retrieval, use execute() followed by fetchone() , fetchall() , or fetchmany() : # Create a table cursor.execute('''CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)''') # Insert data cursor....

SQLite3 databases

Creating a database sounds like it should be complicated — servers, configuration, passwords, the works. With SQLite, it's none of that. A SQLite database is just... a file. That's it. This guide walks through exactly how to make one, in plain English. The Simplest Way: One Line in the Terminal Open your terminal and type: sqlite3 mydatabase.db That's the whole process. If mydatabase.db doesn't exist yet, SQLite creates it for you on the spot. You'll land inside something called the "SQLite shell" — basically a little command box where you can type SQL commands directly. One small thing worth knowing: the file doesn't technically get saved to your disk until you actually write something to it, like creating a table or adding data. So if you open the shell and immediately close it without doing anything, don't be surprised if the file isn't there yet. Creating a Database and a Table at the Same Time Want to skip a step? You can create the datab...

Tables in SQLite3

If you've ever looked at a CREATE TABLE statement and felt your eyes glaze over, this guide is for you. No assumed knowledge, no fancy database-speak — just a plain-English walkthrough of how to build a table in SQLite3. First, What Even Is a Table? Think of a table like a spreadsheet. It has rows (each row is one "thing," like one person or one order) and columns (each column is one piece of information about that thing, like a name or a price). Creating a table just means telling SQLite: "Here's what I want to store, and here's what each piece of information looks like." The Basic Recipe Every table you create follows the same basic pattern: CREATE TABLE table_name ( column1 datatype constraints, column2 datatype constraints, column3 datatype constraints ); Break that down: table_name — whatever you want to call your table (like users or products ) Each line inside the parentheses is one column datatype tells SQLite what kind of info...

SQLite 3

 Have you ever had a toy box? One where you keep all your favorite things, and you can pick it up and carry it anywhere — to your friend's house, into your room, wherever you want? That's exactly what SQLite is. Except instead of holding toys, it holds information — like names, scores, messages, or pictures. And it's one of the most popular toy boxes in the whole world, hiding inside all kinds of apps and gadgets. What Makes It So Special Most big databases are like giant toy stores. They need a manager, workers, a cash register, and a whole building to run. That's a lot of work just to keep some toys organized! SQLite skips all of that. It's just one single box — one file — that holds everything. You can copy it, move it, or send it to a friend, and all your stuff goes with it. No manager needed, no workers needed, no special room required. And even though it's small, it's not weak! SQLite can still do lots of clever tricks that the big toy stores can...