Quick Linux Tip #90 - DNS Lookup Time: Measure Network Latency with curl

Quick Linux Tip #90 - DNS Lookup Time: Measure Network Latency with curl

Question: How do I measure DNS lookup, connect, and download time separately?

Try:

`curl -w '@-' -o /dev/null -s https://google.com <<'EOF'`

` time_namelookup: %{time_namelookup}s`

` time_connect: %{time_connect}s`

` time_appconnect: %{time_appconnect}s`

` time_pretransfer: %{time_pretransfer}s`

` time_starttransfer: %{time_starttransfer}s`

` time_total: %{time_total}s`

`EOF`

Info: `curl -w` customizes output formatting using predefined variables. Breaking down latency identifies bottlenecks across DNS resolution, TCP handshakes, TLS negotiation, and server response times.

Examples:

$ `curl -w 'HTTP: %{http_code}, Time: %{time_total}s\n' -o /dev/null -s https://example.com` # Check status code and total duration

$ `curl -w '%{time_total}\n' -o /dev/null -s -X POST -d 'data' https://api.example.com` # Benchmark API response speed

$ `curl --resolve example.com:443:1.2.3.4 https://example.com` # Test direct IP routing, bypassing DNS

Note: High `appconnect` indicates TLS handshake delays, high `starttransfer` indicates server processing lag (TTFB), and high `connect` signals network routing latency.

Want to master Linux one command at a time?

Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 10 days ago

How to Choose VPS Hosting: What Should You Check Before Buying?

A lot of VPS comparisons start and end with CPU, RAM and storage.

Before choosing a VPS, it's worth checking: https://www.linuxteck.com/how-to-choose-vps-hosting/

  • CPU resources and whether they're dedicated or shared
  • RAM and available headroom
  • NVMe/storage performance and IOPS
  • Sustained network throughput
  • Packets-per-second (PPS) limits
  • Whether "unmetered" traffic can be throttled
  • Data-center location and latency
  • Backup and snapshot options
  • Scalability
  • Managed vs unmanaged support
  • Real-world performance under load
u/Expensive-Rice-2052 — 10 days ago

Kernel Modules: Check RAM Usage with lsmod - 89

Question: The kernel is using tons of RAM. Which modules are the biggest?

Try: `sudo lsmod | sort -k2 -rn | head -10`

Info: `lsmod` lists currently loaded kernel modules alongside their size in bytes. Sorting numerically by size quickly highlights memory-intensive display drivers, filesystems, and device modules.

Examples:

$ `sudo modinfo nvidia` # Display detailed kernel module info and parameters

$ `sudo modprobe -r nvidia` # Safely unload an unused kernel module

$ `cat /proc/meminfo | grep -i slab` # Check kernel slab memory utilization

Note: Kernel-level memory allocations appear under `Slab` in `/proc/meminfo`. Active modules (`Used by > 0`) cannot be unloaded until dependent processes or devices release them.

Want to master Linux one command at a time?

Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 11 days ago

Count Error Occurrences in Linux: Quick Log Monitoring Tip - 85

Question: How do I count new occurrences of an error over time?

Try: `watch -n 5 'grep -c "ERROR" /var/log/nginx/error.log'`

Info: `watch` reruns commands at defined intervals (`-n` seconds) to track changing metrics. Coupling `tail -f` with `awk` increments and displays a live rolling tally as new log entries land.

Examples:

$ `watch -n 1 -d 'grep -c ERROR /var/log/app.log'` # Highlight changing match values automatically

$ `tail -f app.log | grep --line-buffered ERROR | wc -l` # Count streaming lines without buffering lag

$ `journalctl -f -u nginx | grep --line-buffered -c "ERROR"` # Stream systemd journal logs live

Note: Add `--line-buffered` to `grep` when piping live streams to prevent stdio buffer delay. Use `watch -d` to visually highlight value differences between interval updates.

Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 15 days ago

Quick Linux Tip #77 - Git Diff Between Main and Feature Branch

Question: How do I see all differences between production and my feature branch?

Try: `git log --oneline --left-right --graph main...feature/new-api`

Info: Using `...` (triple-dot) finds commits unique to each branch. `--left-right` marks commits with `<` (left/main branch) or `>` (right/feature branch) to display divergence.

Examples:

