diff --git a/Arch-Default-Kernel.md b/Arch-Default-Kernel.md new file mode 100644 index 0000000..548925e --- /dev/null +++ b/Arch-Default-Kernel.md @@ -0,0 +1,8 @@ +Set the default kernel in GRUB2 for Arch + +``` +ROOT_PART=$(grub-probe --target=device /) +ROOT_UUID=$(grub-probe --device ${ROOT_PART} --target=fs_uuid) +grub-set-default "gnulinux-linux-advanced-${ROOT_UUID}" +``` + diff --git a/Arch-Kernel-Order.md b/Arch-Kernel-Order.md new file mode 100644 index 0000000..baec941 --- /dev/null +++ b/Arch-Kernel-Order.md @@ -0,0 +1,26 @@ +Patch GRUB2 on Arch to sort the kernels so that the top entry is the latest standard kernel (when the LTS kernel is also installed) + +grub2 /etc/grub.d/10_linux ordering patch (http://savannah.gnu.org/bugs/?42597) + +``` +--- 10_linux.orig 2014-05-14 01:22:27.000000000 -0500 ++++ 10_linux 2014-06-21 13:20:37.816869963 -0500 +@@ -177,7 +177,16 @@ + + is_top_level=true + while [ "x$list" != "x" ] ; do +- linux=`version_find_latest $list` ++ # version_find_latest returns 'linux-lts' before 'linux' on the average ++ # Arch install of these two kernels, we'll first check if there are any ++ # numerics in the kernels, and if not just pop them off the stack in ++ # natural alpha sorting order. ++ if [ $(echo $list | grep -q '[0-9]') ]; then ++ linux=`version_find_latest $list` ++ else ++ artmp=($list) ++ linux=${artmp[0]} ++ fi + gettext_printf "Found linux image: %s\n" "$linux" >&2 + basename=`basename $linux` + dirname=`dirname $linux` +``` diff --git a/Diff-Lines.md b/Diff-Lines.md new file mode 100644 index 0000000..7cbd80e --- /dev/null +++ b/Diff-Lines.md @@ -0,0 +1,28 @@ +One liner to diff lines one by one (handy for ldd output) + +``` +#!/bin/sh + +diff --unchanged-line-format="" \ + --old-line-format="%dn: %L" \ + --new-line-format="%dn: %L" \ + "$1" "$2" | sort -n + +# This is handy for situations where you need a line-by-line +# comparison of two similar outputs, such as ldd against two +# different libraries to find out if one of them is different +# (extra dependencies). For example: +# +# ldd libsomething.so.old | sort > old.txt +# ldd libsomething.so.new | sort > new.txt +# +# diffl.sh old.txt new.txt +# 1: /usr/lib64/ld-linux-x86-64.so.2 (0x00007f61ba4c7000) +# 1: /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6b96d6b000) +# 2: libc.so.6 => /usr/lib/libc.so.6 (0x00007f61b89f2000) +# 2: libc.so.6 => /usr/lib/libc.so.6 (0x00007f6b95092000) +# 3: libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f61b8376000) +# 3: libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f6b94a16000) +# ... +``` + diff --git a/GitLab-Anchors.md b/GitLab-Anchors.md new file mode 100644 index 0000000..3ba174f --- /dev/null +++ b/GitLab-Anchors.md @@ -0,0 +1,32 @@ +## Contents + + - [net.ifnames Naming](#netifnames-naming) + - [/etc/hostname](#etchostname) + - [Instanced Units (.service, .socket, etc...)](#instanced-units-service-socket-etc) + - [Mount Units (.mount)](#mount-units-mount) + - [Example Bind Mount - /var/tmp to /tmp](#example-bind-mount-vartmp-to-tmp) + +## net.ifnames Naming + + - pandoc: `net.ifnames-naming` + - gitlab / github: `netifnames-naming` + +## /etc/hostname + + - pandoc: `/etc/hostname` + - gitlab / github: `etchostname` + +## Instanced Units (.service, .socket, etc...) + + - pandoc: `instanced-units-(.service,-.socket,-etc...)` + - gitlab / github: `instanced-units-service-socket-etc` + +## Mount Units (.mount) + + - pandoc: `mount-units-(.mount)` + - gitlab / github: `mount-units-mount` + +## Example Bind Mount - /var/tmp to /tmp + + - pandoc: `example-bind-mount---/var/tmp-to-/tmp` + - gitlab / github: `example-bind-mount---vartmp-to-tmp` diff --git a/IPv4-Default-IP.md b/IPv4-Default-IP.md new file mode 100644 index 0000000..ca812cb --- /dev/null +++ b/IPv4-Default-IP.md @@ -0,0 +1,10 @@ +IPv4 address in pure bash/zsh + +``` +[[ -n "$1" ]] || exit 1 +IP=$(ip -4 -o addr show dev $1 primary 2>/dev/null) +IP=${IP%%/*} +IP=${IP##* } +[[ -n "$IP" ]] && echo $IP || exit 1 +``` + diff --git a/Markdown-Samples.md b/Markdown-Samples.md new file mode 100644 index 0000000..4a95aa4 --- /dev/null +++ b/Markdown-Samples.md @@ -0,0 +1,45 @@ +# Markdown Samples + +## Blockquote + +> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +## Blockquote with code + +> Lorem ipsum dolor sit amet, +> +> ``` +> consectetur adipiscing elit, +> ``` +> +> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + +## List with code + + - Item 1 + ``` + code 1 + ``` + - Item 2 + +## Blockquote with list with code + +> Lorem ipsum dolor sit amet, +> +> - Item 1 +> ``` +> code 1 +> ``` +> - Item 2 +> +> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + +## Citations + +This link [(1)][c1] here or [(2)][c2] below + + 1. + 2. + +[c1]: https://example.com +[c2]: https://foobar.com diff --git a/_Sidebar.md b/_Sidebar.md index 58aa762..d62587b 100644 --- a/_Sidebar.md +++ b/_Sidebar.md @@ -2,12 +2,15 @@ - [[APT WhatProvides]] - [[Apache wpadmin]] +- [[Arch Default Kernel]] +- [[Arch Kernel Order]] - [[Bash Dump History]] - [[Bash Trim Whitespace]] - [[CSS Reset]] - [[DB2 Info]] - [[Debian Upgrade]] - [[Dell OpenManage]] +- [[Diff Lines]] - [[Find Examples]] - [[Firefox Tweaks]] - [[Git Combine Repos]] @@ -15,9 +18,11 @@ - [[Git Quickstart]] - [[Git Rewrite User]] - [[Git Server]] +- [[GitLab Anchors]] - [[Glibc IPv4]] - [[GnuPG Things]] - [[IPv4 Default Gateway]] +- [[IPv4 Default IP]] - [[KRB5 Empty Keytab]] - [[Kernel Boot Debug]] - [[Kernel Decompress]] @@ -25,6 +30,7 @@ - [[Linux Valid Usernames]] - [[Loopback FS]] - [[MX Blackhole]] +- [[Markdown Samples]] - [[Mount OVA]] - [[Mount qcow2]] - [[MySQL Connections]] @@ -38,6 +44,7 @@ - [[Samba OSX]] - [[Server Notes]] - [[Smem Datamash]] +- [[systemd PID1]] - [[Thunderbird LDAP AD]] - [[uBlock Filters]] - [[udev Hide Partitions]] diff --git a/systemd-PID1.md b/systemd-PID1.md new file mode 100644 index 0000000..55f42e5 --- /dev/null +++ b/systemd-PID1.md @@ -0,0 +1,20 @@ +Test if PID 1 is systemd + +``` +$ sudo stat -c %N /proc/1/exe +or +# stat -c %N /proc/1/exe + + +Arch: '/proc/1/exe' -> '/usr/lib/systemd/systemd' +U16+: '/proc/1/exe' -> '/lib/systemd/systemd' +U14-: ‘/proc/1/exe’ -> ‘/sbin/init’ +EL7+: ‘/proc/1/exe’ -> ‘/usr/lib/systemd/systemd’ +EL6-: `/proc/1/exe' -> `/sbin/init' +DEB9+: '/proc/1/exe' -> '/lib/systemd/systemd' + +One liner: + +[[ $(sudo stat -c %N /proc/1/exe | grep -q systemd) ]] && echo "False" || echo "True" +``` +