TECH / ARCHIVE

Servers & Websites

TECH / Servers & Websites 1 min

How to Replace Spaces with Commas in the Linux Console (sed, tr, awk)

Processing logs and other text data is handy with scripts right in the Linux console. With sed, awk and regular expressions you can almost work miracles :-) A common task is to replace spaces with commas, for example to turn a line into CSV.

How to Replace Spaces with Commas in the Linux Console (sed, tr, awk)

In short: sed 's/ /,/g' file replaces all spaces with commas. Without g only the first space on each line is replaced.
Read full article →

TECH / Servers & Websites 4 min

How to Add a Dedicated Disk for Swap in Ubuntu (Hyper-V & KVM)

When a Linux VM or server starts running tight on RAM, adding swap space keeps services from crashing under load spikes. If your root disk is already nearly full, the cleanest solution is attaching a separate virtual or physical drive dedicated to swap. Here are both ways to set it up on Ubuntu in Hyper-V (the exact same Linux commands work on KVM, Proxmox, and VMware).

Adding a dedicated second disk for Swap in Ubuntu and Hyper-V

Quick answer: attach a second disk to the VM, find its device name with lsblk (usually /dev/sdb), initialize it with sudo mkswap /dev/sdb, enable it with sudo swapon /dev/sdb, and add its UUID to /etc/fstab so it mounts automatically after reboot.

Read full article →

TECH / Servers & Websites 2 min

turbostat on Linux: CPU Frequency, Temperature and Power Draw

To find out what’s really happening with your CPU — what frequency the cores run at, how much power it draws and how deeply it “sleeps” — Linux has a tool called turbostat.

turbostat on Linux: CPU Frequency, Temperature and Power Draw

In short: on Debian, turbostat is part of the linux-cpupower package. Install it and run turbostat as root — it reads data straight from the CPU’s model-specific registers (MSR).
Read full article →