C-NET :: PROJECTS

ls -t projects/ | grep -i "Linux"

Linux

2022

Copying data from a restored postgres database to the live database

How to copy selected rows from a restored PostgreSQL database into the live database with COPY and psql.

Linux · Reference · Software

2021

DNS names for VirtualBox client machines

A PowerShell script that adds the IP addresses of running VirtualBox guests to the Windows hosts file, and autostarts chosen VMs headless.

Howto's · Linux · Windows · Reference · Solved Problems
DNS names for Hyper-V client machines

A PowerShell script that keeps the Windows hosts file updated with the IP addresses of running Hyper-V virtual machines.

Howto's · Linux · Windows · Solved Problems
Web Echo Service for developers

A pointer to the C-Net Echo Service, which returns the exact HTTP request it receives, for web client and proxy development.

Linux · Reference · Solved Problems

2020

curl SSL fails even with ca-certificates installed

How to fix curl error 60 in a Docker container that has ca-certificates installed, by forcing a certificate rehash.

Linux · Reference · Solved Problems
Perl one-liner to create random passwords

A Perl one-liner that prints a random alphanumeric password of a chosen length.

Linux · Reference

2019

Docker starts slowly on Raspberry Pi / Raspbian

How to fix Docker taking minutes to start on a Raspberry Pi running Raspbian, caused by a lack of random entropy, by installing haveged.

Howto's · Linux · Solved Problems
Binary pastebin

Announcement of paste.c-net.org, a console friendly pastebin that also accepts binary files.

Linux · Solved Problems

2018

Recovering versioned files from Owncloud's data directory

How to find versioned files in ownCloud's data directory and copy them out with readable timestamped names.

Howto's · Linux · Solved Problems
Forcing Cygwin to create sane permissions on Windows

How to stop Cygwin from creating incorrectly ordered Windows permissions by adding noacl to the /cygdrive mount options.

Linux · Windows · Solved Problems
Script for creating a compressed image file from a Raspbian SD card

A script that shrinks a Raspbian SD card, zero-fills its free space and saves it as a compressed image file.

Howto's · Linux · Solved Problems
My tweaks to get Kali Linux running well on the GPD Pocket

Tweaks for Kali Linux on the GPD Pocket: no GRUB splash, WiFi and power settings with tlp, lid screen handling and xorg config.

Linux · Reference · Solved Problems
Checking for required packages on a Debian (or derivative) system

A Bash snippet that checks a list of required Debian packages with a single dpkg-query call and reports the missing ones.

Linux · Reference · Solved Problems

2017

Sleeping without a subprocess in Bash, and how to sleep forever

A Bash function that sleeps, or sleeps forever, with the read builtin on a process substitution instead of running the external sleep command.

Howto's · Linux · Solved Problems
Shrinking a Raspbian installation and re-enabling auto expanding for distribution of customized images

How to shrink a customized Raspbian SD card into a small image file that expands again on first boot.

Howto's · Linux · Solved Problems
Handling multiple overlapping VPN client networks with pfSense and a reflector VM

How to reach VPN client networks that overlap your own or each other with pfSense, outbound NAT and a Shorewall reflector VM.

Howto's · Linux · Solved Problems
Making a minimal VPN routing virtual machine to isolate obnoxious VPN clients

How to build a small Debian VM with OpenConnect and Shorewall that routes traffic to a client VPN, kept apart from pfSense.

Howto's · Linux · Solved Problems
BashDB, a single dynamic database table for bash scripts

BashDB, a Bash library that stores a single key and value table with dynamic columns and lists, to keep persistent state in shell scripts.

Howto's · Linux · Solved Problems
Using IPv6 SLAAC with IP forwarding on Debian Stretch ("connect: network is unreachable", no default gateway)

How to make a Debian Stretch host with IP forwarding enabled accept IPv6 router advertisements and get a default route, by setting accept_ra to 2.

Linux · Solved Problems
Exim4 line length in Debian Stretch - "Mail delivery failed: returning message to sender"

How to make Exim4 in Debian Stretch accept emails with lines longer than 998 characters instead of returning them to the sender.

Linux · Solved Problems
Understanding mcelog ECC errors - Which stick of RAM is broken?

How to find the faulty RAM stick from an mcelog ECC error, by matching its memory address to a DIMM slot with dmidecode.

Linux · Solved Problems
Finding duplicate files with Bash

cdupes, a Bash script that finds duplicate files by size and checksum with find and a few pipes, much like fdupes.

Howto's · Linux · Solved Problems
Killing a process tree, killing a PID and all children

Two Bash functions that kill a process and all its children recursively, or all children of the current script.

