i33Ct

            We do care about Your image:
            program in C, script with Perl,
            teach Java, learn Python.

            Laminar Stagnation Theatre
            
Quick notes on FreeBSD 12.0 (J13D0)

wget -c --no-check-certificate https://www.nano-editor.org/dist/v3/nano-3.2.tar.xz
https://www.tecmint.com/install-apache-mariadb-and-php-famp-stack-on-freebsd/
pkg install php72 mod_php72 php72-mbstring php72-pecl-mcrypt php72-zlib php72-curl php72-gd php72-json
problem with mcrypt:
https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
pkg install php72 mod_php72 php72-mbstring php72-pecl-mcrypt php72-zlib php72-curl php72-gd php72-json

BSD: INSTALL, PXE, COOKBOOK
===========================

PART I. INSTALL
---------------

Virtual Box v.5.2.8

   OS: BSD, FreeBSD 64 bit
   RAM: 4096MB
   VIDEO: 128MB
   HD: Controller IDE, VHD 16GB
   ISO: FreeBSD-11.1-RELEASE-amd64-bootonly.iso
   Network: Bridged

  ftp://ftp.freebsd.org      Main Site
  ftp://ftp.ee.freebsd.org   Estonia
  ftp://ftp.se.freebsd.org   Sweden

Fetching distribution

Default:

  base.txz
  kernel.txz

Optional:

  lib32
  ports

Region: Europe, Estonia, EET

  Default services: SSHD
  Invite virtu into other groups? []: wheel
  user: virtu  password: virtu
  user: root   password: root

Reboot.

  $ cat /etc/rc.conf
  hostname="BSDBox"
  ifconfig_em0="DHCP"
  sshd_enable="YES"
  # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
  dumpdev="AUTO"

Localization

  https://cooltrainer.org/a-freebsd-desktop-howto/

Check locale

  root@darkstar:~ # locale
  LANG=
  LC_CTYPE="C"
  LC_COLLATE="C"
  LC_TIME="C"
  LC_NUMERIC="C"
  LC_MONETARY="C"
  LC_MESSAGES="C"
  LC_ALL=

Set locale

  root@darkstar:~ # locale -a | grep EE
  et_EE.ISO8859-1
  et_EE.ISO8859-15
  et_EE.UTF-8

Edit profile (et_EE.UTF-8 for Estonia: sort)

  # cp /etc/profile /etc/profile.orig
  ..
  # diff profile.orig profile
  18a19,21
  > LANG=en_US.UTF-8
  > LC_ALL=en_US.UTF-8
  > CHARSET=UTF-8

Edit login.conf

  # cp /etc/login.conf /etc/login.conf.orig
  ..
  # diff login.conf.orig login.conf
  49c49,51
  <       :umask=022:
  ---
  >       :umask=022:\
  >       :charset=UTF-8:\
  >       :lang=en_US.UTF-8:

Rebuild the login database with

  # cap_mkdb /etc/login.conf
  # reboot

  $ kbdmap="ee.kbd"  now i have funky layout:

                   shift            altgr            shif-altgr
  ~1234567890+`'   ~!"#$%&/()=?`*   ~ @£$  {[]}\`'   ~ @£$  {[]}\`'
  qwertyuiopü?     QWERTYUIOPÜ?     qw€rtyuiopü§     QW€RTYUIOPÜ§
  asdfghjklöä      ASDFGHJKLÖÄ      ašdfghjklö^      A?DFGHJKLÖ^
  zxcvbnm,.-       ZXCVBNM;:_       žxcvbnm /        ?XCVBNM /

Package managememt
..................

  # pkg
  The package management tool is not yet installed on your system.
  Do you want to fetch and install it now? [y/N]: y
  Bootstrapping pkg from
    pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly
  please wait... Verifying signature with trusted certificate
  pkg.freebsd.org.2013102301... done
  Installing pkg-1.10.1...
  Extracting pkg-1.10.1: 100%
  pkg: not enough arguments
  Usage: pkg [-v] [-d] [-l] [-N]
             [-j <jail name or id>|-c <chroot path>|-r <rootdir>]
             [-C <configuration file>] [-R <repo config dir>]
             [-o var=value] [-4|-6] <command> [<args>]

  For more information on available commands and options see 'pkg help'.

  # pkg2ng
  Converting packages from /var/db/pkg
  Analysing shared libraries, this will take a while...
  Checking all packages: 100%

Building nano from source
-------------------------

  $ su # note that BSD's 'su -' is like Debian 'su' and vice versa
  # pkg info
  pkg-1.10.3_1                    Package manager

  # pkg install wget gettext ncurses
  # wget -c --no-check-certificate  \
      https://www.nano-editor.org/dist/v2.9/nano-2.9.3.tar.xz
  # tar xf nano-2.9.3.tar.xz
  # cd nano-2.9.3
  # ./configure
  # make
  # make install
  # rm -rf nano-2.9.3
  # nano --version
   GNU nano, version 2.9.3

Using nano
..........
                            Bad Habit:)

Remember, there are billion of other hot keys still active!

  Help  -- ^g : (G)et Help    on screen (hint)
  Quit  -- ^x : e(X)it        on screen (hint)

  Save  -- ^o : Write (O)ut   on screen (hint)
  Find  -- ^w : (W)o ist?     on screen (hint)

  Cut   -- ^k : (K)ut         on screen (hint)
  Paste -- ^u : (U)nkut       on screen (hint)

And if you stretch the screen wider than about 1400 pixels, there's a hint at bottom right*4:

  Undo   -- m-u: (U)ndo       m for ALT (meta)
  Redo   -- m-e: r(E)do

Still have to remember:

  -- Hint area: priorities by pairs

    Most important: Help    2: File->Save    4: Find       6: Kut
    1:              Quit    3: File->Open    5: Replace    7: Unkut

  ctrl ^  switch visual marking on/off
  ctrl w  start search DIALOG [^W: Where is]
  alt  w  repeat search
  ctrl \  start replace DIALOG (a -- replace all instances)
  alt  #  toggle show line numbers
  alt  $  toggle ($)oftwrap (long line wrapping)
  alt  r  toggle regex search on/off (while in search)

Put your famous presets into ~/.nanorc

  set regexp        # enable regex search-replace
  set nohelp        # -x
  set linenumbers   # -l
  set morespace     # -O
  set softwrap      # -$

Tired enough? BTW, there is ncurses based midnight editor*6:

  | The editor is very easy to use and requires no tutoring.
  | To see what keys do what, just consult the appropriate
  | pull-down menu.
  | cat /usr/local/share/mc/help/mc.hlp | grep 'very easy'

To add the package (4.8.20):

  pkg install mc

  | Putty has ability to copy-paste. In mcedit, hold __SHIFT__ and     |
  | select by mouse                                                    |
  |                                                                    |
  |   https://superuser.com/questions/884245                           |
  |   /copy-and-paste-text-in-midnight-commander-mc-via-putty-in-linux |
  |                                                                    |
  | Good answer -- immediate reaction: LOL -..                         |

Your device doesn't allow to install editor of your choice? (not enough privileges, embedded system, etc..)

vi is usualy available. sometimes ed.

Further reading:
...............

  1. 8 Things to do after Installing FreeBSD 11 Unix System

    https://linoxide.com/distros/things-installing-freebsd-11/

PART II. PXE
------------

1. Enable second NIC, Internal network.

in /etc/rc.conf add*

  ifconfig_em1="inet 10.10.10.1 netmask 255.255.255.0"

now reactivate NIC in current session:

  ifconfig em1 down
  ifconfig em1 inet 10.10.10.1 netmask 255.255.255.0 up

more aggressive behaviour (you lose SSH, first make script)

  service netif restart
  dhclient em0
  ifconfig em1 inet 10.10.10.1 netmask 255.255.255.0 up

Check NIC with SystemRescueCD machine:

  rescue % ifconfig enp0s3 down
  rescue % ifconfig enp0s3 inet 10.10.10.2 netmask 255.255.255.0 up
  rescue % ping 10.10.10.2

TFTP
....

Install TFTP:

  # whereis tftp-hpa
  tftp-hpa: /usr/ports/ftp/tftp-hpa
  # cd /usr/ports/ftp/tftp-hpa
  # make
  # make install
  # make clean

add to /etc/rc.conf

  tftpd_enable="YES"
  tftpd_flags="--ipv4 --create --address 0.0.0.0:69 -s /usr/local/tftp"

Create tftpboot folder, put some file for testing purposes.

  # mkdir -p /usr/local/tftp
  # echo put banana here.. > /usr/local/tftp/banana

And start the tftpd service (thus starting tftpd):

  # service tftpd start

Check tftp is running:

  # netstat -uap udp
  Active Internet connections (including servers)
  Proto Recv-Q Send-Q Local Address   Foreign Address   (state)
  udp4       0      0 *.tftp          *.*
  ...

Troubleshoot tftp with "SystemRescue" machine

  rescue % tftp 10.10.10.1
  tftp> get banana
  tftp> quit

More troubleshooting in

  http://www.ing.iac.es/~docs/external/realport/ps-xxxx-tsht-tftp.html

PF MASQUERADE
.............

  https://forums.freebsd.org/threads/nat-in-pf.22590/

Add following rows to /etc/rc.conf

  # nano /etc/rc.conf
  ..
  # PF
  pf_enable="YES"
  pf_rules="/etc/pf.conf"
  pflog_enable="YES"
  pflog_logfile="/var/log/pflog"

  gateway_enable="YES"
  ..

Following text goes to /etc/pf.conf

  INET=em0
  # ILAN=em1
  REDE="{ 10.10.10.0/24 }"
  set skip on lo0
  # 'nat/rdr' is TRANSLATION 'pass' is FILTERING
  # means iptables -t nat -a POSTROUTING -s $REDE -o eth0 -j MASQUERADE
  nat on $INET from $REDE to any -> ($INET)
  pass in all

Start the Firewall

  # /etc/rc.d/pf start
  Enabling pf.
  # service pflog start
  Starting pflog.
  # sysctl net.inet.ip.forwarding=1

Troubleshoot: Set up pflog (man 4 pflog) and run tcpdump (man 1 tcpdump) on the interfaces.

  rescue % ifconfig enp0s3 inet 10.10.10.1 netmask 255.255.255.0
  rescue % route add default gw 192.168.1.1
  rescue % ping 8.8.8.8

DNS

  rescue % nano /etc/resolv.conf
  nameserver 192.168.1.1
  ping <ufo.mars>

DHCP

    =============================================================
  || NOTE: TO AVOID IP-COLLISIONS IN CLASSROOM SWITCH em0 TO nat ||
    =============================================================

Using isc-dhcp43-server. Disable all extras (LDAP, Paranoia, etc..)

  $ cd /usr/ports/net/isc-dhcp43-server && make install clean

Configure DHCP. Create a new dhcp configuration file at

  /usr/local/etc/dhcpd.conf:

  allow booting;
  allow bootp;
  authoritative;
  option domain-name-servers 192.168.1.1;
  option subnet-mask 255.255.255.0;
  default-lease-time 600;
  max-lease-time 7200;
  ddns-update-style none;
  subnet 10.10.10.0 netmask 255.255.255.0 {
    range 10.10.10.2 10.10.10.10;
    option routers 10.10.10.1;
    option subnet-mask 255.255.255.0;
    option broadcast-address 10.10.10.255;
    next-server 10.10.10.1;
    filename "pxelinux.0";
  }

Logging to /var/log/messages. How to move log away to a separate file:

  https://bugs.contribs.org/show_bug.cgi?id=2408

When a DHCP request is made from the Intel PXE boot ROM on the NIC, there are additional parameters you can tell it besides just an IP number. The argument filename "tftp/boot/pxeboot"; tells the PXE boot ROM what filename to do a TFTP request for now that it has an IP address. It's the first piece of code which gets run after the initial DHCP IP negotiation is completed, and the corresponding file is what enables a node to boot*.

------
*) Creating a FreeBSD PXE Network Boot Server
     https://dustingram.com/articles/2009/08/25
       /creating-a-freebsd-pxe-network-boot-server
------

Add to /etc/rc.conf

  dhcpd_enable="YES"
  dhcpd_ifaces="em1"
  dhcpd_flags="-q"                            # command option(s)
  dhcpd_conf="/usr/local/etc/dhcpd.conf"      # configuration file

Start DHCPD:

  $ /usr/local/etc/rc.d/isc-dhcpd start

III. PXE
--------

Put some files to /usr/local/tftp. Download and extract:

  https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.04.zip
  Windows 95b boot disk from http://www.bootdisk.com/bootdisk.htm

Use zip -FF then unzip to extract this.

We'll need following files in tftp folder:

  gpxelinux.0  (move gpxe/gpxelinux.0 to pxelinux.0)
  memdisk (copy from syslinux-4.04/memdisk/memdisk)
  winb95b.IMA (extract from boot95b.exe)
  pxelinux.cfg/default  containing text:

  default memdisk initrd=winb95b.IMA

Now boot W95 machine from just built FreeBSD pxeboot server.

Troubleshoot PXE
................

Winb95b.IMA have to use TFTP-HPA solution.

MenuetOS works in VMWare em0:NAT em1:Host only, NAT is somewhere 192.168.xxx.xxx, port forwarding automatic.

Reactos: A fault has occurred causing a virtual CPU to enter the shutdown state. If this fault had occurred outside of a virtual machine, it would have caused the physical machine to restart. The shutdown state can be reached by incorrectly configuring the virtual machine, a bug in the guest operating system, or a problem in VMware Workstation.

SystemRescue: To do..

PART IV. COOKBOOK*0
-------------------

*0) 'Seenelkäik', 2012

    Also, "usually they speak there.." use this postulate to google
    the answer. Transform this to "usually we speak here.." in case
    you are human and Earth is your home planet:)

NOTE: data from i0QA5-Names.txt is used.

01. Space to Newline in sed
...........................

  $ echo Ärda Ääri Ääse Ääsi | sed 's/ /\
  > /g'
  Ärda
  Ääri
  Ääse
  Ääsi

  https://stackoverflow.com/questions/1421478
  /how-do-i-use-a-new-line-replacement-in-a-bsd-sed

Another way:

  echo Ärda Ääri Ääse Ääsi | sed -e 's/ /\'$'\n/g'

  http://nlfiedler.github.io/2010/12/05/newlines-in-sed-on-mac.html

02. Random
..........

  $RANDOM # 0..32767  `expr $RANDOM / 1424`  (0..23)

  ABC=(A B D E G H I J K L M N O P R S T U V Õ Ä Ö Ü)

  ${ABC[`expr $RANDOM / 1424`]}

  | shuf   # shuffle

03. Remove Newline with tr
..........................

  for c in R Õ B A K I D E L Ä T S O N U G V J Ö M P H Ü
  do
    echo $c
  done | sort | tr -d '\n'

  ABCDEFGHIJKLMNOPRSZTUVWÕÄÜ

04. Temporary locale
....................

  $ cat whatamess | LC_COLLATE="et_EE.UTF-8" sort | tr -d '\n'
  ABDEGHIJKLMNOPRSTUVÕÄÖÜ

  inspired by https://gist.github.com/earthgecko/3089509

05. lines from regexa to regexb: sed
....................................

   -n  By default, each line of input is echoed to the standard output
       after all of the commands have been applied to it.  The -n option
       suppresses this behavior.

  $ cat whatamess | sed -n '/Õ/,/A/p'
  Õ
  B
  A

  inspired by

    https://www.cyberciti.biz/faq
    /unix-linux-sed-print-only-matching-lines-command/

06. grep and regex OR
.....................

  $ cat surename | awk '{print $2}' | grep '\(kin\|dev\)$'
  Lebedev
  Sorokin
  Medvedev
  Lukin
  $ cat surename | awk '{print $2}' | grep '\(kin\)\|\(dev\)$'
  Lebedev
  Sorokin
  Medvedev
  Lukin

07. tar and BSD
...............

  $ tar cv -f - i0Q | bzip2 > i0Q.tar.bzip2
  a i0Q
  a i0Q/whatamess
  a i0Q/boys
  a i0Q/girls
  a i0Q/surename
  a i0Q/etc
  a i0Q/etc/profile
  a i0Q/etc/login.conf
  $ ls -l
  total 28
  drwxr-xr-x  3 virtu  virtu    512 Dec 26 18:57 i0Q
  -rw-r--r--  1 virtu  virtu  20767 Dec 26 19:02 i0Q.tar.bzip2

  PS G:\tmp> pscp virtu@192.168.1.226:/usr/home/virtu/i0Q.tar.bzip2 .
  Using keyboard-interactive authentication.
  Password for virtu@darkstar:
  i0Q.tar.bzip2             | 20 kB |  20.3 kB/s | ETA: 00:00:00 | 100%
  PS G:\tmp>

08. TAB character in bash?
..........................

For example:

  echo $string | sed 's/[_]/TAB/g'

Where TAB means the tab key (This works in a shell script not interactively).

  https://stackoverflow.com/questions/6392249
  /how-to-enter-a-tab-char-on-command-line

  | Precede it with Control+V, followed by TAB to suppress the usual   |
  | expansion behavior.                                                |

09. Set TAB size in bash
........................

Once:

  https://www.linuxquestions.org/questions/linux-general-1
  /tab-width-in-bash-how-do-i-set-it-322368/

  $ echo "hello   world" | expand -t 32
  hello                           world

  whatever | expand -t 24,34,52 # etc...

  $ echo -n "b    e" | expand -t 6 | od -x
  0000000      2062    2020    2020    0065
  0000007

Session:

  https://stackoverflow.com/questions/10782699
  /how-to-set-4-space-tab-in-bash

It's your terminal that manages the output. Use the tabs command to change the behavior:

  $ tabs 4

  $ echo -e "a\tb"
  a   b
  $ tabs 8

Note: Default is 8.

10. for..do..done or find?
..........................

  $ cd ~/poirot
  $ for each in '*.srt'; do grep -H 'gratitude' $each; done

  $ find . -name '*.srt' -exec grep -HnA1 'gratitude' {} \;
  ./poirot-3-8.srt:2592:it has the most sincere gratitude
  ./poirot-3-8.srt-2593-of Hercule Poirot.
  ..

11. diff and patch
..................

      .. ihr Vater litt an Angstattacken ..
      oder Schizophrenie?
      Alice. The Darkest Hour, 2018, 25:15

  $ echo 1 2 3 | tr ' ' '\n' > orig; cat orig
  1
  2
  3
  $ cp orig upd; ed upd
  6
  2c
  uuu
  .
  ,p
  1
  uuu
  3
  w
  8
  q
  $ diff orig upd | tee my.patch
  2c2
  < 2
  ---
  > uuu
  $ patch orig -i my.patch -o -
  patching file ppppp (read from orig)
  1
  uuu
  3

12. How to remove a file whose filename begins with a '-'

  https://unix.stackexchange.com/questions/1519
  /how-do-i-delete-a-file-whose-name-begins-with-hyphen-a-k-a-dash-
  or-minus

Use "--" to make rm stop parsing command line options, like this:

  rm -- --help

  '--' indicates the unambiguous end of options. Found in ubuntu bionic, man awk

13. Change default shell

  chsh -s /usr/local/bin/bash root

14. PKG info

  [root@ /home/virtu]# pkg info
  autoconf-2.69_1                Automatically configure source code on many Un*x platforms
  autoconf-wrapper-20131203      Wrapper script for GNU autoconf
  autoconf213-2.13.000227_6      Automatically configure source code on many Un*x platforms (legacy 2.13)
  autogen-5.18.12                Tool designed to simplify the creation and maintenance of programs
  automake-1.15.1                GNU Standards-compliant Makefile generator
  automake-wrapper-20131203      Wrapper script for GNU automake
  autotools-20130627             Autotools meta-port
  avahi-app-0.6.31_5             Service discovery on a local network
  bash-4.4.12_3                  GNU Project's Bourne Again SHell
  binutils-2.28,1                GNU binary tools
  boehm-gc-7.6.0                 Garbage collection and memory leak detection for C and C++
  boehm-gc-threaded-7.6.0_1      Garbage collection and memory leak detection for C and C++
  ca_root_nss-3.35               Root certificate bundle from the Mozilla Project
  cairo-1.14.8_1,2               Vector graphics library with cross-device output support
  cups-2.2.6                     Common UNIX Printing System
  curl-7.58.0                    Command line tool and library for transferring data with URLs
  cvsps-2.1_2                    Create patchset information from CVS
  damageproto-1.2.1              Damage extension headers
  dbus-1.10.16_1                 Message bus system for inter-application communication
  dbus-glib-0.108                GLib bindings for the D-BUS messaging system
  dejavu-2.37                    Bitstream Vera Fonts clone with a wider range of characters
  dialog4ports-0.1.6             Console Interface to configure ports
  doxygen-1.8.13_1,2             Documentation system for C, C++, and other languages
  dri2proto-2.8                  DRI2 prototype headers
  encodings-1.0.4_3,1            X.Org Encoding fonts
  expat-2.2.5                    XML 1.0 parser written in C
  fixesproto-5.0                 Fixes extension headers
  font-bh-ttf-1.0.3_3            X.Org Bigelow & Holmes TTF font
  font-misc-ethiopic-1.0.3_3     X.Org miscellaneous Ethiopic font
  font-misc-meltho-1.0.3_3       X.Org miscellaneous Meltho font
  font-util-1.3.1                Create an index of X font files in a directory
  fontconfig-2.12.1,1            XML-based font configuration API for X Windows
  freebsd-tftp-1.0               Upcoming replacement for tftp(1) and tftpd(8)
  freetype2-2.8_1                Free and portable TrueType font rendering engine
  gcc-6                          Meta-port for the default version of the GNU Compiler Collection
  gcc-ecj-4.5                    Eclipse Java Compiler used to build GCC Java
  gcc6-6.4.0_3                   GNU Compiler Collection 6
  gdbm-1.13_1                    GNU database manager
  gettext-0.19.8.1               GNU gettext meta package
  gettext-runtime-0.19.8.1_1     GNU gettext runtime libraries and programs
  gettext-tools-0.19.8.1         GNU gettext development and translation tools
  ghostscript9-agpl-base-9.16_5  Ghostscript 9.x PostScript interpreter, base part
  giflib-5.1.4                   Tools and library routines for working with GIF images
  git-2.15.1                     Distributed source code management tool
  glib-2.50.3_1,1                Some useful routines of C programming (current stable version)
  glproto-1.4.17                 GLX extension headers
  gmake-4.2.1_1                  GNU version of 'make' utility
  gmp-6.1.2                      Free library for arbitrary precision arithmetic
  gnome_subr-1.0                 Common startup and shutdown subroutines used by GNOME scripts
  gnutls-3.5.16                  GNU Transport Layer Security library
  gobject-introspection-1.50.0,1 Generate interface introspection data for GObject libraries
  graphite2-1.3.10               Rendering capabilities for complex non-Roman writing systems
  graphviz-2.40.1_2              Graph Visualization Software from AT&T and Bell Labs
  gsfonts-8.11_8                 Standard Fonts for Ghostscript
  guile2-2.0.14_1                GNU Ubiquitous Intelligent Language for Extension
  harfbuzz-1.7.4                 OpenType text shaping engine
  harfbuzz-icu-1.7.4             Harfbuzz ICU support
  icu-60.2_1,1                   International Components for Unicode (from IBM)
  indexinfo-0.3.1                Utility to regenerate the GNU info page index
  isc-dhcp43-server-4.3.5        ISC Dynamic Host Configuration Protocol server
  jbig2dec-0.14                  Decoder implementation of the JBIG2 image compression format
  jbigkit-2.1_1                  Lossless compression for bi-level images such as scanned pages, faxes
  jpeg-turbo-1.5.3               SIMD-accelerated JPEG codec which replaces libjpeg
  kbproto-1.0.7                  KB extension headers
  lcms2-2.9                      Accurate, fast, and small-footprint color management engine
  libICE-1.0.9_1,1               Inter Client Exchange library for X11
  libSM-1.2.2_3,1                Session Management library for X11
  libX11-1.6.5,1                 X11 library
  libXau-1.0.8_3                 Authentication Protocol library for X11
  libXaw-1.0.13,2                X Athena Widgets library
  libXdamage-1.1.4_3             X Damage extension library
  libXdmcp-1.1.2                 X Display Manager Control Protocol library
  libXext-1.3.3_1,1              X11 Extension library
  libXfixes-5.0.3                X Fixes extension library
  libXft-2.3.2_1                 Client-sided font API for X applications
  libXmu-1.1.2_3,1               X Miscellaneous Utilities libraries
  libXp-1.0.3,1                  X print library
  libXpm-3.5.12                  X Pixmap library
  libXrender-0.9.10              X Render extension library
  libXt-1.1.5,1                  X Toolkit library
  libXxf86vm-1.1.4_1             X Vidmode Extension
  libdaemon-0.14_1               Lightweight C library that eases the writing of UNIX daemons
  libdrm-2.4.89,1                Userspace interface to kernel Direct Rendering Module services
  libedit-3.1.20170329_2,1       Command line editor library
  libffi-3.2.1_2                 Foreign Function Interface
  libfontenc-1.1.3_1             The fontenc Library
  libgd-2.2.4_1,1                Graphics library for fast creation of images
  libiconv-1.14_11               Character set conversion library
  libidn-1.33_1                  Internationalized Domain Names command line tool
  libidn2-2.0.4                  Implementation of IDNA2008 internationalized domain names
  libltdl-2.4.6                  System independent dlopen wrapper
  libnghttp2-1.29.0              HTTP/2.0 C Library
  libpaper-1.1.24.4              Library providing routines for paper size management
  libpciaccess-0.13.5            Generic PCI access library
  libpotrace-1.12                Library for transforming bitmaps into vector graphics
  libpthread-stubs-0.4           This library provides weak aliases for pthread functions
  libssh2-1.8.0,3                Library implementing the SSH2 protocol
  libtasn1-4.12                  ASN.1 structure parser library
  libtool-2.4.6                  Generic shared library support script
  libunistring-0.9.8             Unicode string library
  libunwind-20170113_1           Generic stack unwinding library
  libxcb-1.12_2                  The X protocol C-language Binding (XCB) library
  libxml2-2.9.7                  XML parser library for GNOME
  libxshmfence-1.2_2             Shared memory 'SyncFence' synchronization primitive
  m4-1.4.18,1                    GNU M4
  mesa-libs-17.3.1               OpenGL libraries that support GLX and EGL clients
  mkfontdir-1.0.7                Create an index of X font files in a directory
  mkfontscale-1.1.2              Creates an index of scalable font files for X
  mpc-1.0.3                      Library of complex numbers with arbitrarily high precision
  mpfr-3.1.6                     Library for multiple-precision floating-point computations
  ncurses-6.0.0s20171223_1       Library for terminal-independent, full-screen output
  nettle-3.4                     Low-level cryptographic library
  nspr-4.18                      Platform-neutral API for system level and libc like functions
  nss-3.35                       Libraries to support development of security-enabled applications
  openjpeg-2.3.0                 Open-source JPEG 2000 codec
  openjpeg15-1.5.2_1             Open-source JPEG 2000 codec
  p11-kit-0.23.9                 Library for loading and enumerating of PKCS#11 modules
  p5-Authen-SASL-2.16_1          Perl5 module for SASL authentication
  p5-Digest-HMAC-1.03_1          Perl5 interface to HMAC Message-Digest Algorithms
  p5-Error-0.17025               Error/exception handling in object-oriented programming style
  p5-GSSAPI-0.28_1               Perl extension providing access to the GSSAPIv2 library
  pango-1.40.6                   Open-source framework for the layout and rendering of i18n text
  pciids-20171206                Database of all known IDs used in PCI devices
  pcre-8.40_1                    Perl Compatible Regular Expressions library
  perl5-5.24.3                   Practical Extraction and Report Language
  pixman-0.34.0                  Low-level pixel manipulation library
  pkg-1.10.3_1                   Package manager
  pkgconf-1.3.7,1                Utility to help to configure compiler and linker flags
  png-1.6.34                     Library for manipulating PNG images
  poppler-0.57.0                 PDF rendering library
  poppler-data-0.4.8             Poppler encoding data
  printproto-1.0.5               Print extension headers
  psutils-1.17_5                 Utilities for manipulating PostScript documents
  python2-2_3                    The "meta-port" for version 2 of the Python interpreter
  python27-2.7.14_1              Interpreted object-oriented programming language
  readline-7.0.3_1               Library for editing command lines as they are typed
  renderproto-0.11.1             RenderProto protocol headers
  sqlite3-3.21.0_1               SQL database engine in a C library
  svgalib-1.4.3_7                Low level console graphics library
  t1lib-5.1.2_4,1                Type 1 font rasterization library for Unix/X11
  teckit-2.5.7                   Toolkit for converting data between 8-bit legacy encodings and Unicode
  tex-basic-engines-20150521     Basic TeX Engines
  tex-dvipsk-5.995_1             Convert a TeX DVI file to PostScript
  tex-formats-20150521_2         Formats for basic TeX engines
  tex-kpathsea-6.2.1_1           Path searching library for TeX
  tex-ptexenc-1.3.3_2            Library for Japanese pTeX and its tools
  tex-web2c-20150521_1           TeX implementation translating WEB to C
  texlive-base-20150521_23       TeX Live Typesetting System, base binaries
  texlive-texmf-20150523_4       TeX Live Typesetting System, texmf Tree
  texlive-tlmgr-20150523_2       TeXLive manager modules
  tiff-4.0.9_1                   Tools and library routines for working with TIFF images
  tpm-emulator-0.7.4_2           Trusted Platform Module (TPM) emulator
  trousers-0.3.14_2              Open-source TCG Software Stack
  webp-0.6.1                     Google WebP image format conversion tool
  wget-1.19.2                    Retrieve files from the Net via HTTP(S) and FTP
  xcb-util-0.4.0_2,1             Module with libxcb/libX11 extension/replacement libraries
  xcb-util-renderutil-0.3.9_1    Convenience functions for the Render extension
  xextproto-7.3.0                XExt extension headers
  xf86vidmodeproto-2.3.1         XFree86-VidModeExtension extension headers
  xorg-fonts-truetype-7.7_1      X.Org TrueType fonts
  xpdfopen-0.86                  Command line utility for PDF viewers
  xproto-7.0.31                  X11 protocol headers
  zziplib-0.13.62_2              Library to provide transparent read access to zipped files

  # pkg info | grep dox
  doxygen-1.8.13_1,2             Documentation system for C, C++, and other languages

  # pkg remove doxygen  # 25MB
  # pkg autoremove      # 2GB
  # dd if=/dev/zero of=biig; rm biig

Links (found here):

  1. https://www.chrisnewland.com/find-and-replace-with-nano-47

  2. https://askubuntu.com/questions/73444
     /how-to-show-line-numbering-in-nano-when-opening-a-file

  3. https://stackoverflow.com/questions/7745535
     /regex-based-matching-and-sustitution-with-nano

  4. https://askubuntu.com/questions/332961/undo-functionality-in-nano

  5. https://unix.stackexchange.com/questions/122795
     /long-line-wrapping-in-nano

  6. https://forums.freebsd.org/threads/55627/

  7. https://serverfault.com/questions/228510
     /how-to-change-default-shell-in-freebsd

IV. MAKE USE OF FREEBSD BOX
---------------------------

1. BUILD NAWK WITH UNICODE SUPPORT
..................................

Build:

Install dependencies:

  # pkg install wget flex bison ncurses

Add missing header as /usr/include/utmp.h (found here:)

  http://www.retro11.de/ouxr/211bsd/usr/include/utmp.h.html

Code:

  #ifndef _UTMP_H_
  #define _UTMP_H_

  #define _PATH_UTMP  "/var/run/utmp"
  #define _PATH_WTMP  "/usr/adm/wtmp"

  #define UT_NAMESIZE 15
  #define UT_LINESIZE 8
  #define UT_HOSTSIZE 16
  struct utmp {
      char    ut_line[UT_LINESIZE];
      char    ut_name[UT_NAMESIZE];
      char    ut_host[UT_HOSTSIZE];
      long    ut_time;
  };

  #endif

Build libraries:

  $ wget -c --no-check-certificate https://freefr.dl.sourceforge.net
      /project/heirloom/heirloom/070715/heirloom-070715.tar.bz2
  $ tar xf heirloom-070715.tar.bz2

  $ cd /usr/home/virtu/heirloom-070715
  $ make
  $ cd nawk

Patch nawk with diff below and build it:

  $ diff main.c.orig main.c
  69c69
  < int main(int argc, unsigned char *argv[], unsigned char *envp[])
  ---
  > int main(int argc, char *argv[], char *envp[])
  $ make

Use:

  $ ./awk 'BEGIN {if (match("One Üks Ein"," [a-zÜ]+ ")) print RLENGTH}'
  5

2. LOOM (RETRO DOS GAME) IN A BROWSER
.....................................

  (todo...)
  Getting Started on FreeBSD

  https://www.ibm.com/developerworks/community/blogs/karsten/entry
  /emscripten_running_your_c_c_programs_web_pages?lang=en

  pkg install node www/npm python cmake
  wget -c --no-check-certificate https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
  tar xf emsdk-portable.tar.gz
  cd emsdk-portable
  ./emsdk update
  ./emsdk install latest

  CTRL-F9     Kill (close) DOSBox

3. VISUAL PYTHON AND JUPYTER NOTEBOOK
.....................................

  (todo...)

4. PROCESSING TEXT FILES
........................

Source:

  http://nimi.ee/tudrukute-nimed
  http://nimi.ee/poiste-nimed

  $ cat boys | grep -v '^.\?$' | LC_COLLATE="et_EE.UTF-8" sort

  $ cat girls | grep -v '^.\?$' | LC_COLLATE="et_EE.UTF-8" sort

  $ cat girls | grep -v '^.\?$' | sed 's/ \+/\'$'\n/g' | wc -l
  2326

  $ cat boys | grep -v '^.\?$' | sed 's/ \+/\'$'\n/g' | wc -l
  2518

  $ cat surename | awk '{print $2 " "  $3}' | sed 's/[0-9]//g' | \
    grep "[^ ] [^ ]" | grep -v 'va$' | grep '[^aeiou] .\+a$'
  Nikitin Nikitina
  Kuzmin Kuzmina
  Iljin Iljina
  Sorokin Sorokina
  Kalinin Kalinina
  Fomin Fomina
  Voronin Voronina
  Kostin Kostina
  Lukin Lukina

Concusion:
  male   ^name(v|n)$

  $ cat surename | awk '{print $2 " "  $3}' | sed 's/[0-9]//g' | \
    grep "[^ ] [^ ]" | wc -l
       125

draft.. HINTS
.............

  while : ; do
    actions
    [[ current_time <= $cutoff ]] || break
  done

TIPS
....

create user, invite to group wheel

  # adduser

Use chpass to change user login settings

  /etc/rc.conf

To enable sshd in /etc/rc.conf

  sshd_enable="YES"

  /etc/rc.d/sshd start

Use following to add created user (virtu) to group wheel
(to make work su, sudo)

  # pw user mod virtu -G wheel
  # groups virtu

To activate network in

  # cat /etc/rc.conf
  ..
  ifconfig_em0="DHCP"
  ..

  # dhclient em0

Bootstrap pkg:

  # pkg
  # pkg2ng

Force pkg to reinstall

  https://forums.freebsd.org/threads/59313/

  # pkg-static bootstrap -f

To install gnome, firefox, gedit

  pkg install gnome-desktop gnome-terminal gdm xorg xf86-video-fbdev
  pkg install sudo firefox gedit

Add the following lines in /etc/rc.conf

  gnome_enable="YES"
  moused_enable="YES"
  dbus_enable="YES"
  hald_enable="YES"

To add guest additions to virtual box

  # pkg install virtualbox-ose-additions

Add the following lines in /etc/rc.conf

  vboxguest_enable="YES"
  vboxservice_enable="YES"

Now /etc/rc.conf looks like:

  sshd_enable="YES"
  ifconfig_em0="DHCP"
  gnome_enable="YES"
  moused_enable="YES"
  dbus_enable="YES"
  hald_enable="YES"
  vboxguest_enable="YES"
  vboxservice_enable="YES"

Now reboot, Gnome login starts automatically.

------------------------------------------------------------------------

Links
-----

BSD Book

  1. https://www.freebsd.org/doc/handbook/

Draft i37JK
-----------

http://www.andrewblog.ru
/freebsd-11-0-release-nastrojka-tftp-servera-tftpd-hpa/

That ISO on boot tries to find itself on a cd9660 device. It is clear you cannot PXE boot FreeBSD-10.1-RELEASE-amd64-uefi-bootonly.iso using a memdisk approach.

https://stackoverflow.com/questions/31850523
/pxelinux-pxe-freebsd-install

http://xgu.ru/wiki/Бездисковая_загрузка_FreeBSD_с_помощью_PXE

http://wr-mem.livejournal.com/2660.html

http://greendail.ru/node
     /server-setevoy-zagruzki-pxe-na-freebsd-ch1-nastroyka-servera

Логи этого tftp сервера можно будет смотреть в  /var/log/xferlog

https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.04.zip
