# Advocacy just for fun -- little (?) things to love about FreeBSD



## zirias@ (Aug 26, 2016)

It's that time again that I discovered some _gems_ in this system I'm just about to start to really use (as opposed to: experiment with) and I thought it might be fun to collect things about FreeBSD you really love 

This time:

the /usr/src/release subtree with advanced make magic that just allowed me to get the base I carefully configured and tested -- on an USB stick to install my new server with. Just type `make memstick`. Amazing.
little useful "unixy" things in the base system. Quite some time ago, my old (XEN/Linux) server's NIC froze, leaving only the serial console. I was shocked because I had only an USB stick with a -CURRENT installer at hands and was used to having to install some kind of terminal application -- well not so with FreeBSD, that's what cu(1) is for. Next nice surprise today: my base system doesn't include vi, because I install editors/vim anyways, everywhere. Too bad the update of my pkg repo for 11.0-RC2 is still running. Nevermind, I managed to edit /etc/rc.conf using ed(1). Ok, using it reminds me of the description of the _pangalactic gargleblaster_ ... nevertheless it got the job done, so great it's there 
Earlier discoveries involve things like -- hey, they use a CI for the whole system with automated testing, great! Or -- who said software mixing _isn't_ possible with a traditional /dev/dsp? And a lot of "well, this design is somewhat elegant and makes sense" -- like the possibility to use a central mouse daemon, or the overall design of the ports with the nice Makefile library. The list probably goes on.

Care to list what you really love about FreeBSD? Of course those are just opinions, but I could imagine to stumble upon further _gems_ myself, reading the replies here!

Regards, Felix


----------



## Phishfry (Aug 26, 2016)

I have switched to the editor in base FreeBSD, `ee`. I used to be lost without editors/nano.
ARM boards have taught me many things including how to do more with less.


----------



## zirias@ (Aug 26, 2016)

Hehe, I disabled ee(1) as well, trying to get a "blueprint" base for my personal needs, because the editor I prefer is, as I mentioned, editors/vim  So it was a very good thing (TM) that at least the ancient ed(1) (it's from the 70s, isn't it?) is _always_ there.

On a side note, about ARM boards -- I still have a "Banana PI" around here, it was a gift 2 years ago and because of building a new house and all the stuff, I didn't have time to play with it so far ... you don't happen to know whether FreeBSD runs fine on it? I think it would make for a nice "surf station" for the guest room


----------



## Phishfry (Aug 26, 2016)

The BPi for a surf station could be tough. No desktop meta-packages or browsers. You can pull off an x11-wm/openbox desktop with www/dillo2 browser. A x11/lxde-meta package exists but fails.


----------



## fossette (Aug 27, 2016)

What I like about FreeBSD?  I like:
https://forums.freebsd.org/

But if I need to be specifically technical, I would say `alias` (does that even count?).

Dominique.


----------



## Phishfry (Aug 27, 2016)

I like how things change with time but not dramatically. Sometimes I chuckle when I look at a man page and its dated 2003 or older.


----------



## zirias@ (Aug 27, 2016)

Phishfry, thanks for the answers, and sorry to hear about your broken banana 

I'll definitely have a look ... what should break building ports like a desktop environment for ARM if the base system is working just fine? Well, I will see, as soon as I find the time 

Good point btw about the slow and steady change, that's just what a stable system should do! I guess it somehow gives you this feeling of reliability you feel comfortable with, and the things I described like nice old UNIX tools always available and the traditional /dev/dsp modernized without breaking the contract -- are just symptoms of that 

Any other points?


----------



## Phishfry (Aug 27, 2016)

security/nss needs patching.
http://portsmon.freebsd.org/portoverview.py?category=security&portname=nss

Here is a link to the fix:
https://forums.freebsd.org/threads/57358/


----------



## Snurg (Aug 27, 2016)

One of the things I like very much at FreeBSD is the `sc` console. Its scrollback buffer which you even can extend via kernel option (my setting is `SC_HISTORY_SIZE=2500` instead of the default `100`) is just awesome.
(Yes I know that some people want `vt` to replace `sc` because `sc` would need some updating for UEFI. But `vt` breaks suspend/resume on many systems and is still extremely buggy and sluggish yet. For example `vt` needs 5 sec for switching consoles due to a completely unnecessary mode reset inbetween.)