Linux · Solved Problems
Making a telnet server with Bash and tcpserver

How to serve a Bash script over telnet with tcpserver, and a function library that handles telnet line endings, ctrl+c and password input.

Linux · Solved Problems
apt-get reports Packages not found

How to fix 404 errors from apt-get update on Debian by removing stale partial package lists, and what else to check if that does not help.

Linux · Solved Problems
Reset dpkg (apt) package configuration to default, restore deleted config files

How to restore a Debian package's deleted or changed config files with dpkg or apt-get and --force-confmiss.

Linux · Reference · Solved Problems

2016

Duplicate bind mounts with chroots on systemd

How to stop duplicate bind mounts in chroot jails on systemd by marking the fstab bind mounts private.

Linux · Solved Problems
W: [pulseaudio] authkey.c: Failed to open cookie file '/home/user/.config/pulse/cookie': No such file or directory

How to fix the PulseAudio warning about a missing ~/.config/pulse/cookie file by symlinking the old cookie file.

Linux · Solved Problems
Some fonts shown as squares in Kali Linux

How to fix fonts shown as squares in Kali Linux by rebuilding the font cache.

Linux · Reference · Solved Problems
My tweaks to Kali Linux (note to self)

A checklist of settings, packages and tweaks for Kali Linux 2016.1: autologin, smartmontools, power button, encrypted swap file and virt-manager.

Linux · Reference
SPF exists for a reason, and postfix makes it ridiculously easy

What SPF does and does not do for email, with a pointer to a guide for enabling SPF checks in Postfix on Debian and Ubuntu.

Howto's · Linux
pfSense as a Cisco AnyConnect VPN Client using OpenConnect

How to install OpenConnect on pfSense, keep a Cisco AnyConnect VPN connection up from cron and add its interface to the GUI.

Howto's · Linux · Solved Problems
Squid Compile with SSL support under Debian Jessie

How to rebuild the Debian Jessie squid3 package from source with SSL support enabled.

Linux · Reference

2015

Force removal of a package that's "is in a very bad inconsistent state"

How to force dpkg to remove a package that is in a very bad inconsistent state.

Linux · Reference · Solved Problems
Relay UDP broadcasts between subnets in pfSense

A script that relays UDP broadcasts between subnets in pfSense, with tcpdump and tcpreplay.

Linux · Solved Problems
Mounting and using KVM raw image files on the host system

How to map the partitions of a KVM raw disk image on the host with losetup and kpartx, and how to unmap them again.

Linux · Reference
Tool tip: "vbetool" runs real-mode video BIOS code to alter hardware state

The vbetool manual page: a tool that turns displays on and off and changes video BIOS state from the console.

Linux · Reference
Solution: Using ProxyPass from http to https in apache2 causes AH02032 SNI error

How to fix the AH02032 SNI hostname error when Apache proxies from HTTP to an internal HTTPS server, by turning off ProxyAddHeaders.

Linux · Solved Problems
The fastest way to extend disk image files on Linux

How to grow a virtual machine disk image file on Linux with the truncate tool instead of dd.

Linux · Reference · Solved Problems
How to use a gateway outside of the local subnet on Linux

How to route all traffic on Debian through a gateway with a private IP outside the local public subnet.

Howto's · Linux · Solved Problems
dovecot: master: Error: systemd listens on port 143, but it’s not configured in Dovecot. Closing.

How to stop Dovecot's systemd socket errors after an upgrade from Debian Wheezy to Jessie by disabling dovecot.socket.

Linux · Solved Problems
Taking a screenshot of an entire page with Firefox, saved as a .png

How to save a full-page screenshot as a PNG with the Firefox developer toolbar.

Linux · Windows · Solved Problems
What to do when kill -9 doesn't do anything

A pointer to an explanation of why kill -9 sometimes has no effect on a process.

Linux · Reference
Restarting a VPN client on pfSense through the CLI (SSH)

How to restart an OpenVPN client on pfSense from another machine over SSH with a small script, for a flaky VPN connection.

Howto's · Linux · Solved Problems
Writing a newline to separate commands in XChat

How to type a line break in XChat to put several commands on one line.

Linux · Reference

2014

Typing the escape character ^] on a non-english keyboard

How to type the telnet escape character ^] on a Norwegian or other non-English keyboard: press Ctrl + 5.

Linux · Reference · Solved Problems
Make exim4 on Debian respect .forward and /etc/aliases when using a smarthost

How to make exim4 on Debian apply /etc/aliases and ~/.forward to outgoing mail when it sends through a smarthost.

Howto's · Linux · Solved Problems
Reverse SSHFS mounts (fs push)

