Skip to content

Instantly share code, notes, and snippets.

View plembo's full-sized avatar

Phil Lembo plembo

View GitHub Profile
@plembo
plembo / FindPDN.md
Last active March 29, 2024 17:49
Find a predictable device name

Find a predictable device name

One-liner to find the Linux systemd "predictable name" of a hardware network device like the embedded ethernet card on a desktop motherboard.

udevadm test-builtin net_id /sys/class/net/eth0 | grep '^ID_NET_NAME_'

Answer by "GnP" in this post.

@plembo
plembo / ubuntu-server-setup-netplan.md
Last active February 9, 2025 16:52
Ubuntu Server Setup - with netplan

Ubuntu Server Setup - with netplan

Introduction

The assumption here is that you're now starting with a Ubuntu 22.04 LTS Server or newer, rather than Desktop, base (Ubuntu Desktop deploys NetworkManager rather than systemd-networkd by default). This box has an AMD Ryzen CPU.

The goal is networking configured for static addressing using systemd-networkd and netplan. Note that punctuation (including hypens, '-') and indentation are significant when working with netplan YAML files.

There are a lot good arguments against using netplan. I have tried NetworkManager (packages named "network-manager", but the service is "NetworkManager.service" -- go figure) on Ubuntu Server, and was

@plembo
plembo / search-domain-kvm-dhcp.md
Last active August 29, 2022 14:49
Setting the search domain in DHCP for KVM

Setting the search domain in DHCP for KVM

The built-in DHCP server (based on dnsmasq) included with KVM (libvirtd) has limited configuration options compared to other DHCP servers like the one published by ISC, but it can be set up to specify a search domain for clients.

Edit the network configuration using virsh. The examples below assume configuration will be of a network named "default" (by default this is the first network set up by libvirtd).

$ virsh net-edit default
@plembo
plembo / greed-apache-redirect.md
Last active April 22, 2019 17:40
Greediest Apache redirect

Greediest Apache Redirect

Sometimes you just have to make sure that anything going to an old site winds up on a designated page over at the new.

RewriteEngine On
RewriteRule /.* https://new.example.com/newhome [R=301,L]

The foward slash dot star is what makes this redirect matching rule the most greedy of all. The "R=301" flag forces an external redirect (to another host) and tells the browser it is permanent. The "L" flag marks this as the end of the rewriting process.

@plembo
plembo / new-chromebook-setup.md
Last active May 8, 2019 15:58
New Chromebook Setup

Setup a new Chromebook

Model used: Dell Inspiron 3181 (11" screen)

  • Run through standard configuration routine, linking to Google account.
  • Install Android apps: Gmail, Google Calendar, Bitwarden.
  • Install Linux Beta, share SD Card with Linux.
  • Set hostname using "hostnamectl set-hostname mycb" ("mycb" is your chosen Linux host name).
  • Update Linux packages with "apt update" and "apt upgrade".
  • In Linux terminal, edit /etc/dhcp/dhclient.conf to add:
@plembo
plembo / crontab-perm-denied.md
Last active February 7, 2025 06:16
crontab says fopen: permission denied

When crontab gives fopen: permission denied error

While trying to open my user's crontab on Ubuntu, the system barked back:

$ crontab -l
crontabs/myuser/: fopen: Permission denied

This is due to improper permissions on crontab executable.

@plembo
plembo / bu-restore-perms-ubuntu.md
Last active September 17, 2021 04:07
Backup and Restore File Permissions on Ubuntu LTS

Backup and Restore Ubuntu LTS file permissions

This can be done any time, but it's probably a best practice to create a backup on initial install and update occasionally afterwards.

This procedure uses utiltiies in the acl package, which should be installed by default.

To backup:

$ cd /
$ sudo getfacl -R . >/tmp/root-perms.txt
@plembo
plembo / you-need-spice-vdagent.md
Last active January 27, 2025 00:55
You need spice-vdagent

You need spice-vdagent

Debian or Kali Linux installed to as KVM (libvirtd) guests do not automatically have qemu-guest-agent or spice-vdagent installed. This will prevent seamless movement of the mouse cursor between the guest and host desktop in Virtual Machine Manager (requiring the use of a Ctrl-Alt to release the cursor from the guest window).

To cure this, install both qemu-guest-agent and spice-vdagent on each guest and reboot (the guests).

$ sudo apt install qemu-guest-agent
$ sudo apt install spice-vdagent
@plembo
plembo / setupsublime.md
Last active August 17, 2019 16:29
Sublime Text Setup

Sublime Text Setup

Notes on setting up Sublime Text.

  1. Install from binary or repo. Prefer repo on Linux. See Linux Package Manager Repositories. For Debian based Linux distros. Stable channel.
$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
$ sudo apt-get install apt-transport-https
$ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
$ apt update
@plembo
plembo / resizekvmboot.md
Last active November 5, 2023 18:28
Resize a kvm boot partition

Resize a KVM (libvirtd) boot partition

Most of the guests I use for testing are desktop machines created using the graphical virt-manager tool. These have a single partition virtio disk that's formatted ext4 when Linux, without LVM. This is the procedure I follow to grow the disk when more space is needed:

  1. Shut down the guest.
  2. Use qemu-img to grow the disk:
$ sudo qemu-img resize myguest.qcow2 +20G