$ `git log main..feature --oneline` # Commits on feature branch missing from main

$ `git diff main...feature -- '*.js'` # File diffs introduced on feature branch

$ `git range-diff main..feature@{yesterday} main..feature` # Track branch changes over time

Note: Two dots (`..`) lists commits reachable from B but not A. Three dots (`...`) displays symmetric difference across branches. Essential for PR reviews!

Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 24 days ago

Quick Linux Tip #73 How to Trace Disk I/O Activity in Linux with btrace

Try: `sudo btrace /dev/sda`

Info: `btrace` traces block layer I/O events in real time. It shows every read/write action with exact timing, process IDs, and I/O stages (`Q`=queued, `D`=dispatched, `C`=completed).

Examples:

$ `sudo blktrace -d /dev/sda -o - | blkparse -i -` # Live block trace pipe

$ `sudo iotop -o -d 1` # Interactive process-level I/O monitor

$ `sudo iostat -xz 1` # Live extended device utilization stats

Note: Install via `sudo apt install blktrace`. Very verbose output—filter with `grep` or use `iotop` for higher-level process tracking.

Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 29 days ago

Quick Linux Tip #72 - How do I find files changed within a specific time window for an incident report?

Try: `find /var/www -type f -newermt '2026-09-10 14:00:00' ! -newermt '2026-09-10 16:00:00' -printf '%TY-%Tm-%Td %TH:%TM %p\n'`

Info: `-newermt` filters files newer than a start timestamp. Prefixing with `! -newermt` establishes the upper boundary, while `-printf` formats custom date-time output.

Examples:

$ `find /home -type f -newermt yesterday` # Files modified since yesterday

$ `find / -type f -newermt '1 hour ago' 2>/dev/null` # Files modified in the last hour

$ `find /etc -type f -newermt '2026-09-01' ! -newermt '2026-09-30'` # Filter by date range

Note: Accepts natural language like `'yesterday'` or `'2 hours ago'`. Use `-newermt` for modification time, `-newerct` for attribute change time, and `-neweramt` for access time.

Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #70 Run Daily Tasks with Linux systemd Timers

Question: How do I run a task daily but with more control than cron?

Try: `sudo systemctl edit --force --full backup.timer`

Info: `systemd` timers replace `cron` with native logging via `journalctl`, dependency control, `Persistent=true` for missed runs, and `RandomizedDelaySec` to spread load.

Examples:

$ `systemctl list-timers --all` # List all active system timers

$ `journalctl -u backup.service` # Check execution history and logs

$ `systemd-analyze calendar 'weekly'` # Parse and test calendar expressions

Note: Requires a paired `.service` unit file. Use `OnBootSec` for boot-relative timers and `OnCalendar` for wall-clock scheduling.

Follow r/LinuxTeck for more #LinuxTips https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #67 How to Test SSD Speed in Linux with hdparm and dd

Try: `sudo hdparm -Tt /dev/sda`

Info: `hdparm -T` measures cached RAM reads; `-t` benchmarks direct disk reads. `dd` tests sequential write performance using `conv=fdatasync` to flush cache.

Examples:

$ `sudo hdparm -I /dev/sda | head -20` # Display drive specs and identity

$ `fio --name=randwrite --ioengine=libaio --rw=randwrite --bs=4k --size=1G` # Measure random write speed

$ `iozone -a -g 1G` # Run comprehensive file system benchmark

Note: `hdparm` tests sequential read speeds. For workload-heavy random I/O (like databases), use `fio`. NVMe drives should reach 2–7 GB/s.

Follow r/LinuxTeck for more #LinuxTips here https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 1 month ago

Best VPS for AI Tools in 2026 - What should you actually look for?

covering: https://www.linuxteck.com/best-vps-for-ai-tools/

  • RAM requirements for different model sizes
  • CPU and AVX support
  • NVMe storage
  • Dedicated vs. shared vCPU
  • When a GPU is actually necessary
  • VPS provider comparison
  • Docker + Ollama setup
  • Commands to validate CPU, RAM and AVX before committing to a server
  • Common OOM and resource problems
u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #66 How to Redirect stdout and stderr to Separate Files in Linux

Question: How do I save errors and normal output to different files?

Try: `./deploy.sh > success.log 2> errors.log`