How to mount a file system on a remote machine with sshfs, started from the machine that holds the files, using dpipe and sshfs slave mode.

Howto's · Linux · Solved Problems
Shrinking a vmdk with VMware Player

How to shrink a VMware virtual disk from the command line with VMwareToolboxCmd.

Linux · Reference · Solved Problems

2013

Disable screensaver in default desktop Raspbian installation

How to disable the screensaver and screen blanking in the default LXDE desktop on Raspbian.

Linux · Reference
Running PulseAudio in system mode with TCP listening on Debian Wheezy

How to run PulseAudio in system mode on Debian Wheezy with a TCP listener for remote sound over an SSH tunnel.

Howto's · Linux
Mysterious IGMP Query Request packets from 0.0.0.0 to 224.0.0.1

Why a Linux bridge sends IGMP queries from 0.0.0.0 to 224.0.0.1 every two minutes, and how to turn off multicast_snooping to stop them.

Linux · Solved Problems
How to prevent ssh -X from hanging on exit when dbus is used

How to stop ssh -X from hanging on exit when the remote program starts dbus, by launching dbus yourself and killing it afterwards.

Linux · Reference · Solved Problems
One-time passwords in Debian Wheezy with libpam-otpw

How to set up one-time password SSH logins on Debian Wheezy with libpam-otpw.

Howto's · Linux

2012

Using CheckInstall to track custom source downloads on Debian

How to use CheckInstall to make Debian packages from source installs, so they can be removed with dpkg.

Howto's · Linux
ShellShock - a Bash 3 / Bash 4 spaceshooter!

ShellShock, a top-down space shooter written in Bash, and the attention it got when the Bash exploit took the same name.

Linux
Parse long options in bash scripts

A Bash script by geirha that parses both short and long command line options in shell scripts.

Linux · Reference
Pausing and continuing a process on Linux

How to pause and resume a running process on Linux with the STOP and CONT signals.

Howto's · Linux
Linux on Mac Mini - power on after power loss

How to make a Mac Mini running Linux power on again after a power loss, with the command for each Mac Mini model.

Linux · Solved Problems
gitolite: 'foo' does not appear to be a git repository - ForceCommand

Why gitolite says a repository does not exist when sshd's ForceCommand or a second ssh key overrides its command= setting in authorized_keys.

Linux · Solved Problems
Creating .deb-Packages With Checkinstall

Why to use checkinstall to wrap a from-source install in a .deb package on Debian, with a pointer to a howto.

Linux · Reference

2011

UDP through SSH

A link to a guide on tunneling UDP traffic through an SSH connection, with an archived copy.

Linux · Reference
Fixing "shmget() failed: No space left on device"

How to clean up shared memory segments left behind by killed x11vnc processes, with a root cron script that reports who left them.

Linux · Solved Problems
SSH in a while loop - stdin problems

Why ssh inside a while read loop only runs once, because ssh consumes stdin, and how the -n option fixes it.

Linux · Reference · Solved Problems
Set php.ini values using .htaccess

How to set php.ini values with php_value lines in an Apache .htaccess file.

Linux · Reference
GCC stray X in program

How to fix GCC's "stray in program" error caused by invalid characters in source code, from building the Intel EMGD driver.

Linux · Reference · Solved Problems
xorg.conf for KVM

An xorg.conf that works for a Linux guest in KVM, with the VESA driver and vmmouse.

Linux · Reference
bash time limit on commands

How to put a time limit on a command using only the shell, with a script based on the pixelbeat.org timeout script.

Howto's · Linux · Solved Problems
Debian APT Pinning properly explained

A pointer to a Debian cheat sheet that explains APT pinning, with an archived PDF copy.

Linux · Reference
Using LD_PRELOAD to override a function

How to override a library function such as getpid with LD_PRELOAD and dlsym(RTLD_NEXT), with a complete example.

Linux · Reference
Debian and Ubuntu auto-login and Xorg without a display manager

How to log in automatically on a spare TTY with rungetty and start Xorg from .bash_login on Debian and Ubuntu, without a display manager.

Howto's · Linux
Save and restore partition tables with sfdisk

How to copy a partition table from one drive to a replacement drive with sfdisk, for example when rebuilding an mdadm RAID.

Linux · Reference

2010

sudo without a password

How to let a user run sudo without a password, for all commands or for specific ones, in /etc/sudoers.

Linux · Reference
Using Flags and Arguments in Bash

A small example bash script that parses command line flags and their arguments with getopts.

Linux · Reference
exim4 smarthost smtp password

How to give exim4 a username and password for an authenticated smarthost in /etc/exim4/passwd.client.

