Technical Notes

These notes are my personal online notebook of useful commands and "how-to's". You are welcome to make use of them if you find them helpful. They obviously don't come with any warranty! Click on one of the category tags above for the notes in any category.

Fixing a Linux broken boot

If the system has been corrupted, and there is no grub menu, then boot from a live CD, open a terminal and do this:

sudo fdisk -l # find the root filesystem
sudo mount /dev/sda2 /mnt #whatever your root filesystem is
sudo mount --bind /$D1 /mnt/$D1 &&
sudo mount --bind /$D2 /mnt/$D2 &&
sudo mount --bind /$D3 /mnt/$D3 &&
sudo mount --bind /$D4 /mnt/$D4

sudo chroot /mnt # You are now back in the main hard drive

cd /etc/default
cp grub grub.orig
vi grub
# change timeout from 0 to 10
# change STYLE from hidden to menu
# remove # from Ter

Wiping a Hard Drive Clean

To securely wipe a hard drive of all data, do:

apt install wipe
shred -vfz -n 2 /dev/sdb
  • Options above are verbose, force, zero out in an extra pass
  • Number of passes: -n 2

An alternative “light” way of doing this is to simply copy random bytes

fdisk -l /dev/$D # make sure we have the right device
dd if=/dev/urandom of=/dev/$D bs=4096 status=progress
  • If the progress info is not sufficient, then from another terminal session do the following and updates will appear in the original terminal
pgrep -l '^dd$'   # gives the pid: nnnn DD
watch -n 60 kill

iptables configuration on a linux server

  • List current tables with line numbers and stats
iptables -L INPUT --line-numbers -v
  • Append another rule
iptables -A INPUT -s -j DROP
  • Delete rule #3
iptables -D INPUT 3
  • The moment you apply IPTABLE rule it immediately becomes active.But it will not survive a reboot.
  • To be able to survive IPTABLES a reboot in your network configuration file /etc/network/interfaces file (referring to a Debian/Ubuntu system) you need to add:
pre-up  iptables-restore < firewall.txt

Making changes persistent in CentOS 5

iptables rules are stored in memory.

Setting up NFS on Ubuntu 16.04

Make sure userid’s and groupid’s match between the systems

  • e.g. usermod -u 1001 -g 504 -c "Andrew Fountain" andrewf

Set up the server

  • set up the fully qualified domain name, e.g.

Installing libsass on Ubuntu

The most minimal way of doing an installation is using sassc, the C binding.

apt install git build-essential
cd /opt
git clone https://github.com/sass/libsass.git
git clone https://github.com/sass/sassc.git libsass/sassc
echo 'SASS_LIBSASS_PATH="/opt/libsass"' >> /etc/environment
source /etc/environment
echo $SASS_LIBSASS_PATH # Make sure it worked…
cd libsass/sassc
ln -sn /opt/libsass/sassc/bin/sassc /usr/local/bin/

sassc file.scss file.css # run like this

Install php 5.6 on Ubuntu 16.04

By default Ubuntu 16.04 (Xenial) now comes with php 7.0

You can install php 5.6 in parallel and switch between them using the following instructions:

add-apt-repository ppa:ondrej/php
apt update
apt install php5.6 libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-xmlrpc
a2dismod php7.0
a2enmod php5.6
systemctl restart apache2
  • See htt

Setting up Syncthing on an Ubuntu 16.04 server


PDF printing under ubuntu

To install:

sudo apt-get install cups-pdf

There are a couple of pitfalls:

  1. Getting unreadable PDF
    • Due to wrongly selecting ☒ print to file (which creates an EPS, not a pdf but can be read with some pdf tools
    • Just don’t be tempted to check this box!

Problems upgrading to Ubuntu 15.10

  1. A bad swap file entry in /etc/fstab stopped systemd from booting
  2. systemd did’t like my ssd optimizations:
    • tmpfs /var/lock tmpfs defaults,noatime,mode=0755 0 0 # had to be commented out
    • had to do: mkdir /etc/tmpfiles.d/console-kit.conf to stop another error message

See ubuntuforums.org/…owthread.php

and bbs.archlinux.org/…ewtopic.php for explanations

Syndicate content