Info: `>` redirects `stdout` (fd 1), while `2>` redirects `stderr` (fd 2). Separating streams keeps error logs clean and easy to isolate.

Examples:

$ `./script > out.log 2> err.log` # Separate standard output and errors

$ `./script &> combined.log` # Redirect both streams to one file (Bash/Zsh)

$ `./script > out.log 2>&1` # POSIX redirection of stderr to stdout file

Note: Redirection order matters: `> file 2>&1` works, but `2>&1 > file` sends `stderr` to terminal. Redirect to `/dev/null` to discard output completely.

Follow r/LinuxTeck for more #LinuxTips https://www.linuxteck.com/linux-tips/redirect-stdout-stderr-separate-files-linux/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #65 How to View Child Processes in Linux with pstree

Try: `pstree -pau 3456`

Info: `pstree` displays process hierarchies. `-p` includes PIDs, `-a` shows full command arguments, and `-u` lists usernames. Curly braces `{}` indicate threads.

Examples:

$ `pstree -pau $$` # View process tree starting from current shell

$ `pstree -T` # Hide threads to show only main processes

$ `pstree -sp 3456` # Show parent ancestors leading up to PID 3456

Note: Essential for identifying orphaned processes and child process trees. Threads inside `{}` share parent memory space.

Follow r/LinuxTeck for more #LinuxTips https://www.linuxteck.com/linux-tips/linux-pstree-view-child-processes/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #64: Write an ISO to USB on Linux

Try: `sudo dd if=ubuntu-24.04.iso of=/dev/sdb bs=4M status=progress conv=fsync`

Info: `dd` writes raw blocks. `bs=4M` accelerates speed, `status=progress` displays live transfer rates, and `conv=fsync` flushes data to physical storage before completion.

Examples:

$ `sudo dd if=/dev/zero of=/dev/sdb bs=4M` # Wipe USB drive table

$ `sudo dd if=/dev/sda of=disk.img bs=64K` # Create full disk image backup

$ `sudo pv ubuntu.iso | sudo dd of=/dev/sdb bs=4M` # Monitor write progress via pv

Note: Always verify target drives using `lsblk` first to prevent catastrophic data loss. Safely eject using `sync; sudo eject /dev/sdb` after writing.

Follow r/LinuxTeck for more #LinuxTips : https://www.linuxteck.com/linux-tips/linux-write-iso-to-usb-dd/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #63 Question: Is someone trying to break into my server?

Try: `sudo grep 'Failed password' /var/log/auth.log | awk '{print $11}' | uniq -c | sort -rn | head -5`

Info: Searches `/var/log/auth.log` for SSH authentication failures, isolates source IP addresses via `awk`, and tallies frequencies to highlight top offending addresses.

Examples:

$ `sudo journalctl -u ssh | grep -i failed | wc -l` # Count total SSH failures via journalctl

$ `sudo lastb | head` # View bad login attempts from btmp log

$ `sudo fail2ban-client status sshd` # List currently jailed IP addresses

Note: Install `fail2ban` to automatically drop brute-force attempts. On `systemd` systems without syslog, inspect auth logs via `journalctl -u ssh`.

Follow r/LinuxTeck for more #LinuxTips : https://www.linuxteck.com/linux-tips/linux-check-failed-ssh-logins/

u/Expensive-Rice-2052 — 1 month ago

Quick Linux Tip #61 Question: Find Files Not Accessed in Over a Year

Try: `sudo find /home -type f -atime +365 -printf '%T@ %p\n' | sort -n | head -20`

Info: `-atime +365` filters files not accessed in over a year. `-printf '%T@ %p\n'` formats output with epoch timestamps for numeric sorting with `sort -n`.

Examples:

$ `find /var/log -atime +90 -type f` # Locate inactive log files

$ `find /home -atime +365 -type f -exec ls -la {} \;` # Inspect file metadata

$ `find /tmp -atime +7 -type f -delete` # Auto-purge temporary files older than 7 days

Note: Modern Linux filesystems default to `relatime`, updating access time only if older than modification time. Combine `-atime` with `-size +100M` to identify large candidate files for archiving.

Follow r/LinuxTeck for more #LinuxTips https://www.linuxteck.com/linux-tips/linux-find-files-not-accessed-year/

u/Expensive-Rice-2052 — 1 month ago