Zirias said:


> Next nice surprise today: my base system doesn't include vi, because I install editors/vim anyways, everywhere. Too bad the update of my pkg repo for 11.0-RC2 is still running.



At me it's because FreeBSD contains a true vi (in /usr/bin/vi) unlike most Linuxes. (I hate vim because its colorfulness distracts and annoys me.)
BTW I doubt that your installation does not contain vi. I guess vim installs an alias vi vim or such.


----------



## a6h (Aug 27, 2016)

Snurg said:


> I hate vim because its colorfulness distracts and annoys me.



In command mode:

```
:syntax off
```
or
`~/.vimrc`

```
syntax off
```



Snurg said:


> I guess vim installs an alias vi vim or such.




```
406K: /usr/bin/vi
406K: /usr/bin/nvi
2.5M: /usr/local/bin/vim
```

vi(1): nex/nvi are intended as bug-for-bug compatible replacements for the original Fourth Berkeley Software Distribution (4BSD) ex and vi programs.


----------



## zirias@ (Aug 27, 2016)

Snurg said:


> BTW I doubt that your installation does not contain vi.




```
<root@nexus-freebsd:~>
zsh 387 # grep VI </etc/src.conf
WITHOUT_VI=yes
```
sure thing it doesn't


----------



## Snurg (Aug 27, 2016)

Zirias said:


> ```
> ... /etc/src.conf ...
> ```


Now that is nice! Even more configurability!  +1  
Didn't know of this file.
It is apparently not mentioned at all in the build(8) manpage on versions before FreeBSD 11-RC1 or 12 even though the src.conf(5) manpage says it's there since FreeBSD 7.0.

If I understand the src.conf(5) manpage correctly, some settings seem to be redundant with the kernel configuration file settings (/usr/src/sys/<arch>/conf), while others can be specified only in /etc/src.conf?


----------



## kpa (Aug 27, 2016)

Snurg said:


> Now that is nice! Even more configurability!  +1
> Didn't know of this file.
> It is apparently not mentioned at all in the build(8) manpage on versions before FreeBSD 11-RC1 or12 even though the src.conf(5) manpage says it's there since FreeBSD 7.0.
> 
> If I understand the src.conf(5) manpage correctly, some settings seem to be redundant with the kernel configuration file settings (/usr/src/sys/<arch>/conf), while others can be specified only in /etc/src.conf?



