1
0

fleshing out some more

This commit is contained in:
dtb 2022-10-17 22:37:05 -04:00
parent 9523e77e7c
commit 0c23741f85

View File

@ -45,6 +45,7 @@ Plan 9 from Bell Labs, due to its historical relationship with UNIX, will be men
<UL>
<LI>_hyperlink(`https://en.wikipedia.org/wiki/Echo_(command)', `echo') (Wikipedia)</LI>
<LI>_hyperlink(`https://man7.org/linux/man-pages/man1/echo.1p.html', `echo(1p)') (man7)</LI>
<LI><A HREF="https://www.netbsd.org/">NetBSD</A>/<A HREF="https://github.com/NetBSD/src/blob/trunk/bin/echo/echo.c">bin/echo/echo.sh</A></LI>
<LI><A HREF="https://www.in-ulm.de/~mascheck/various/echo+printf/">Variations in echo implementations</A></LI>
</UL>
<P>
@ -104,6 +105,73 @@ A traditional _code(`ed(1)') implementation is in plan9ports.
I'm pretty sure some later UNIX-based OSes doubled the _code(`ed(1)') buffers, there's pretty much no downside to doing so in the modern era but it should be very easy to do yourself if it hasn't already been done (just double some of the array sizes in the beginning of _code(`ed.c')).
</P>
<H3 ID="true">true(1)</H3>
<UL>
<LI><A HREF="http://trillian.mit.edu/~jc/;-)/ATT_Copyright_true.html">CHAMBERS John - The /bin/true Command and Copyright</A></LI>
<LI><A HREF="https://twitter.com/rob_pike/status/966896123548872705">PIKE Rob - "/bin/true used to be an empty file."</A></LI>
<LI><A HREF="https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html">RAITER Brian - A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux</A></LI>
<LI><A HREF="https://www.unix.com/man-page/posix/1p/true/">true(1p)</A> (The Open Group, 2003)</LI>
<LI><A HREF="https://www.gnu.org/">GNU</A>/<A HREF="https://www.gnu.org/software/coreutils/">coreutils</A>/<A HREF="https://git.savannah.gnu.org/cgit/coreutils.git/tree/src/true.c">src/true.c</A></LI>
<LI><A HREF="https://www.netbsd.org/">NetBSD</A>/<A HREF="https://github.com/NetBSD/src/blob/trunk/usr.bin/true/true.sh">usr.bin/true/true.sh</A></LI>
</UL>
<P>
_code(`true(1)') is a tool that <I>only</I> quits silently with an exit status of 0.
Similarly, _code(`false(1)') is a tool that <I>only</I> quits silently with an exit status of 1.
Recognizing arguments, printing to standard output, reading from standard input, or otherwise exiting with any other status of 0, is a violation of the POSIX specification for _code(`true(1)').
These utilities find use in shell scripting, which, though extremely relevant to these utilities, is beyond the scope of this article.
</P>
<P>
Because _code(`true(1)')'s required functionality is so simple a POSIX-compliant implementation is a one-liner in most languages, so long as you're willing to make an exception in your code styling.
For example, in C:
</P>
<PRE>
int main(void) { return 0; }
</PRE>
<P>
Because executing an empty shellscript file will in most shells do nothing and return an exit status of 0, technically an empty shellscript file is a POSIX-compliant _code(`true(1)') implementation in 0 bytes.
This was the _code(`true(1)') implementation on early versions of UNIX, including Research UNIX, System V, and Sun's Solaris, according to both Rob Pike and John Chambers.
A more explicit implementation also exists in POSIX shell:
</P>
<PRE>
#!/bin/sh
exit 0
</PRE>
<P>
This happens to be nearly identical in source to the implementation used by NetBSD.
</P>
<P>
Python has the same 0 byte _code(`true(1)') implementation feature as most shells.
Here's _code(`<I>false</I>(1)') in Python rather than _code(`true(1)') to demonstrate how exiting with an arbitrary exit status can be done:
</P>
<PRE>
import sys
sys.exit(1)
</PRE>
<P>
In some shells, _code(`true(1)') is a shell built-in command, so running _code(`true') will run the shell author's implementation of _code(`true(1)') rather than the system implementation.
</P>
<P>
GNU _code(`true(1)'), from the GNU coreutils, is well known for being a maximalist implementation - it's eighty lines long and directly includes four C header files.
Their _code(`true.c') is 2.3 kilobytes and parses the arguments _code(`--help') and _code(`--version') (only if either are the first argument to the program).
The GNU coreutils implementation of _code(`true(1)') is not POSIX compliant.
</P>
<H3 ID="vi">vi</H3>
<UL>
<LI>_hyperlink(`https://man7.org/linux/man-pages/man1/vi.1p.html', `vi(1p)') (man7)</LI>
</UL>
<P>
Unlike _code(`busybox')'s _code(`ed(1)') implementation, its _code(`vi(1)') is very useable.
_code(`vim(1)') is a popular re-implementation of _code(`vi(1)').
</P>
<H2>util-linux</H2>
<UL>
<LI><A HREF="https://en.wikipedia.org/wiki/Util-linux">util-linux - Wikipedia</A></LI>
</UL>
<P>
_code(`util-linux') is distributed on all popular Linux distributions and contains utilities users may expect to be already present on their systems, like _code(`more(1)') or _code(`hexdump(1)').
</P>
<H2>Advanced Configuration and Power Interface</H2>
<UL>
<LI><A HREF="https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface">Advanced Configuration and Power Interface</A> (Wikipedia)</LI>
@ -366,6 +434,73 @@ Complex Makefiles may not be useable in both.
It's custom for Linux systems to have _code(`make(1)') as GNU Make and _code(`bmake(1)') as BSD Make, and BSD-based systems to have _code(`make(1)') as BSD Make and _code(`gmake(1)') as GNU Make.
</P>
<H2>NetBSD</H2>
<UL>
<LI><A HREF="http://netbsd.org/">netbsd.org</A></LI>
<LI><A HREF="https://www.netbsd.org/docs/guide/en/">NetBSD Guide</A></LI>
<LI><A HREF="https://www.netbsd.org/docs/pkgsrc/">pkgsrc Guide</A></LI>
</UL>
<H3>Battery</H3>
<P>_code(`envstat(1)') can show the current battery status.</P>
<H3>Mounting filesystems</H3>
<OL>
<LI>Connect the drive with the filesystem you want to access.</LI>
<LI>Use _code(`dmesg(8)') to determine the location in _code(`/dev/') of the disk.</LI>
<LI>_code(`disklabel(8)') the drive to determine which partition on the disk you want to access (_code(`disklabel /dev/<I>disk</I>'))</LI>
<LI>_code(`mount(8)') the filesystem.</LI>
<LI>_code(`umount(8)') the filesystem when done using it.</LI>
</OL>
<H4>ext4</H4>
<P>
Install _code(`filesystems/fuse') and _code(`filesystems/fuse-ext2').
_code(`disklabel(8)') will list ext4 filesystems as of type "Linux Ext2".
Use _code(`fuse-ext2(1)') to mount the filesystem.
</P>
<P>
_code(`fuse-ext2(1)') is spotty in places and may not work correctly.
</P>
<H4>exFAT</H4>
<P>
Install _code(`filesystems/fuse') and _code(`filesystems/fuse-exfat').
Use _code(`mount.exfat') to mount the filesystem (the manual page for which is _code(`mount.exfat-fuse(8)')).
</P>
<H3>Fix _code(`SSL certificate problem: unable to get local issuer certificate')</H3>
<UL>
<LI><A HREF="http://mail-index.netbsd.org/pkgsrc-users/2021/07/19/msg034147.html">Depending on security/ca-certificates?</A></LI>
<LI><A HREF="https://www.cambus.net/installing-ca-certificates-on-netbsd/">Installing CA certificates on NetBSD</A></LI>
<LI><A HREF="https://github.com/ohmyzsh/ohmyzsh/issues/8321#issuecomment-863493503">SSL Certificate Problem</A> (ohmyzsh/ohmyzsh#8321)</LI>
</UL>
<P>Install _code(`security/mozilla-rootcerts-openssl').</P>
<P>
<I>Do not</I> use SSL workarounds like (in the case of git) _code(`GIT_SSL_NO_VERIFY').
These leave your system open to man-in-the-middle attacks.
</P>
<H3>OpenVPN</H3>
<UL>
<LI>_hyperlink(`https://forums.freebsd.org/threads/mullvad-via-openvpn-up-could-not-execute-external-program.79968/', `Mullvad via openvpn - up could not execute external program') (FreeBSD Forums)</LI>
<LI>_hyperlink(`https://community.openvpn.net/openvpn/wiki/PlatformNotes', `Platform Notes') (OpenVPN Community Wiki)</LI>
</UL>
<P>
If using Mullvad, you have to change the shebang on _code(`update-resolv-conf(8)')
(a standalone Bash script included in the OpenVPN configurations from Mullvad, intended to be placed in _code(`/etc/openvpn/'))
from _code(`#!/bin/bash') to _code(`#!/usr/pkg/bin/bash') if using Bash from pkgsrc or another appropriate location if using a different package manager.
</P>
<H3>rc.d</H3>
<UL>
<LI><A HREF="http://www.mewburn.net/luke/papers/rc.d.pdf">The Design and Implementation of the NetBSD rc.d system</A></LI>
</UL>
<H3>System logging</H3>
<UL>
<LI><A HREF="https://www.unitedbsd.com/d/548-system-instability-on-unstable-version-how-do-i-get-logs/7">System instability on unstable version - how do I get logs?</A></LI>
</UL>
<P>See _code(`syslogd(8)') and _code(`syslog.conf(5)'), which pertain to system logging.</P>
<P>Setting _code(`DDB_ONPANIC') (see _code(`options(4)') and _code(`sysctl(8)')) will save a crash dump at _code(`/var/crash') on kernel panic.
<H3>Upgrading</H3>
<UL>
<LI>The NetBSD Guide - <A HREF="https://www.netbsd.org/docs/guide/en/chap-upgrading.html">Chapter 4: Upgrading NetBSD</A></LI>
<LI><A HREF="https://www.unitedbsd.com/d/110-upgrading-netbsd-using-sysinst">Upgrading NetBSD using sysinst</A></LI>
</UL>
<H2>On-line manual</H2>
<P>
In the context of POSIX and UNIX-like systems, an "on-line" manual is a manual that is accessible via the computer system it documents.
@ -464,73 +599,6 @@ _code(`dm-crypt') will need the UUID of the <I>physical</I> block device while f
<LI><A HREF="https://en.wikipedia.org/wiki/TestDisk">TestDisk</A> (Wikipedia)</LI>
</UL>
<H2>NetBSD</H2>
<UL>
<LI><A HREF="http://netbsd.org/">netbsd.org</A></LI>
<LI><A HREF="https://www.netbsd.org/docs/guide/en/">NetBSD Guide</A></LI>
<LI><A HREF="https://www.netbsd.org/docs/pkgsrc/">pkgsrc Guide</A></LI>
</UL>
<H3>Battery</H3>
<P>_code(`envstat(1)') can show the current battery status.</P>
<H3>Mounting filesystems</H3>
<OL>
<LI>Connect the drive with the filesystem you want to access.</LI>
<LI>Use _code(`dmesg(8)') to determine the location in _code(`/dev/') of the disk.</LI>
<LI>_code(`disklabel(8)') the drive to determine which partition on the disk you want to access (_code(`disklabel /dev/<I>disk</I>'))</LI>
<LI>_code(`mount(8)') the filesystem.</LI>
<LI>_code(`umount(8)') the filesystem when done using it.</LI>
</OL>
<H4>ext4</H4>
<P>
Install _code(`filesystems/fuse') and _code(`filesystems/fuse-ext2').
_code(`disklabel(8)') will list ext4 filesystems as of type "Linux Ext2".
Use _code(`fuse-ext2(1)') to mount the filesystem.
</P>
<P>
_code(`fuse-ext2(1)') is spotty in places and may not work correctly.
</P>
<H4>exFAT</H4>
<P>
Install _code(`filesystems/fuse') and _code(`filesystems/fuse-exfat').
Use _code(`mount.exfat') to mount the filesystem (the manual page for which is _code(`mount.exfat-fuse(8)')).
</P>
<H3>Fix _code(`SSL certificate problem: unable to get local issuer certificate')</H3>
<UL>
<LI><A HREF="http://mail-index.netbsd.org/pkgsrc-users/2021/07/19/msg034147.html">Depending on security/ca-certificates?</A></LI>
<LI><A HREF="https://www.cambus.net/installing-ca-certificates-on-netbsd/">Installing CA certificates on NetBSD</A></LI>
<LI><A HREF="https://github.com/ohmyzsh/ohmyzsh/issues/8321#issuecomment-863493503">SSL Certificate Problem</A> (ohmyzsh/ohmyzsh#8321)</LI>
</UL>
<P>Install _code(`security/mozilla-rootcerts-openssl').</P>
<P>
<I>Do not</I> use SSL workarounds like (in the case of git) _code(`GIT_SSL_NO_VERIFY').
These leave your system open to man-in-the-middle attacks.
</P>
<H3>OpenVPN</H3>
<UL>
<LI>_hyperlink(`https://forums.freebsd.org/threads/mullvad-via-openvpn-up-could-not-execute-external-program.79968/', `Mullvad via openvpn - up could not execute external program') (FreeBSD Forums)</LI>
<LI>_hyperlink(`https://community.openvpn.net/openvpn/wiki/PlatformNotes', `Platform Notes') (OpenVPN Community Wiki)</LI>
</UL>
<P>
If using Mullvad, you have to change the shebang on _code(`update-resolv-conf(8)')
(a standalone Bash script included in the OpenVPN configurations from Mullvad, intended to be placed in _code(`/etc/openvpn/'))
from _code(`#!/bin/bash') to _code(`#!/usr/pkg/bin/bash') if using Bash from pkgsrc or another appropriate location if using a different package manager.
</P>
<H3>rc.d</H3>
<UL>
<LI><A HREF="http://www.mewburn.net/luke/papers/rc.d.pdf">The Design and Implementation of the NetBSD rc.d system</A></LI>
</UL>
<H3>System logging</H3>
<UL>
<LI><A HREF="https://www.unitedbsd.com/d/548-system-instability-on-unstable-version-how-do-i-get-logs/7">System instability on unstable version - how do I get logs?</A></LI>
</UL>
<P>See _code(`syslogd(8)') and _code(`syslog.conf(5)'), which pertain to system logging.</P>
<P>Setting _code(`DDB_ONPANIC') (see _code(`options(4)') and _code(`sysctl(8)')) will save a crash dump at _code(`/var/crash') on kernel panic.
<H3>Upgrading</H3>
<UL>
<LI>The NetBSD Guide - <A HREF="https://www.netbsd.org/docs/guide/en/chap-upgrading.html">Chapter 4: Upgrading NetBSD</A></LI>
<LI><A HREF="https://www.unitedbsd.com/d/110-upgrading-netbsd-using-sysinst">Upgrading NetBSD using sysinst</A></LI>
</UL>
<H2>PCI Utilities</H2>
<UL>
<LI><A HREF="https://github.com/pciutils/pciutils">pciutils/pciutils</A> (GitHub)</LI>
@ -607,11 +675,6 @@ This generates an <A HREF="https://en.wikipedia.org/wiki/EdDSA#Ed25519">Ed25519<
_code(`nano(1)') is a text editor that's usually recommended for beginners because its controls are more intuitive.
_code(`ne(1)') is like _code(`nano(1)') but with different superpowers. Not yet in pkgsrc.
</P>
<H3>vi</H3>
<P>
Unlike _code(`busybox')'s _code(`ed(1)') implementation, its _code(`vi(1)') is very useable.
_code(`vim(1)') is a popular re-implementation of _code(`vi(1)').
</P>
<H3>emacs</H3>
<P>
Emacs ("editor macros") is a text editor with a very powerful Lisp interpreter included.
@ -624,67 +687,6 @@ Technically _code(`cat(1)') and other UNIX utilities can be used in a hacky way
You'd be better off using _code(`ed(1)'); the UX is very similar.
</P>
<H2 ID="true">true(1)</H2>
<UL>
<LI><A HREF="http://trillian.mit.edu/~jc/;-)/ATT_Copyright_true.html">CHAMBERS John - The /bin/true Command and Copyright</A></LI>
<LI><A HREF="https://twitter.com/rob_pike/status/966896123548872705">PIKE Rob - "/bin/true used to be an empty file."</A></LI>
<LI><A HREF="https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html">RAITER Brian - A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux</A></LI>
<LI><A HREF="https://www.unix.com/man-page/posix/1p/true/">true(1p)</A> (The Open Group, 2003)</LI>
<LI>Notable true implementations<UL>
<LI><B>ongoing</B> started 1992 - <A HREF="https://www.gnu.org/">GNU</A>/<A HREF="https://www.gnu.org/software/coreutils/">coreutils</A> - <A HREF="https://git.savannah.gnu.org/cgit/coreutils.git/tree/src/true.c">src/true.c</A></LI>
<LI><B>ongoing</B> forked from 4.4BSD-Lite2 - <A HREF="https://www.netbsd.org/">NetBSD</A>/<A HREF="https://github.com/NetBSD/src">src</A> - <A HREF="https://github.com/NetBSD/src/blob/trunk/usr.bin/true/true.sh">usr.bin/true/true.sh</A></LI>
</UL></LI>
</UL>
<P>
_code(`true(1)') is a tool that <I>only</I> quits silently with an exit status of 0.
Similarly, _code(`false(1)') is a tool that <I>only</I> quits silently with an exit status of 1.
Recognizing arguments, printing to standard output, reading from standard input, or otherwise exiting with any other status of 0, is a violation of the POSIX specification for _code(`true(1)').
These utilities find use in shell scripting, which, though extremely relevant to these utilities, is beyond the scope of this article.
</P>
<P>
Because _code(`true(1)')'s required functionality is so simple a POSIX-compliant implementation is a one-liner in most languages, so long as you're willing to make an exception in your code styling.
For example, in C:
</P>
<PRE>
int main(void) { return 0; }
</PRE>
<P>
Because executing an empty shellscript file will in most shells do nothing and return an exit status of 0, technically an empty shellscript file is a POSIX-compliant _code(`true(1)') implementation in 0 bytes.
This was the _code(`true(1)') implementation on early versions of UNIX, including Research UNIX, System V, and Sun's Solaris, according to both Rob Pike and John Chambers.
A more explicit implementation also exists in POSIX shell:
</P>
<PRE>
#!/bin/sh
exit 0
</PRE>
<P>
This happens to be nearly identical in source to the implementation used by NetBSD.
</P>
<P>
Python has the same 0 byte _code(`true(1)') implementation feature as most shells.
Here's _code(`<I>false</I>(1)') in Python rather than _code(`true(1)') to demonstrate how exiting with an arbitrary exit status can be done:
</P>
<PRE>
import sys
sys.exit(1)
</PRE>
<P>
In some shells, _code(`true(1)') is a shell built-in command, so running _code(`true') will run the shell author's implementation of _code(`true(1)') rather than the system implementation.
</P>
<P>
GNU _code(`true(1)'), from the GNU coreutils, is well known for being a maximalist implementation - it's eighty lines long and directly includes four C header files.
Their _code(`true.c') is 2.3 kilobytes and parses the arguments _code(`--help') and _code(`--version') (only if either are the first argument to the program).
The GNU coreutils implementation of _code(`true(1)') is not POSIX compliant.
</P>
<H2>util-linux</H2>
<UL>
<LI><A HREF="https://en.wikipedia.org/wiki/Util-linux">util-linux - Wikipedia</A></LI>
</UL>
<P>
_code(`util-linux') is distributed on all popular Linux distributions and contains utilities users may expect to be already present on their systems, like _code(`more(1)') or _code(`hexdump(1)').
</P>
<H2>WiFi</H2>
<H3>wpa_supplicant</H3>
<P>