How to Add an Empty Line to a Text File from a Linux Shell Script
For nicer formatting, you may want to print an empty line from a script into a text file.
You can make an empty line in Linux with this command:
Infrastructure. Technology. Financial Markets.
For nicer formatting, you may want to print an empty line from a script into a text file.
You can make an empty line in Linux with this command:
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.
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 →
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).
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.
While building a package from source on Ubuntu Linux, I hit an error at the ./configure step:
configure: error: libevent not found.
In short: the libevent header files are missing. Install the development package — libevent-dev on Ubuntu and Debian — and run ./configure again.
Read full article →
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.
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 →