They are not redundant but complementary. The kernel config(5) file is for setting kernel internal settings and selecting which device drivers are included in the monolithic kernel file. The src.conf(5) on the other hand is where you select which parts of the system get built in the first place, for example if you select WITHOUT_ZFS the ZFS modules and the related utilities are not built at all. Same with for example the WITHOUT_PF setting, regardless of what you set in the kernel config file for the PF devices this setting would give you a system without PF (and I think you would get a linker error because of a missing module if you have "device pf" in kernel config but the module isn't built because of WITHOUT_PF).


----------



## Phishfry (Aug 27, 2016)

Sorry to go off topic but I have questions.


Zirias said:


> zsh 387 # grep VI </etc/src.conf


I am trying to learn Unix command prompt. Could you hep me understand this?

zsh = shell (why call up this shell?)
387 = ?
# = ?
grep VI = Search for text string "VI"
</etc/src.conf = ?  I recently learned redirect, This looks similar except angle bracket in other direction.

A rough guess is you are commenting out line 387 from etc/src.conf?


----------



## a6h (Aug 27, 2016)

Phishfry said:


> zsh = shell (why call up this shell?)
> 387 = ?
> # = ?


It's just a shell prompt.


Phishfry said:


> grep VI = Search for text string "VI"


Another style. you can try this one:

```
# grep VI /etc/src.conf
```
Same


----------



## Snurg (Aug 27, 2016)

Phishfry said:


> 387 = ?


This was a secret message.
It made me add "\! " to the beginning of my FreeBSD default csh prompt


----------



## a6h (Aug 27, 2016)

Zirias said:


> Care to list what you really love about FreeBSD?


No show-off, my list is simple:

UFS2
init(8)/rc.d
hier(7), style(9), ports(7), jail(8)
sysctl(8) : System Calls, MIB, "C calling convention"/UNIX convention, parameters/stack.
`fortune freebsd-tips`
`loader_logo="beastie"`
`firewall_enable="YES"`
Defaults: 
sh(1)/csh(1) (bash-free)
clang/llvm
nex(1)/nvi(1)

Junk-free installation (CLI/TUI)
doc, man, lists, wiki, forums, ... so forth and so on.
Newbie/distro-fanboy repellent.
A policy of zero tolerance in forums, ... concerning idiots situation.


----------



## zirias@ (Aug 27, 2016)

Phishfry said:


> zsh = shell (why call up this shell?)


It's not a call, it's just part of the prompt -- the command starts with `grep`.
Reason for using zsh has nothing to do with the particular command: I want a bourne compatible shell, so tcsh is out already, and I like my shell with lots of useful extra features like intelligent auto-completion, mathematical expressions, git integration and so on. bash would be a candidate, but zsh can just do more 



Phishfry said:


> 387 = ?


Well I admit, I'm lazy and used a pre-made prompt .. this one puts the "command count" here since the shell was started. Something I don't need, but it doesn't hurt 



Phishfry said:


> # = ?


This is just the typical "end prompt character" for a privileged shell, while `>` or `$` are often seen for unprivileged shells. Of course you can configure whatever you like, but following the convention here has its benefits.



Phishfry said:


> </etc/src.conf = ?  I recently learned redirect, This looks similar except angle bracket in other direction.


`<` is indeed a redirection, it redirects stdin (the input). So with this command, the shell reads the file and feeds it to the standard input of grep. Of course, grep can also read a file itself ... but there _are_ tools around that can _only_ process data on standard input, that's why I got used to use shell redirects and pipes often ...


----------



## Phishfry (Aug 27, 2016)

I have found most people here genuinely trying to help anybody who asks. Just don't insult them.

I need to read up on style(9) I had not seen that before.

I had wondered why dmesg.boot and messages reside in different directories and the hier(7) page explained it well.


----------



## a6h (Aug 27, 2016)

Phishfry
Section 7 of man pages is full of surprise:
`# ls /usr/share/man/man7`
Try some of the man pages from this section, e.g.:
c(7), development(7), operator(7), re_format(7)


----------



## zirias@ (Aug 27, 2016)

vigole said:


> style(9)


That's an interesting read, and while some points are a matter of taste, most are just sensible and of course it's always important to agree upon _one_ coding style.

But reading through it, one thing kind of hit me:

```
Use printf(3), not    fputs(3), puts(3), putchar(3), whatever; it is faster
     and usually cleaner, not to mention avoiding stupid bugs.
```
So why is this? Especially, why should printf(3) be faster if no formatting and conversions are needed, and isn't it printf(3) that introduces bad format-string attack bugs when writing e.g. `printf(message);` instead of `printf("%s", message);` while `puts(message);` would be totally fine?

I tend to strongly disagree with just that little part of style(9), but maybe someone can tell me something I've overlooked


----------



## Phishfry (Aug 27, 2016)

I also found a dead link on the hier(7) manpage. Under /boot /dtb section the dtc(1) link is broke/misrouted.


----------



## wblock@ (Aug 27, 2016)

Hm, the dtc(1) page is present on 10.0-release, missing from 10.1-release through 10.3-release, and back again on 11-current.


----------



## a6h (Aug 27, 2016)

Zirias said:


> why should printf(3) be faster if no formatting and conversions are needed,


No idea! It looks like it's been there forever.
/head/share/man/man9/style.9
Revision 12823
Thu Dec 14 10:50:27 1995 UTC (20 years, 8 months ago)
https://svnweb.freebsd.org/base/head/share/man/man9/style.9?revision=12823&view=markup#l326


----------



## Snurg (Aug 27, 2016)

Back to topic...


vigole said:


> No show-off, my list is simple:
> init(8)/rc.d


Hope this stays as it is until there are better, non-cancerous solutions. Two years ago Lennart Poettering demanded better cooperation from the FreeBSD community and this makes me feel really uneasy. (Link in German)


----------



## zirias@ (Aug 29, 2016)

Regarding this thread ... thanks for including the good old nc(1) in the installer image ... another of these invaluable "unixy" tools and just working to restore my pool from an image file on a Linux desktop machine


----------

