Appendix: Implicit Skills
- 4 minutes read - 758 wordsBasic Navigation in the Unix Shell
You’re going to be navigating around (cd
), editing files (vi
), etc. You
need to be able to list files, view files’ content, move directories, copy and
moves files about, etc. You should be able to page output with less
or
more
.
“Home directory” should be a familiar term.
Reading man
Pages
As I mentioned, FreeBSD has an excellent documentation culture and that comes
in the form of manual or man
pages. FreeBSD is descended from the original
Unix developed at AT&&T who gave out their implementations on physical
tape. Given that they were shipping around the globe in the early 1970s,
providing documentation “on-line” was a practical necessity. Thus man
was
born. It’s a program. You can even man man
which has always been amusing. The
man
library is divided into sections:
1. FreeBSD General Commands Manual
2. FreeBSD System Calls Manual
3. FreeBSD Library Functions Manual
4. FreeBSD Kernel Interfaces Manual
5. FreeBSD File Formats Manual
6. FreeBSD Games Manual
7. FreeBSD Miscellaneous Information Manual
8. FreeBSD System Manager's Manual
9. FreeBSD Kernel Developer's Manual
FreeBSD people are forever saying printf(1)
with that (1)
after the
interesting term or function. This might seem obnoxious, but sometimes the same
token has multiple sections. The printf
program appears in both sections 1
and 3. To leave off that identifier leaves the destination as ambiguous.
Install a Package With pkg
Foreshadowing Linux’s apt
and apt-get
, pkg install <packagename>
.
Search with pkg search <package-string>
See the man
page for more.
Privileged and Unprivileged Users
root
versus all the others. Why do they exist? Which should you log in as
(not root
). Why? This is covered elsewhere, but the installer will have you
create a privileged and non-privileged account and you should have some model
for why.
FreeBSD does not come with sudo
as is common in Linux (sudo
is a GNU
program). For the sake of this guide, and for my philosophical purity of
keeping things BSD as much as possible, my solution was simply to log in as
root. This has risks but I started using virtual terminal 9 (Alt + F9) for user
stuff and leaving terminal 0 for root login.
You can install sudo
. My finger memory definitely reached for it, often.
But once I got the system setup, it wasn’t something I needed often. Also,
during installation, we added our unprivileged user to the wheel
group. Doing
so on a BSD system gives that user the ability, through their group membership,
to edit most system file – so one theoretically needs sudo
less.
File ownership; permissions
Many resources explain this.
sysctl
sysctl
is a way for changing kernel behavior without (re-)building the
kernel. So it’s very low-level configuration that can be changed from the
terminal i.e. no reboot required to see effect.
Here’s the man page:
The sysctl utility retrieves kernel state and allows processes with ap- propriate privilege to set kernel state. The state to be retrieved or set is described using a “Management Information Base” (“MIB”) style name, described as a dotted set of components.
As suggested, these values can also be read. Dump them all with sysctl -a
.
sysctl
changes are volatile. That is, they don’t stick unless you put them in
disk.
Other Helpful Tools
Since we’re focusing on a focus mode laptop a lot of desktop niceties that we
don’t want to install for fear of avoiding bloat or distraction won’t be
around. Make sure that you can do some searching (grep
) and some output
mangling for use as input (|
).
|
(“Pipe”)grep
Commands for…
Power Management
acpciconf -s3
: Put the system in “S3” (industry specification) suspension. This will help you simulate “shutting the lid” without wearing out your computer’s hinge
System Information
- Boot log can be read via
dmesg
or interacting with/var/log/messages
Mounting a USB Drive
If you need help with a large bug, you may need to get data to another machine for submitting to forum, etc.
# camcontrol devlist # this is for the CAM subsystem: it manages hardware
# mount -t msdosfs /dev/da0s1 /mnt # do a basic mount
^
– to determine the filesystem type first, use file -s /dev/da0s1
Keep in mind, that in the case of a USB drive (typical), you have to mount a
given slice, in specific, the first slice: that’s the s1
at the end. If you
do lsblk
(“list block (storage) devices”)), you’ll see /dev/da0
.
It’s typical in BSD related things to refer to the physical partitions on a
storage medium with s[1-n]