Linux · Reference
Use OpenDNS with Smoothwall Express 3.x

How to make Smoothwall Express 3.x use OpenDNS instead of the DNS servers from the ISP's DHCP, by editing rc.updatered.

Linux · Reference
What's touching that config file?!

How to find which Debian package's maintainer script changes a config file, by grepping the postinst scripts in /var/lib/dpkg/info.

Linux · Reference · Solved Problems
OTP (one-time passwords) on Debian Squeeze SSH logins

How to require OPIE one-time passwords for SSH logins on Debian Squeeze with libpam-opie and challenge-response authentication.

Howto's · Linux
Switching alsa sound cards around

How to change the order of ALSA sound cards and pick the default card with module index options.

Linux · Reference
Avoiding invalid commands in Bash history

How to keep mistyped, not-found commands (exit status 127) out of your Bash history with a PROMPT_COMMAND function.

Howto's · Linux

2009

Hide join/part messages in XChat

How to hide and show join and part messages in XChat with the irc_conf_mode setting.

Linux · Reference
XFCE: Unable to perform shutdown

How to fix the XFCE "Unable to perform shutdown" error by allowing the HAL shutdown, reboot and mount actions in PolicyKit.conf.

Linux · Reference
Resizing an ext3 filesystem on an lvm

The steps to shrink an ext3 filesystem and its LVM logical volume with resize2fs and lvreduce, and to give the space to another volume.

Linux · Reference
Moving or removing ~/.xsession-errors

How to move, disable or split ~/.xsession-errors per host by changing ERRFILE in /etc/X11/Xsession on Debian.

Linux · Reference
Wake on Lan on an Intel Mac Mini with Linux

How to enable Wake on LAN and power-on after power loss on an Intel Mac Mini running Linux, with setpci and ethtool.

Linux · Reference
Improve the mouse response and acceleration in Debian

How to patch and rebuild xserver-xorg-core on Debian Lenny for the improved mouse acceleration from Simon Thum's patch.

Howto's · Linux
Compiling and patching debian packages from source

A quick reference on how to compile Debian packages from source, and possibly patching them along the way.

Linux · Reference
Enlightened XFCE4

A howto stolen from http://ubuntuforums.org/showthread.php?t=101066 for later use. All credit to its writer, Iandefor.

Howto's · Linux

2008

How to kill a process that uses too much CPU

A Bash script, run from cron, that watches a process's CPU usage and sends an alert e-mail when it goes over a set limit.

Linux · Reference
Norwegian Windows edition on suicide mission

So I downloaded this Debian netinstall image... and Windows went suicidal?

Rants · Linux
Fun with "beep"

How to play notes and simple melodies, such as Für Elise and the Axel F theme, on the PC speaker with the Linux beep program.

Linux
How to move a mysql database from one box to another

How to move a MySQL database to another server with mysqldump and the mysql client.

Linux · Reference
GPG Error: The following signatures were invalid

A tip for the APT error "The following signatures were invalid" when a transparent proxy is in the way.

Linux · Solved Problems
CIFS VFS No response for cmd n mid...

How to stop CIFS mounts from hanging with "No response for cmd" errors by disabling opportunistic locking.

Linux · Solved Problems
Disable the "No mail" notification on machines which have no local mail

How to stop the "No mail." message at login on machines that send all mail to a smarthost, by editing the pam_mail line in PAM.

Howto's · Linux
Hardware clock fix for Debian on Mac Mini

How to stop the hardware clock on a Mac Mini running Debian from moving back an hour each boot, with the --directisa option.

Linux · Solved Problems
Disable Debian's motd on login

How to stop Debian from showing the message of the day on login by emptying /etc/motd and disabling its regeneration at boot.

Howto's · Linux
Nifty linux oneliners

This is a list of nifty oneliners I often use and just as often forget. Now I have a place to jot them down.

Linux · Reference
Installing vmware from scratch

How to install VMware Server 1.0 and its management interface on a fresh Debian install, including the libraries it needs.

Linux · Reference
The stuff I always install on a Debian box

A list of the packages the author installs on every new Debian box, with a one-line command to install them all.

Linux
How to reset the root password on a Debian machine

How to reset a lost root password on Debian from a live CD or by booting with init=/bin/bash from the GRUB menu.

Howto's · Linux
Linux fan speed control - speedfan for linux

A short reference for getting lm-sensors and fan speed control working on Linux, as a Linux equivalent of SpeedFan.

Linux · Reference
Where to rename network interfaces in debian etch

Has your desired eth0 ended up as eth1 and the other way around? Did you put in a new network card, having every config file set to use eth0, and the card shows up as eth1?

Howto's · Linux