Ollama and Local AI in 2026: The Complete Beginner's Guide
Introduction
What if you could run an AI assistant like ChatGPT, Claude, DeepSeek, or Qwen entirely on your own computer without paying monthly subscriptions?
That is exactly what Ollama makes possible.
Ollama has become the easiest platform for running open-source AI models locally on Windows, Linux, and macOS. It allows users to download and run powerful language models directly on their own machines while maintaining privacy and avoiding recurring API costs.
This guide explains everything you need to know.
What is Ollama?
Ollama is a platform that simplifies running large language models locally. It supports models such as Qwen, DeepSeek, Gemma, Llama, Phi, Mistral, and many others.
Think of it as Docker for AI.
Instead of dealing with complicated model downloads, configurations, and dependencies, Ollama lets you install and run models with simple commands.
Why Developers Love Ollama
Privacy
Your prompts remain on your computer when running local models. Ollama states that local execution does not send your prompts to their servers.
No Subscription Fees
Once a model is downloaded, you can use it unlimited times without API charges.
Offline Usage
Many models work completely offline after installation.
More RAM generally allows larger models and faster responses. Community recommendations often focus on keeping model size within available VRAM for best performance.
Best Ollama Frontends
Open WebUI
Creates a ChatGPT-style interface.
Continue
Turns Ollama into a coding assistant inside VS Code.
Cline
Creates an AI coding agent.
OpenCode
Provides Claude Code-like workflows.
Security Considerations
Ollama is designed to run locally, but users should avoid exposing their Ollama instance directly to the internet. Security researchers have reported many publicly exposed Ollama servers caused by misconfiguration.
Ollama vs ChatGPT
Feature
Ollama
ChatGPT
Monthly Cost
Free
Subscription
Privacy
High
Cloud Based
Offline Usage
Yes
No
Setup Required
Yes
No
Latest Knowledge
Limited
Better
Custom Models
Yes
No
Pros and Cons
Pros
Free
Private
Offline capable
Supports many models
No API charges
Open ecosystem
Cons
Requires capable hardware
Setup complexity
Local models may be slower than frontier cloud models
No built-in web search by default
Final Thoughts
Ollama has become the foundation of the local AI movement. Whether you want a private ChatGPT alternative, a coding assistant, or a fully self-hosted AI workflow, Ollama provides one of the easiest ways to get started.
For developers, students, and businesses that value privacy and cost control, learning Ollama in 2026 is one of the highest-return skills in AI.
The Best Free AI Coding IDEs in 2026: Cursor, Claude Code & Antigravity Alternatives
Introduction
AI coding tools have changed software development faster than almost any technology trend in recent years. Tools such as Cursor, Claude Code, Codex, Windsurf, and Antigravity can now write code, understand entire repositories, fix bugs, generate documentation, and even build applications from simple prompts.
The problem is that many of these tools require monthly subscriptions. Cursor Pro, Claude Max, and other premium AI coding assistants can quickly become expensive for developers, students, and hobbyists.
Fortunately, several powerful free alternatives have emerged. Some are completely free, some offer generous free tiers, and others can even run locally on your own computer without recurring costs.
This guide covers the best free AI coding IDEs available in 2026, how to use them, their advantages, limitations, and who should choose each one.
Trae IDE is developed by ByteDance and has quickly become one of the most talked-about AI-powered development environments.
Unlike traditional code editors, Trae is designed from the ground up around AI-assisted development. It combines a familiar IDE experience with advanced AI agents capable of understanding and modifying entire projects.
Key Features
AI chat integrated directly into the IDE
Multi-file editing
Autonomous coding agent
Repository-wide understanding
Visual input support
Model Context Protocol (MCP) support
Integration with local models via Ollama
Pros
Generous free usage
Excellent interface
Fast code generation
Strong repository understanding
Supports multiple frontier models
Cons
Privacy concerns have been raised by some researchers
Instead of operating primarily inside an IDE, Qwen Code focuses on terminal-based development workflows. It can inspect files, edit code, execute commands, and solve complex software engineering tasks.
OpenCode focuses on creating an open-source alternative to Claude Code.
It provides a terminal-first coding agent experience while allowing users to connect various models.
Pros
Lightweight
Open source
Supports multiple models
Cons
Smaller ecosystem
Less polished than commercial tools
Comparison Table
Tool
Free
Open Source
Local Models
Best For
Trae IDE
Yes
No
Yes
General Development
Qwen Code
Partial
Yes
Yes
Terminal Coding
Continue
Yes
Yes
Yes
VS Code Users
Cline
Yes
Yes
Yes
Agent Workflows
OpenCode
Yes
Yes
Yes
Claude Code Alternative
Which One Should You Choose?
Choose Trae IDE if you want the closest experience to Cursor without paying.
Choose Qwen Code if you prefer terminal workflows similar to Claude Code.
Choose Continue if you want maximum flexibility.
Choose Cline if you want an autonomous coding agent.
Choose OpenCode if you want an open-source Claude Code replacement.
Final Verdict
For most developers in 2026, Trae IDE offers the best balance of usability, capability, and cost. However, developers concerned about privacy may prefer open-source alternatives such as Continue, Cline, or OpenCode.
The good news is that powerful AI-assisted coding is no longer limited to expensive subscriptions. Today, developers can access professional-grade coding agents completely free or at minimal cost.
Nepal Telecom's eSIM Ecosystem: Building the Future of ConnectivityDigital Telecom · eSIM
Nepal Telecom's eSIM Ecosystem: Building the Future of Connectivity, One Digital Layer at a Time
From the country's first online SIM conversion portal to a complete digital package covering every stage of the eSIM journey — how Nepal Telecom is building something few operators in the world have managed.
Nepal TelecomeSIM · Digital Governance2083 BS
There is a difference between building a digital platform and building a digital ecosystem. A platform solves a problem. An ecosystem solves a category of problems — and in doing so, creates something that outlasts any single service. Nepal Telecom appears to understand this distinction well, and nowhere is that clearer than in what it has been quietly assembling around eSIM over the past two years.
A global shift, arriving here
The global telecom industry is undergoing a structural change it cannot reverse. eSIM — the embedded SIM standard that replaces the physical card with a downloadable profile — is no longer a premium feature confined to flagship devices. Apple removed the physical SIM slot entirely from US iPhone models in 2022. Samsung, Google, and a growing list of manufacturers have followed. The GSMA projects that eSIM-capable devices will account for the majority of new connections in developed markets within this decade.
For a telecom operator, this shift demands more than a technical upgrade. It demands a rethinking of how customers are acquired, verified, and served — because eSIM, by its very nature, is a digital-first experience. A customer getting an eSIM does not walk into a shop, hand over documents, and leave with a card. They expect the entire process — application to activation — to happen on their device, in minutes.
Nepal Telecom recognized this early. And rather than launching one eSIM service, it set out to build the infrastructure that would make the entire eSIM customer journey possible, end-to-end, for every category of customer.
Where it started: the conversion portal
The foundation was laid on Magh 22, 2081 — Nepal Telecom's 21st anniversary — with the launch of the country's first online platform for converting existing physical SIMs to eSIM without a counter visit.
The platform is not a simple form. It performs balance request verification, validates user credentials against system records, handles balance deduction, triggers eSIM profile generation, and delivers it — all within a single unbroken digital flow. Globally, end-to-end digital SIM conversion of this kind remains rare. Most operators that support eSIM still require at least one in-person step. Nepal Telecom built a system that removes all of it.
In fifteen months since launch, over 15,000 customers have converted their physical SIMs through this platform — entirely through self-service, with no physical touchpoint required.
The gap that became the next platform
Every system, when it works at scale, reveals the problems that existed before it but went unnoticed. The conversion platform included a validation step: the customer's details had to match what was already on file. For many users — particularly those who had held their number for years without updating their registration — this check failed. The system correctly refused to proceed. But the customer then had nowhere to go except a physical service counter, precisely what the digital platform had been designed to make unnecessary.
The online KYC update portal, launched on Magh 22, 2082 — Nepal Telecom's 22nd anniversary — closed that gap. Customers can now submit updated identity documentation through a dedicated portal at kyc.ntc.net.np, get it verified, and then proceed seamlessly to convert their physical SIM. The counter visit is removed from the equation entirely.
The adoption numbers here are striking. Over 30,000 KYC records have been updated through this portal in just three months since launch — a monthly rate roughly ten times higher than the conversion portal's average, reflecting both the scale of pent-up demand and the fact that outdated KYC had been a silent barrier for a large number of customers who wanted to convert but could not. The portal has also proven especially valuable for Nepali citizens abroad, who previously had no way to update their documents remotely.
A new entry point: the prepaid eSIM distribution portal
With the conversion pipeline in place, Nepal Telecom has turned to customer acquisition — and the newest platform is a meaningful departure from everything that came before it. Launched on Baisakh 28, 2083, the new prepaid eSIM distribution portal at esim.ntc.net.np/new/ is not an extension of the existing system. It is a completely independent platform built from the ground up for first-time customers, with its own built-in KYC process integrated directly into the application flow.
This is an important distinction. The earlier platforms served existing Nepal Telecom customers. This one opens the door to people who have never held an NT SIM at all.
The platform integrates NamastePay and a dynamic QR payment module accepting any compatible digital wallet or mobile banking application, meaning a customer can complete the entire process — application, identity verification, payment, and eSIM delivery — without calling anyone or visiting anywhere. Number selection is built in, so customers can choose from available numbers rather than being assigned one.
More than 1,200 eSIMs were dispatched within just two weeks of the portal's launch — a figure that signals strong organic demand and a smooth onboarding experience from day one.
The use cases this platform enables are genuinely new for Nepal's telecom sector. A tourist arriving at Tribhuvan International Airport can get a working eSIM before leaving the terminal. A Nepali student abroad can obtain a local number ahead of returning home. A young person buying their first eSIM-only smartphone — increasingly common as manufacturers push toward eSIM-only hardware — has a direct digital path to connectivity without needing to locate a physical shop. For all of these users, the experience is entirely faceless and paperless.
Platform milestones at a glance
Magh 22, 2081 — 21st Anniversary
Physical SIM → eSIM conversion portal
Country's first online SIM conversion platform. 15,000+ conversions over 15 months. First of its kind in Nepal's telecom history.
Magh 22, 2082 — 22nd Anniversary
Online KYC update portal
Customers update identity documents remotely before conversion. 30,000+ records updated in just 3 months. Critical for Nepalis abroad.
Baisakh 28, 2083 — Recently launched
New prepaid eSIM distribution portal
First-time customers get a new prepaid eSIM fully online, with built-in KYC. 1,200+ dispatched in the first two weeks. Open to tourists, diaspora, and first-time users.
Later 2083 — Upcoming
Lost SIM recovery portal
Customers will be able to claim a replacement eSIM digitally, without visiting a service center. Will complete the full digital eSIM package.
The platform adoption numbers
Physical → eSIM conversions
15,000+
over 15 months · launched Magh 22, 2081
KYC records updated online
30,000+
in 3 months · launched Magh 22, 2082
New prepaid eSIMs dispatched
1,200+
in first 2 weeks · launched Baisakh 28, 2083
The complete package: two paths, one roof
What makes Nepal Telecom's approach coherent is not just the individual platforms but the architecture that ties them together. Rather than a single cycle, what has been built is a complete package covering two distinct journeys, both accessible under a unified entry point.
For a brand-new customer, the path is direct: apply at the new prepaid eSIM portal, complete identity verification in-platform, receive the eSIM. For an existing customer who wants to move from a physical SIM, the path is: update KYC if needed, then convert through the existing eSIM portal. Both categories of customer, once they have an active eSIM, will be served by a fourth platform — a lost SIM recovery portal currently in development, planned for later in 2083, which will allow digital replacement without a counter visit.
New customers
New prepaid eSIM portal
esim.ntc.net.np/new/
Built-in KYC · digital payment · number selection · for tourists, diaspora, first-time users
Existing customers
KYC update portal
kyc.ntc.net.np
Update identity documents remotely before proceeding to SIM conversion
Existing customers
Physical → eSIM conversion
esim.ntc.net.np/esim/
End-to-end conversion from physical SIM to eSIM profile, fully online
All eSIM customers · upcoming
Lost SIM recovery portal
launching later 2083
Digital replacement for lost eSIM — no counter visit required. Will complete the full ecosystem.
When that final platform goes live, Nepal Telecom will have built something very few operators anywhere in the world have achieved: a complete digital package in which a customer can get their first SIM, update their documents, convert an old SIM, and recover a lost one — all without walking into a service center.
Why this matters
The significance of this ecosystem extends well past operational convenience. It changes who can realistically be a telecom customer. Someone working overseas who discovers their KYC is outdated no longer faces an impossible situation. A tourist on a short visit no longer needs to plan around finding a SIM outlet. A young person in a city without a nearby service center is no longer excluded from getting connected. And people with eSIM-only devices — whose numbers will only grow — now have a native path to join Nepal Telecom without workarounds.
Nepal Telecom has also made a quiet but significant statement about timing. Each of the first two major launches — the conversion portal and the KYC portal — was timed to the operator's anniversary, signaling that digital services are being treated as institutional milestones, not minor updates. The pace of adoption across all three platforms suggests that demand for these services was there long before the platforms were.
The remaining piece — the lost SIM recovery portal — will complete what is already one of the most comprehensive digital SIM management ecosystems offered by any operator in this region. Once in place, the question of what it means to be a fully digital telecom operator in Nepal will have a very concrete answer to point to.
How to Get Your Nepal Telecom eSIM Online — A Complete Step-by-Step Guide
Nepal Telecom · eSIM Guide
How to Get Your Nepal Telecom eSIM Online: A Complete Step-by-Step Guide
Everything you need to go from registration to a working eSIM — without visiting a counter.
8 min read 11 steps covered eSIM-compatible device required
You'll need:
Valid email address Citizenship / Passport (digital copy, front & back) eSIM-compatible smartphone Fonepay or NamastePay (Rs. 90 fee)
Getting a new mobile number used to mean waiting in long lines at a telecom counter. Nepal Telecom has introduced a fully digital process that lets you apply for a new prepaid eSIM from home. This guide walks through every step, including what to expect at each stage of the application dashboard.
Where to start
Open the NT eSIM Portal
Option A
esim.ntc.net.np — then click Get New Prepaid eSIM on the homepage
NT eSIM portal homepage — click Get New Prepaid eSIM to begin
Phase 1
Registration & Email Verification
The NT eSIM portal — start by clicking the Register tab
1
Create your account
Go to the NT eSIM portal and click the Register tab. Enter your email address and choose a strong password, then click Create Account. The system will immediately send a 6-digit OTP to that email address.
The Register tab on the NT eSIM portal
Tip: If the OTP doesn't appear in your inbox, check your Spam or Junk folder. The code is valid for 10 minutes only.
2
Verify your email with the OTP
Enter the 6-digit code from your email into the verification screen. Once confirmed, you will be logged in and taken to your dashboard.
Enter the 6-digit OTP sent to your email
Phase 2
KYC & Number Selection
3
Start your eSIM application
From your dashboard, click the Apply for eSIM button to begin the application process.
Click "Apply for eSIM" from your dashboard
4
Choose your mobile number
Browse the available numbers or use the search box to find a specific pattern. Select the number you want and click Next to continue.
Browse and select your preferred mobile number
5
Fill out the KYC form and upload your ID
Complete the KYC form with your accurate personal and address details. You will also need to upload a clear, color photo of your identification document — front and back combined into a single file.
Fill in your personal details and upload your ID document
Important: Blurry or cut-off document images are the most common reason for application rejection. Ensure all text and photos on your ID are clearly visible before uploading.
6
Take a live selfie with your ID
You will be prompted to take a real-time photo of yourself while holding your ID document next to your face. This step is required for identity verification and cannot be substituted with a pre-taken photo.
Hold your ID next to your face and take a live photo
7
Review, agree to terms, and submit
Carefully review all the details you have submitted. Check the box to accept the Terms and Conditions, then click Submit Request to send your application.
Review your details, accept the Terms and Conditions, then submit
Phase 3
Admin Review
After submission, your application enters a manual review queue. A Nepal Telecom administrator will cross-check your submitted KYC details against your uploaded documents. Your dashboard timeline will show Request Review as the active stage.
Your dashboard timeline will show "Request Review" as the active stage
Possible statuses during review
Request Review— Application is in queue for admin verification
Withheld— Admin found an issue; action required from you
Approved— Review complete; payment step unlocks
If your status shows Withheld: You will receive an email notification. Log back into your dashboard to view the specific issue flagged by the admin, correct it, and resubmit — there is no need to restart the entire application.
Once your review is approved, the Payment step unlocks on your dashboard
Phase 4
Payment & Activation
8
Pay the application fee
Once your request is approved, the payment step unlocks on your dashboard. Click Proceed for Payment. The application fee is Rs. 90, payable through either of the following options:
Fonepay Dynamic QR
NamastePay Wallet
Your payment status will update automatically on the dashboard once the transaction is complete.
Choose between Fonepay Dynamic QR or NamastePay Wallet
9
Confirm your profile
After payment, click the Confirm My Profile button on your dashboard. This is a final acknowledgement that the KYC details you submitted are correct before the eSIM is generated.
Click "Confirm My Profile" to proceed to activation
10
Activate your eSIM
Click Activate My eSIM to provision your chosen number onto the Nepal Telecom network. This makes the number ready to use.
Click "Activate My eSIM" to provision your number on the network
11
Download your QR code
Once activation is complete, your unique eSIM QR code is generated. Click the button to download it as a secure PDF directly from your dashboard. A copy of the same PDF will also be sent to your registered email address. Keep this file safe — it is your eSIM credential.
Download your eSIM QR code PDF — a copy is also emailed to you
All 7 stages complete — your eSIM journey is finished
Final Step
Installing the eSIM on Your Phone
Scan the QR code you downloaded using your phone's cellular settings. The exact path varies by operating system:
iPhone / iOS
Go to Settings → Cellular → Add eSIM, then select Use QR Code and scan.
Android
Go to Settings → Connections → SIM Manager → Add eSIM, then select Scan QR code and scan.
Follow the on-screen prompts on your phone to label the new plan. Once complete, your Nepal Telecom eSIM is active and ready to connect.
That's it! Your dashboard will show Completed status. Your new Nepal Telecom prepaid number is now live on the network.
In simple terms: PAYG means you use mobile data and get charged directly from your main balance, without needing a data pack. No subscription—just pay for what you use.
In telecom terms: PAYG is a default billing mechanism where data usage is rated per KB/MB and deducted from the subscriber’s prepaid balance when no active data bundle is available.
PAYG in Nepal Telecom (NTC)
With a Nepal Telecom SIM, PAYG controls whether your mobile data can consume your main balance.
How to Enable / Disable PAYG
Dial *444#
Select 4 (Data Service Settings)
Choose:
1 → Disable PAYG
2 → Enable PAYG
3 → Check Status
What Do “Enable” and “Disable” Mean?
PAYG Enabled → Data works using your main balance → “PAYG data service is currently ENABLED…”
PAYG Disabled → Data will NOT use your main balance → “PAYG data service is currently DISABLED…”
Quick Tip
If you want to avoid unexpected balance deduction, keep PAYG disabled (which actually blocks usage from balance).
20 Linux Commands Every Database Administrator Should Know
📅 2025⏱ 18 min read🔧 MySQL · PostgreSQL · Oracle
Master these essential Linux commands to diagnose performance bottlenecks, monitor database processes, track disk usage, analyze logs, and keep your databases running at peak health — with real-world examples you can copy and paste directly.
As a Database Administrator, your terminal is your most powerful diagnostic tool. When a database slows down at 2 AM, you need to diagnose it fast — is it CPU? Memory? Disk I/O? A runaway query? A network bottleneck? The commands in this guide are the ones senior DBAs reach for first, every time.
Each command includes its most useful flags, real DBA output examples, and practical troubleshooting scenarios for MySQL, PostgreSQL, and Oracle environments.
01
top
Real-time view of system CPU, memory, and running processes
Performance
What it does:top displays a continuously updated snapshot of your system's resource usage — CPU load, memory consumption, swap usage, and a ranked list of the most resource-hungry processes. For a DBA, it's the first command to run when a server feels sluggish.
Basic usage
top# launch interactive viewtop-umysql# show only mysql user processestop-upostgres# show only postgres user processestop-b-n1# batch mode: single snapshot (good for cron scripts)top-d2# refresh every 2 seconds
Sample output — MySQL server under load
top - 14:32:11 up 42 days, 6:14, 2 users, load average: 4.21, 3.87, 3.54
Tasks: 312 total, 3 running, 309 sleeping
%Cpu(s): 62.4 us, 5.1 sy, 0.0 ni, 30.2 id, 2.1 wa, 0.0 hi
MiB Mem : 64432.0 total, 1248.3 free, 58731.2 used, 4452.5 buff/cache
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4821 mysql 20 0 58.4g 49.2g 8.1g R 94.3 78.2 182:14.33 mysqld
5103 mysql 20 0 58.4g 49.2g 8.1g S 12.1 78.2 18:02.11 mysqld
⚠️
DBA Red Flag: If %wa (I/O wait) is consistently above 10%, your database is waiting on disk — suspect missing indexes, full table scans, or underpowered storage. If us (user CPU) is above 80%, you likely have long-running or poorly optimized queries.
Interactive Key
Action
P
Sort by CPU usage (default)
M
Sort by memory usage
1
Toggle per-CPU core breakdown
k
Kill a process by PID
q
Quit
💡
DBA Trick: Run top -b -n 3 -u mysql > /tmp/top_snapshot.txt to capture 3 snapshots automatically — useful for attaching to incident tickets.
02
htop
Color-enhanced interactive process manager with tree view
Performance
What it does:htop is a more user-friendly alternative to top. It displays CPU bars for each core, scrollable process lists, and allows killing or renicing processes interactively with arrow keys.
Usage
htop# launch interactive viewhtop-umysql# filter to mysql userhtop-p4821,4822,4823# monitor specific PIDs onlyhtop--sort-key=PERCENT_MEM# start sorted by memory
🎯
DBA Use Case: Use htop -p $(pgrep -d',' mysqld) to monitor all mysqld threads simultaneously. Press F5 for tree view to see parent–child thread relationships — essential for understanding connection pools and background workers.
03
df
Report disk space usage across all mounted filesystems
Storage
What it does:df (disk free) shows how much disk space is available and used on each mounted filesystem. For DBAs, this is critical — a full /var or /data partition will crash your database or corrupt tables.
Common usage
df-h# human-readable sizes (GB, MB)df-hT# include filesystem type (ext4, xfs, nfs)df-h/var/lib/mysql# check specific MySQL data directorydf-h/var/lib/postgresql# check PostgreSQL data directorydf-i# check inode usage (important for many small files)
Critical Alert: The /var/lib/mysql partition at 97% above is a disaster waiting to happen. MySQL will refuse writes and InnoDB may crash. Set up disk usage alerts at 80% — never let a database partition reach 100%.
Pro Tip: Don't forget to check inodes with df -i! A filesystem can run out of inodes even when disk space is available. MySQL's InnoDB with innodb_file_per_table generates one .ibd file per table — thousands of tables = thousands of inodes.
04
du
Estimate disk usage of files and directories
Storage
What it does: While df shows filesystem-level usage, du (disk usage) drills into directories to show exactly what's consuming space. DBAs use it to find which databases, tables, or log files are eating disk.
DBA-specific du commands
# Show total size of MySQL data directorydu-sh /var/lib/mysql/
# Show size of each MySQL databasedu-h--max-depth=1 /var/lib/mysql/ | sort-rh# Find the top 10 largest tables (InnoDB .ibd files)du-h /var/lib/mysql/*/*.ibd | sort-rh | head-10# Check binary log sizes (common cause of disk bloat)du-sh /var/lib/mysql/mysql-bin.* 2>/dev/null | sort-rh# PostgreSQL: find largest databasesdu-h--max-depth=1 /var/lib/postgresql/*/main/base/ | sort-rh
Pro Tip: Binary logs often grow silently. Ensure expire_logs_days (MySQL 5.x) or binlog_expire_logs_seconds (MySQL 8.x) is set to avoid runaway disk usage.
05
iostat
Monitor disk I/O throughput, latency, and utilization
I/O
What it does:iostat (from the sysstat package) reports CPU statistics and I/O statistics for devices and partitions. It's the go-to tool when diagnosing storage bottlenecks — slow queries that access disk heavily will show up here.
Usage
iostat-xh2# extended stats, human-readable, every 2 secondsiostat-xhdsdb 1# watch specific device every 1 secondiostat-psdb# per-partition stats for device sdb
Key Metrics:%util near 100% means the disk is saturated. await above 20ms for HDDs or 5ms for SSDs is a concern. svctm is actual service time; if await >> svctm, the device queue is backing up.
06
vmstat
Virtual memory, swap, CPU, and I/O statistics at a glance
Performance
Usage
vmstat210# report every 2s, 10 timesvmstat-s# memory statistics summaryvmstat-d# disk statistics
Sample output
procs -------memory------ --swap-- ---io--- -system-- ----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa
4 8171924 23456 4096 1048576 1218 842 1204 4210 2890 62 6 22 10
⚠️
DBA Signals:b (blocked processes) > 0 signals I/O contention. si/so (swap in/out) > 0 means you're swapping — terrible for database performance. wa (I/O wait) > 10 indicates disk bottleneck.
07
ps
Snapshot of currently running processes and their state
Process
What it does:ps (process status) shows a point-in-time snapshot of running processes. Unlike top, it doesn't update continuously — making it ideal for scripting, piping to grep, or capturing process states for logs and tickets.
DBA-specific ps commands
# Show all MySQL processes with CPU, MEM, and start timepsaux | grepmysqld# Custom columns: PID, user, CPU, memory, elapsed time, commandps-eopid,user,%cpu,%mem,etime,cmd | grepmysqld# Count number of MySQL connections (threads)psaux | grepmysqld | wc-l# Find zombie/stuck processes (D = uninterruptible sleep = I/O wait)psaux | awk'$8 == "D" { print }'
Sample output
$ ps -eo pid,user,%cpu,%mem,etime,cmd | grep mysqld
PID USER %CPU %MEM ELAPSED CMD
4821 mysql 94.3 78.2 42-06:14:22 /usr/sbin/mysqld --basedir=/usr
4822 mysql 0.1 0.0 42-06:14:21 /usr/sbin/mysqld --basedir=/usr
💡
DBA Trick: Combine ps with watch for a pseudo-live view: watch -n 1 'ps aux | grep mysqld | grep -v grep'. Great for watching connections grow during a traffic spike.
08
netstat
Display network connections, listening ports, and routing tables
Network
What it does:netstat shows all active network connections, open ports, and socket states. For DBAs, it reveals who's connected to your database, how many connections are in use, and whether there's a connection leak.
DBA network investigation
# List all listening ports — confirm MySQL (3306) or PG (5432) is listeningnetstat-tlnp# Count connections by state (ESTABLISHED, TIME_WAIT, CLOSE_WAIT)netstat-an | grep:3306 | awk'{print $6}' | sort | uniq-c | sort-rn# Show which IPs are connecting to MySQL and how many connections eachnetstat-an | grep'ESTABLISHED' | grep:3306 | awk'{print $5}' \
| cut-d:-f1 | sort | uniq-c | sort-rn# PostgreSQL: connections to port 5432netstat-an | grep:5432 | awk'{print $6}' | sort | uniq-c
Connection Leak Signals: A high count of CLOSE_WAIT connections usually means your application is not properly closing DB connections — a connection leak. Many TIME_WAIT connections are normal after spikes but can pile up with poor connection pooling.
🎯
Note: On modern Linux systems, netstat is deprecated. Use ss (command #9) for better performance on servers with thousands of connections.
09
ss
Modern, faster socket statistics — the netstat replacement
Network
Usage
ss-tlnp# TCP listening ports with process namesss-tnpsport = :3306# all connections on MySQL portss-tnpstate established'dport = :5432'# established PG connectionsss-s# summary count of connections by state# Connection count to MySQL from each source IPss-tnstate established'dport = :3306' \
| awk'{print $5}' | cut-d:-f1 | sort | uniq-c | sort-rn
10
grep
Search and filter text using patterns — the DBA's log knife
Search
What it does:grep searches for pattern matches in text. For DBAs, it's the primary tool for searching error logs, slow query logs, and configuration files. Master grep and you'll cut incident resolution time in half.
Essential grep patterns for DBAs
# Find all errors in MySQL error loggrep-i"error" /var/log/mysql/error.log
# Find crashes, deadlocks, or corruptiongrep-iE"(crash|deadlock|corrupt|InnoDB: Error)" /var/log/mysql/error.log
# Show context: 3 lines before and after each matchgrep-i-B3-A3"deadlock" /var/log/mysql/error.log
# Find slow queries over 5 seconds in slow query loggrep-A2"Query_time: [5-9]\|Query_time: [0-9][0-9]" /var/log/mysql/slow.log
# Count occurrences of "Access denied" errorsgrep-c"Access denied" /var/log/mysql/error.log
# Search PostgreSQL logs for connection failuresgrep-i"FATAL\|connection refused\|too many connections" \
/var/log/postgresql/postgresql-*.log
# Inverse match — show lines NOT matching a patterngrep-v"Note\|Warning" /var/log/mysql/error.log | grep-i"error"# Live monitoring with color highlighttail-f /var/log/mysql/error.log | grep--color=always-i"error\|warn\|critical"
Flag
Description
-i
Case-insensitive search
-r / -R
Recursive directory search
-l
Print only filenames that match
-c
Count of matching lines
-v
Invert match (show non-matching lines)
-E
Extended regex (use | for OR)
-o
Print only the matched part of the line
-B N / -A N
N lines before / after each match
-n
Print line numbers
11
awk
Field-based text processing and log aggregation
Text
DBA log processing with awk
# Extract query times from slow query log and calculate averageawk'/Query_time/ { sum += $2; count++ } END { print "Avg:", sum/count "s" }' \
/var/log/mysql/slow.log
# Print the top query patterns (the actual SQL) from slow logawk'/^(SELECT|INSERT|UPDATE|DELETE)/ { print }' /var/log/mysql/slow.log \
| sort | uniq-c | sort-rn | head-20# Parse PostgreSQL CSV logs — extract duration and queryawk-F',''$13 > 5000 { print $13"ms:", $15 }' /var/log/postgresql/pg.csv
# Count error types by hour from MySQL logawk'/ERROR/ { match($0, /[0-9]{2}:[0-9]{2}/, t); errors[t[0]]++ }
END { for (h in errors) print h, errors[h] }' /var/log/mysql/error.log | sort
12
tail
Follow logs in real-time as your database writes them
Text
Live log monitoring
# Follow MySQL error log live (Ctrl+C to stop)tail-f /var/log/mysql/error.log
# Follow multiple logs simultaneouslytail-f /var/log/mysql/error.log /var/log/mysql/slow.log
# Show last 100 lines, then followtail-n100-f /var/log/mysql/error.log
# Follow with grep — live filtered viewtail-f /var/log/mysql/error.log | grep--line-buffered-i"error\|warn"# PostgreSQL: follow all logstail-f /var/log/postgresql/postgresql-$(date +%Y-%m-%d).log
💡
Pro Tip: Use multitail (if installed) to follow multiple log files in split-screen terminal panels — invaluable during incidents when you need to watch the MySQL error log and system journal at the same time.
13
find
Locate database files, logs, and configs by any attribute
Search
File hunting for DBAs
# Find all MySQL config files on the systemfind / -name"my.cnf"-o-name"my.ini" 2>/dev/null
# Find large .ibd files (tables over 1 GB)find /var/lib/mysql -name"*.ibd"-size+1G-execdu-sh {} \; | sort-rh# Find backup files older than 30 days to clean upfind /backups -name"*.sql.gz"-mtime+30-delete# Find files with wrong permissions in MySQL data dirfind /var/lib/mysql ! -usermysql-ls# Find core dump files that MySQL may have createdfind / -name"core.*"-usermysql-mtime-7 2>/dev/null
14
lsof
List open files — see what MySQL/Postgres has locked or opened
System Info
Usage
# List all files opened by MySQL processlsof-umysql# Count open file descriptors (compare against ulimit)lsof-umysql | wc-l# Check which process is using MySQL port 3306lsof-i:3306# Find deleted files still held open by MySQLlsof-umysql | grep"deleted"
⚠️
Deleted-but-open files: You delete a large binary log to free space, but df still shows the disk full — because MySQL still holds the file open. lsof | grep deleted reveals these ghost files. Restarting MySQL releases them.
15
strace
Trace system calls made by a database process
I/O
Usage — use with caution in production
# Attach to running MySQL process and trace I/O callsstrace-p $(pidof mysqld | awk '{print $1}') -etrace=read,write# Trace with timestamps and output to filestrace-p4821-tt-etrace=open,read,write,close-o /tmp/strace_mysql.txt
# Count system call frequency (profile mode)strace-p4821-c-f
🚨
Warning:strace can add significant overhead — use only on non-production systems or during controlled maintenance windows. For production diagnosis, prefer perf or MySQL's Performance Schema instead.
16
sar
System Activity Reporter — historical performance data
Performance
What it does:sar collects and saves system activity data. Unlike top (which only shows the current moment), sar lets you go back in time and see what happened at 3 AM when the DBA was asleep. Part of the sysstat package.
Historical investigation
# CPU usage for today, every 10 minutessar-u10# CPU usage for a specific past date (day 20 of current month)sar-u-f /var/log/sysstat/sa20
# Memory usage historysar-r-f /var/log/sysstat/sa20
# Disk I/O historysar-b-f /var/log/sysstat/sa20
💡
DBA Use Case: A user complains "the database was slow at 3 AM." Use sar -u -r -b -f /var/log/sysstat/sa$(date +%d -d yesterday) to pull CPU, memory, and I/O stats for yesterday and pinpoint the exact degradation window.
17
free
Quick snapshot of total, used, and available memory
Performance
Usage
free-h# human-readablefree-h-s2# update every 2 secondsfree-m# in megabytes
Sample output
total used free shared buff/cache available
Mem: 62Gi 57Gi 1.2Gi 256Mi 4.1Gi 4.8Gi
Swap: 8.0Gi 171Mi 7.8Gi
🎯
Key Insight: Don't panic if "free" memory is low — Linux uses spare RAM as disk cache (buff/cache), which benefits databases. The "available" column is what matters. If "available" is near 0 and swap is being used, you have a real memory problem.
18
ulimit
View and set resource limits for database processes
Limits
Usage
ulimit-a# show all current limitsulimit-n# show max open files (critical for MySQL)ulimit-n65536# set open files limit (current shell)# Check limits of a running MySQL processcat /proc/$(pidof mysqld | awk '{print $1}')/limits | grep-i"open files"# Set permanent limits (add to /etc/security/limits.conf)echo"mysql soft nofile 65536" >> /etc/security/limits.conf
echo"mysql hard nofile 65536" >> /etc/security/limits.conf
⚠️
Critical for MySQL: MySQL uses one file descriptor per table when innodb_file_per_table=ON. If the open file limit is too low (default is often 1024), MySQL will log "Too many open files" errors. Set nofile to at least 65536 for production MySQL servers.
19
journalctl
Query the systemd journal — database service logs and OOM kills
System Info
Usage
# Follow MySQL service logs livejournalctl-umysql-f# Show MySQL logs since last bootjournalctl-umysql-b# Show logs for a specific time windowjournalctl-umysql--since"2025-03-20 02:00:00"--until"2025-03-20 04:00:00"# MOST IMPORTANT: Find Out-of-Memory kills (OOM killer)journalctl-k | grep-i"oom\|killed process"# Check why MySQL service stopped/restartedjournalctl-umysql--no-pager | grep-i"start\|stop\|fail\|error"
🚨
OOM Killer: The Linux OOM killer terminates processes to free memory — and mysqld is often a prime target due to its large memory footprint. If your MySQL keeps mysteriously dying, journalctl -k | grep -i oom will confirm it. Fix: tune innodb_buffer_pool_size down, or add more RAM.
20
sysctl
Read and tune kernel parameters for database optimization
Tuning
What it does:sysctl reads and modifies kernel parameters at runtime. For DBAs, it's used to tune OS-level settings that directly impact database performance — network buffers, memory behavior, I/O scheduling, and file descriptor limits.
Essential kernel tunables for DBAs
# KEY DBA TUNING: Reduce swappiness (0-10 for database servers)sysctl-wvm.swappiness=10# Increase max open files system-widesysctl-wfs.file-max=2097152# Tune network buffers (good for high-throughput replication)sysctl-wnet.core.rmem_max=134217728sysctl-wnet.core.wmem_max=134217728# View all DB-relevant parameters at oncesysctl-a 2>/dev/null | grep-E"swappiness|hugepages|file-max|overcommit|somaxconn"
Make changes permanent — /etc/sysctl.conf
# Add to /etc/sysctl.conf for persistence across rebootscat >> /etc/sysctl.conf << 'EOF'# MySQL/PostgreSQL performance tuning
vm.swappiness = 10
vm.dirty_ratio = 15
vm.dirty_background_ratio = 5
fs.file-max = 2097152
net.core.somaxconn = 65535
EOF# Apply without rebootsysctl-p
💡
vm.swappiness: On database servers, set this to 1–10 (not 0). A low non-zero value tells the kernel to strongly prefer physical RAM but still use swap as an absolute last resort — avoiding an OOM kill if memory is exhausted.
Quick Reference
DBA Command Cheat Sheet
Copy-paste ready commands for the most common DBA scenarios