diff --git a/documentation/content/en/books/handbook/basics/_index.adoc b/documentation/content/en/books/handbook/basics/_index.adoc --- a/documentation/content/en/books/handbook/basics/_index.adoc +++ b/documentation/content/en/books/handbook/basics/_index.adoc @@ -84,12 +84,12 @@ The first line contains some information about the system. The `amd64` indicates that the system in this example is running a 64-bit version of FreeBSD. -The hostname is `pc3.example.org`, and [.filename]#ttyv0# indicates that this is the "system console". +The hostname is `pc3.example.org`, and `ttyv0` indicates that this is the "system console". The second line is the login prompt. Since FreeBSD is a multiuser system, it needs some way to distinguish between different users. This is accomplished by requiring every user to log into the system before gaining access to the programs on the system. -Every user has a unique name "username" and a personal "password". +Every user has a unique "username" and a personal "password". To log into the system console, type the username that was configured during system installation, as described in crossref:bsdinstall[bsdinstall-addusers,Add Users], and press kbd:[Enter]. Then enter the password associated with the username and press kbd:[Enter]. @@ -111,7 +111,7 @@ This essentially provides the command line equivalent of having several windows open at the same time in a graphical environment. The key combinations kbd:[Alt+F1] through kbd:[Alt+F8] have been reserved by FreeBSD for switching between virtual consoles. -Use kbd:[Alt+F1] to switch to the system console ([.filename]#ttyv0#), kbd:[Alt+F2] to access the first virtual console ([.filename]#ttyv1#), kbd:[Alt+F3] to access the second virtual console ([.filename]#ttyv2#), and so on. +Use kbd:[Alt+F1] to switch to the system console (`ttyv0`), kbd:[Alt+F2] to access the first virtual console (`ttyv1`), kbd:[Alt+F3] to access the second virtual console (`ttyv2`), and so on. When using Xorg as a graphical console, the combination becomes kbd:[Ctrl+Alt+F1] to return to a text-based virtual console. When switching from one console to the next, FreeBSD manages the screen output. @@ -120,7 +120,7 @@ Refer to man:kbdcontrol[1], man:vidcontrol[1], man:atkbd[4], man:syscons[4], and man:vt[4] for a more technical description of the FreeBSD console and its keyboard drivers. -In FreeBSD, the number of available virtual consoles is configured in this section of [.filename]#/etc/ttys#: +In FreeBSD, the number of available virtual consoles is configured in this section of `/etc/ttys`: [.programlisting] .... @@ -139,9 +139,9 @@ .... To disable a virtual console, put a comment symbol (`+#+`) at the beginning of the line representing that virtual console. -For example, to reduce the number of available virtual consoles from eight to four, put a `+#+` in front of the last four lines representing virtual consoles [.filename]#ttyv5# through [.filename]#ttyv8#. -_Do not_ comment out the line for the system console [.filename]#ttyv0#. -Note that the last virtual console ([.filename]#ttyv8#) is used to access the graphical environment if Xorg has been installed and configured as described in crossref:x11[x11,The X Window System]. +For example, to reduce the number of available virtual consoles from eight to four, put a `+#+` in front of the last four lines representing virtual consoles `ttyv5` through `ttyv8`. +_Do not_ comment out the line for the system console `ttyv0`. +Note that the last virtual console (`ttyv8`) is used to access the graphical environment if Xorg has been installed and configured as described in crossref:x11[x11,The X Window System]. For a detailed description of every column in this file and the available options for the virtual consoles, refer to man:ttys[5]. @@ -155,7 +155,7 @@ However, full `root` access to the system is available, and by default, the `root` password is not needed. For these reasons, physical access to the keyboard is needed to boot into this mode and determining who has physical access to the keyboard is something to consider when securing a FreeBSD system. -The settings which control single user mode are found in this section of [.filename]#/etc/ttys#: +The settings which control single user mode are found in this section of `/etc/ttys`: [.programlisting] .... @@ -203,7 +203,7 @@ # vidcontrol MODE_279 .... -If the new video mode is acceptable, it can be permanently set on boot by adding it to [.filename]#/etc/rc.conf#: +If the new video mode is acceptable, it can be permanently set on boot by adding it to `/etc/rc.conf`: [.programlisting] .... @@ -239,12 +239,6 @@ Examples of system accounts are `daemon`, `operator`, `bind`, `news`, and `www`. -[WARNING] -==== - -Care must be taken when using the operator group, as unintended superuser-like access privileges may be granted, including but not limited to shutdown, reboot, and access to all items in [.filename]#/dev# in the group. -==== - `nobody` is the generic unprivileged system account. However, the more services that use `nobody`, the more files and processes that user will become associated with, and hence the more privileged that user becomes. @@ -299,7 +293,7 @@ Home directory:: The home directory is the full path to a directory on the system. This is the user's starting directory when the user logs in. -A common convention is to put all user home directories under [.filename]#/home/username# or [.filename]#/usr/home/username#. +A common convention is to put all user home directories under `/home/username` or `/usr/home/username`. Each user stores their personal files and subdirectories in their own home directory. User shell:: @@ -356,7 +350,7 @@ [[users-modifying-utilities]] .Utilities for Managing User Accounts -[cols="1,1", frame="none", options="header"] +[cols="25h,~"] |=== | Command | Summary @@ -375,14 +369,17 @@ |man:pw[8] |A powerful and flexible tool for modifying all aspects of user accounts. + +|man:bsdconfig[8] +|A system configuration utility with account management support. |=== [[users-adduser]] -==== `adduser` +==== Adding a user The recommended program for adding new users is man:adduser[8]. -When a new user is added, this program automatically updates [.filename]#/etc/passwd# and [.filename]#/etc/group#. -It also creates a home directory for the new user, copies in the default configuration files from [.filename]#/usr/share/skel#, and can optionally mail the new user a welcome message. +When a new user is added, this program automatically updates `/etc/passwd` and `/etc/group`. +It also creates a home directory for the new user, copies in the default configuration files from `/usr/share/skel`, and can optionally mail the new user a welcome message. This utility must be run as the superuser. The man:adduser[8] utility is interactive and walks through the steps for creating a new user account. @@ -425,7 +422,6 @@ adduser: INFO: Successfully added (jru) to the user database. Add another user? (yes/no): no Goodbye! -# .... ==== @@ -435,20 +431,23 @@ ==== [[users-rmuser]] -==== `rmuser` +==== Removing a user To completely remove a user from the system, run man:rmuser[8] as the superuser. This command performs the following steps: [.procedure] +==== . Removes the user's man:crontab[1] entry, if one exists. . Removes any man:at[1] jobs belonging to the user. -. Kills all processes owned by the user. +. Sends a SIGKILL signal to all processes owned by the user. . Removes the user from the system's local password file. -. Optionally removes the user's home directory, if it is owned by the user. -. Removes the incoming mail files belonging to the user from [.filename]#/var/mail#. -. Removes all files owned by the user from temporary file storage areas such as [.filename]#/tmp#. -. Finally, removes the username from all groups to which it belongs in [.filename]#/etc/group#. If a group becomes empty and the group name is the same as the username, the group is removed. This complements the per-user unique groups created by man:adduser[8]. +. Removes the user's home directory (if it is owned by the user), including handling of symbolic links in the path to the actual home directory. +. Removes the incoming mail files belonging to the user from `/var/mail`. +. Removes all files owned by the user from `/tmp`, `/var/tmp`, and `/var/tmp/vi.recover`. +. Removes the username from all groups to which it belongs in `/etc/group`. (If a group becomes empty and the group name is the same as the username, the group is removed; this complements man:adduser[8]'s per-user unique groups.) +. Removes all message queues, shared memory segments and semaphores owned by the user. +==== man:rmuser[8] cannot be used to remove superuser accounts since that is almost always an indication of massive destruction. @@ -465,12 +464,11 @@ Is this the entry you wish to remove? y Remove user's home directory (/home/jru)? y Removing user (jru): mailspool home passwd. -# .... ==== [[users-chpass]] -==== `chpass` +==== Change user information Any user can use man:chpass[1] to change their default shell and personal information associated with their user account. The superuser can use this utility to change additional account information for any user. @@ -535,7 +533,7 @@ ==== [[users-passwd]] -==== `passwd` +==== Change user password Any user can easily change their password using man:passwd[1]. To prevent accidental or unauthorized changes, this command will prompt for the user's original password before a new password can be set: @@ -579,7 +577,7 @@ ==== [[users-pw]] -==== `pw` +==== Create, remove, modify and display system users and groups The man:pw[8] utility can create, remove, modify, and display users and groups. It functions as a front end to the system user and group files. @@ -592,15 +590,20 @@ In FreeBSD, the kernel uses the UID of a process, and the list of groups it belongs to, to determine what the process is allowed to do. Most of the time, the GID of a user or process usually means the first group in the list. -The group name to GID mapping is listed in [.filename]#/etc/group#. +The group name to GID mapping is listed in `/etc/group`. This is a plain text file with four colon-delimited fields. The first field is the group name, the second is the encrypted password, the third the GID, and the fourth the comma-delimited list of members. For a more complete description of the syntax, refer to man:group[5]. -The superuser can modify [.filename]#/etc/group# using a text editor. +The superuser can modify `/etc/group` using a text editor, although editing the group file using man:vigr[8] is preferred because it can catch some common mistakes. Alternatively, man:pw[8] can be used to add and edit groups. For example, to add a group called `teamtwo` and then confirm that it exists: +[WARNING] +==== +Care must be taken when using the operator group, as unintended superuser-like access privileges may be granted, including but not limited to shutdown, reboot, and access to all items in `/dev` in the group. +==== + .Adding a Group Using man:pw[8] [example] ==== @@ -630,7 +633,7 @@ The argument to `-M` is a comma-delimited list of users to be added to a new (empty) group or to replace the members of an existing group. To the user, this group membership is different from (and in addition to) the user's primary group listed in the password file. This means that the user will not show up as a member when using `groupshow` with man:pw[8], but will show up when the information is queried via man:id[1] or a similar tool. -When man:pw[8] is used to add a user to a group, it only manipulates [.filename]#/etc/group# and does not attempt to read additional data from [.filename]#/etc/passwd#. +When man:pw[8] is used to add a user to a group, it only manipulates `/etc/group` and does not attempt to read additional data from `/etc/passwd`. .Adding a New Member to a Group Using man:pw[8] [example] @@ -658,7 +661,7 @@ In this example, `jru` is a member of the groups `jru` and `teamtwo`. -For more information about this command and the format of [.filename]#/etc/group#, refer to man:pw[8] and man:group[5]. +For more information about this command and the format of `/etc/group`, refer to man:pw[8] and man:group[5]. [[permissions]] == Permissions @@ -730,7 +733,7 @@ -rw-r--r-- 1 root wheel 7680 Sep 5 12:31 email.txt .... -The first (leftmost) character in the first column indicates whether this file is a regular file, a directory, a special character device, a socket, or any other special pseudo-file device. +Focusing on the line for `myfile`, the `(leftmost)` first character indicates whether this file is a regular file, a directory, a special character device, a socket, or any other special pseudo-file device. In this example, the `-` indicates a regular file. The next three characters, `rw-` in this example, give the permissions for the owner of the file. The next three characters, `r--`, give the permissions for the group that the file belongs to. @@ -740,7 +743,7 @@ According to the table above, the permissions for this file would be `644`, where each digit represents the three parts of the file's permission. How does the system control permissions on devices? FreeBSD treats most hardware devices as a file that programs can open, read, and write data to. -These special device files are stored in [.filename]#/dev/#. +These special device files are stored in `/dev/`. Directories are also treated as files. They have read, write, and execute permissions. @@ -816,7 +819,7 @@ |=== These values are used with man:chmod[1], but with letters instead of numbers. -For example, the following command would block other users from accessing _FILE_: +For example, the following command would block both members of the group associated with _FILE_ and all other users from accessing _FILE_: [source,shell] .... @@ -838,7 +841,7 @@ With file flags, even `root` can be prevented from removing or altering files. File flags are modified using man:chflags[1]. -For example, to enable the system undeletable flag on the file [.filename]#file1#, issue the following command: +For example, to enable the system undeletable flag on the file `file1`, issue the following command: [source,shell] .... @@ -868,7 +871,7 @@ In other cases, the file owner may set its file flags. Refer to man:chflags[1] and man:chflags[2] for more information. -=== The `setuid`, `setgid`, and `sticky` Permissions +=== The setuid, setgid, and sticky Permissions Other than the permissions already discussed, there are three other specific settings that all administrators should know about. They are the `setuid`, `setgid`, and `sticky` permissions. @@ -882,14 +885,21 @@ However, in order to update the password database, the command runs as the effective ID of the `root` user. This allows users to change their passwords without seeing a `Permission Denied` error. -The setuid permission may be set by prefixing a permission set with the number four (4) as shown in the following example: +The setuid permission may be added symbolically by adding the `s` permission for the user as in the following example: + +[source,shell] +.... +# chmod u+s suidexample.sh +.... + +The setuid permission may also be set by prefixing a permission set with the number four (4) as shown in the following example: [source,shell] .... # chmod 4755 suidexample.sh .... -The permissions on [.filename]#suidexample.sh# now look like the following: +The permissions on `suidexample.sh` now look like the following: [.programlisting] .... @@ -935,7 +945,14 @@ The `setgid` permission performs the same function as the `setuid` permission; except that it alters the group settings. When an application or utility executes with this setting, it will be granted the permissions based on the group that owns the file, not the user who started the process. -To set the `setgid` permission on a file, provide man:chmod[1] with a leading two (2): +To set the `setgid` permission on a file symbolically, add the `s` permission for the group with man:chmod[1]: + +[source,shell] +.... +# chmod g+s sgidexample.sh +.... + +Alternatively, provide man:chmod[1] with a leading two (2): [source,shell] .... @@ -959,8 +976,15 @@ The third special permission, the `sticky bit`, can strengthen the security of a system. When the `sticky bit` is set on a directory, it allows file deletion only by the file owner. -This is useful to prevent file deletion in public directories, such as [.filename]#/tmp#, by users who do not own the file. -To utilize this permission, prefix the permission set with a one (1): +This is useful to prevent file deletion in public directories, such as `/tmp`, by users who do not own the file. +To utilize this permission, add the `t` mode to the file: + +[source,shell] +.... +# chmod +t /tmp +.... + +Alternatively, prefix the permission set with a one (1): [source,shell] .... @@ -989,129 +1013,123 @@ A mount point is a directory where additional file systems can be grafted onto a parent file system (usually the root file system). This is further described in <>. -Standard mount points include [.filename]#/usr/#, [.filename]#/var/#, [.filename]#/tmp/#, [.filename]#/mnt/#, and [.filename]#/cdrom/#. -These directories are usually referenced to entries in [.filename]#/etc/fstab#. +Standard mount points include `/usr/`, `/var/`, `/tmp/`, `/mnt/`, and `/cdrom/`. +These directories are usually referenced to entries in `/etc/fstab`. This file is a table of various file systems and mount points and is read by the system. -Most of the file systems in [.filename]#/etc/fstab# are mounted automatically at boot time from the script man:rc[8] unless their entry includes `noauto`. +Most of the file systems in `/etc/fstab` are mounted automatically at boot time from the script man:rc[8] unless their entry includes `noauto`. Details can be found in <>. A complete description of the file system hierarchy is available in man:hier[7]. The following table provides a brief overview of the most common directories. -[.informaltable] -[cols="1,1", frame="none", options="header"] +[cols="25h,~"] |=== | Directory | Description -|[.filename]#/# +|`/` |Root directory of the file system. -|[.filename]#/bin/# +|`/bin/` |User utilities fundamental to both single-user and multi-user environments. -|[.filename]#/boot/# +|`/boot/` |Programs and configuration files used during operating system bootstrap. -|[.filename]#/boot/defaults/# +|`/boot/defaults/` |Default boot configuration files. Refer to man:loader.conf[5] for details. -|[.filename]#/dev/# -|Device nodes. Refer to man:intro[4] for details. +|`/dev/` +|Device special files managed by man:devfs[5] -|[.filename]#/etc/# +|`/etc/` |System configuration files and scripts. -|[.filename]#/etc/defaults/# +|`/etc/defaults/` |Default system configuration files. Refer to man:rc[8] for details. -|[.filename]#/etc/mail/# -|Configuration files for mail transport agents such as man:sendmail[8]. - -|[.filename]#/etc/periodic/# +|`/etc/periodic/` |Scripts that run daily, weekly, and monthly, via man:cron[8]. Refer to man:periodic[8] for details. -|[.filename]#/etc/ppp/# -|man:ppp[8] configuration files. +|`/lib/` +|Critical system libraries needed for binaries in `/bin` and `/sbin` -|[.filename]#/mnt/# +|`/libexec/` +|Critical system files + +|`/media/` +|Contains subdirectories to be used as mount points for removable media such as CDs, USB drives, and floppy disks + +|`/mnt/` |Empty directory commonly used by system administrators as a temporary mount point. -|[.filename]#/proc/# +|`/net/` +|Automounted NFS shares; see man:auto_master[5] + +|`/proc/` |Process file system. Refer to man:procfs[5], man:mount_procfs[8] for details. -|[.filename]#/rescue/# +|`/rescue/` |Statically linked programs for emergency recovery as described in man:rescue[8]. -|[.filename]#/root/# +|`/root/` |Home directory for the `root` account. -|[.filename]#/sbin/# +|`/sbin/` |System programs and administration utilities fundamental to both single-user and multi-user environments. -|[.filename]#/tmp/# -|Temporary files which are usually _not_ preserved across a system reboot. A memory-based file system is often mounted at [.filename]#/tmp#. This can be automated using the tmpmfs-related variables of man:rc.conf[5] or with an entry in [.filename]#/etc/fstab#; refer to man:mdmfs[8] for details. +|`/tmp/` +|Temporary files which are usually _not_ preserved across a system reboot. A memory-based file system is often mounted at `/tmp`. This can be automated using the tmpmfs-related variables of man:rc.conf[5] or with an entry in `/etc/fstab`; refer to man:mdmfs[8] for details. -|[.filename]#/usr/# +|`/usr/` |The majority of user utilities and applications. -|[.filename]#/usr/bin/# +|`/usr/bin/` |Common utilities, programming tools, and applications. -|[.filename]#/usr/include/# +|`/usr/include/` |Standard C include files. -|[.filename]#/usr/lib/# +|`/usr/lib/` |Archive libraries. -|[.filename]#/usr/libdata/# +|`/usr/libdata/` |Miscellaneous utility data files. -|[.filename]#/usr/libexec/# +|`/usr/libexec/` |System daemons and system utilities executed by other programs. -|[.filename]#/usr/local/# -|Local executables and libraries. Also used as the default destination for the FreeBSD ports framework. Within [.filename]#/usr/local#, the general layout sketched out by man:hier[7] for [.filename]#/usr# should be used. Exceptions are the man directory, which is directly under [.filename]#/usr/local# rather than under [.filename]#/usr/local/share#, and the ports documentation is in [.filename]#share/doc/port#. - -|[.filename]#/usr/obj/# -|Architecture-specific target tree produced by building the [.filename]#/usr/src# tree. +|`/usr/local/` +|Local executables and libraries. Also used as the default destination for the FreeBSD ports framework. Within `/usr/local`, the general layout sketched out by man:hier[7] for `/usr` should be used. Exceptions are the man directory, which is directly under `/usr/local` rather than under `/usr/local/share`, and the ports documentation is in `share/doc/port`. -|[.filename]#/usr/ports/# +|`/usr/ports/` |The FreeBSD Ports Collection (optional). -|[.filename]#/usr/sbin/# +|`/usr/sbin/` |System daemons and system utilities executed by users. -|[.filename]#/usr/share/# +|`/usr/share/` |Architecture-independent files. -|[.filename]#/usr/src/# +|`/usr/src/` |BSD and/or local source files. -|[.filename]#/var/# -|Multi-purpose log, temporary, transient, and spool files. A memory-based file system is sometimes mounted at [.filename]#/var#. This can be automated using the varmfs-related variables in man:rc.conf[5] or with an entry in [.filename]#/etc/fstab#; refer to man:mdmfs[8] for details. +|`/var/` +|Multi-purpose log, temporary, transient, and spool files. -|[.filename]#/var/log/# +|`/var/log/` |Miscellaneous system log files. -|[.filename]#/var/mail/# -|User mailbox files. +|`/var/tmp/` +|Temporary files which are usually preserved across a system reboot. -|[.filename]#/var/spool/# -|Miscellaneous printer and mail system spooling directories. - -|[.filename]#/var/tmp/# -|Temporary files which are usually preserved across a system reboot, unless [.filename]#/var# is a memory-based file system. - -|[.filename]#/var/yp/# -|NIS maps. |=== [[disk-organization]] == Disk Organization The smallest unit of organization that FreeBSD uses to find files is the filename. -Filenames are case-sensitive, which means that [.filename]#readme.txt# and [.filename]#README.TXT# are two separate files. +Filenames are case-sensitive, which means that `readme.txt` and `README.TXT` are two separate files. FreeBSD does not use the extension of a file to determine whether the file is a program, document, or some other form of data. Files are stored in directories. @@ -1119,10 +1137,10 @@ A directory can also contain other directories, allowing a hierarchy of directories within one another in order to organize data. Files and directories are referenced by giving the file or directory name, followed by a forward slash, `/`, followed by any other directory names that are necessary. -For example, if the directory [.filename]#foo# contains a directory [.filename]#bar# which contains the file [.filename]#readme.txt#, the full name, or _path_, to the file is [.filename]#foo/bar/readme.txt#. +For example, if the directory `foo` contains a directory `bar` which contains the file `readme.txt`, the full name, or _path_, to the file is `foo/bar/readme.txt`. Note that this is different from Windows(R) which uses `\` to separate file and directory names. FreeBSD does not use drive letters, or other drive names in the path. -For example, one would not type [.filename]#c:\foo\bar\readme.txt# on FreeBSD. +For example, one would not type `c:\foo\bar\readme.txt` on FreeBSD. Directories and files are stored in a file system. Each file system contains exactly one directory at the very top level, called the _root directory_ for that file system. @@ -1138,37 +1156,37 @@ If man:ls[1] is used to view the contents of this directory, it will show two subdirectories, `A1` and `A2`. The directory tree looks like this: -image::example-dir1.png[] +image::example-dir1.png[Directory tree with the root directory and two subdirectories, A1 and A2] A file system must be mounted on to a directory in another file system. When mounting file system `B` on to the directory `A1`, the root directory of `B` replaces `A1`, and the directories in `B` appear accordingly: -image::example-dir2.png[] +image::example-dir2.png[Directory tree with the root directory and two subdirectories, A1 and A2. And more subdirectories, B1 and B2 hanging from A1] -Any files that are in the `B1` or `B2` directories can be reached with the path [.filename]#/A1/B1# or [.filename]#/A1/B2# as necessary. -Any files that were in [.filename]#/A1# have been temporarily hidden. +Any files that are in the `B1` or `B2` directories can be reached with the path `/A1/B1` or `/A1/B2` as necessary. +Any files that were in `/A1` have been temporarily hidden. They will reappear if `B` is _unmounted_ from `A`. If `B` had been mounted on `A2` then the diagram would look like this: -image::example-dir3.png[] +image::example-dir3.png[Directory tree with the root directory and two subdirectories, A1 and A2. And more subdirectories, B1 and B2 hanging from A2] -and the paths would be [.filename]#/A2/B1# and [.filename]#/A2/B2# respectively. +and the paths would be `/A2/B1` and `/A2/B2` respectively. File systems can be mounted on top of one another. Continuing the last example, the `C` file system could be mounted on top of the `B1` directory in the `B` file system, leading to this arrangement: -image::example-dir4.png[] +image::example-dir4.png[A complex directory tree. With different subdirectories hanging from root.] Or `C` could be mounted directly on to the `A` file system, under the `A1` directory: -image::example-dir5.png[] +image::example-dir5.png[A complex directory tree. With different subdirectories hanging from root.] It is entirely possible to have one large root file system, and not need to create any others. There are some drawbacks to this approach, and one advantage. .Benefits of Multiple File Systems -* Different file systems can have different _mount options_. For example, the root file system can be mounted read-only, making it impossible for users to inadvertently delete or edit a critical file. Separating user-writable file systems, such as [.filename]#/home#, from other file systems allows them to be mounted _nosuid_. This option prevents the _suid_/_guid_ bits on executables stored on the file system from taking effect, possibly improving security. +* Different file systems can have different _mount options_. For example, the root file system can be mounted read-only, making it impossible for users to inadvertently delete or edit a critical file. Separating user-writable file systems, such as `/home`, from other file systems allows them to be mounted _nosuid_. This option prevents the _suid_/_guid_ bits on executables stored on the file system from taking effect, possibly improving security. * FreeBSD automatically optimizes the layout of files on a file system, depending on how the file system is being used. So a file system that contains many small files that are written frequently will have a different optimization to one that contains fewer, larger files. By having one big file system this optimization breaks down. * FreeBSD's file systems are robust if power is lost. However, a power loss at a critical point could still damage the structure of the file system. By splitting data over multiple file systems it is more likely that the system will still come up, making it easier to restore from backup as necessary. @@ -1178,6 +1196,9 @@ [IMPORTANT] ==== FreeBSD features the man:growfs[8] command, which makes it possible to increase the size of file system on the fly, removing this limitation. +A file system can only be expanded into free space in the partition in which it resides. +If there is space after the partition, the partition can be expanded with man:gpart[8]. +If the partition is the last one on a virtual disk, and the disk is expanded, the partition can then be expanded. ==== File systems are contained in partitions. @@ -1191,8 +1212,7 @@ Some partitions have certain conventions associated with them. -[.informaltable] -[cols="1,1", frame="none", options="header"] +[cols="25h,~"] |=== | Partition | Convention @@ -1291,31 +1311,31 @@ ==== This diagram shows FreeBSD's view of the first SATA disk attached to the system. Assume that the disk is 250 GB in size, and contains an 80 GB slice and a 170 GB slice (MS-DOS(R) partitions). -The first slice contains a Windows(R) NTFS file system, [.filename]#C:#, and the second slice contains a FreeBSD installation. +The first slice contains a Windows(R) NTFS file system, `C:`, and the second slice contains a FreeBSD installation. This example FreeBSD installation has four data partitions and a swap partition. The four partitions each hold a file system. -Partition `a` is used for the root file system, `d` for [.filename]#/var/#, `e` for [.filename]#/tmp/#, and `f` for [.filename]#/usr/#. +Partition `a` is used for the root file system, `d` for `/var/`, `e` for `/tmp/`, and `f` for `/usr/`. Partition letter `c` refers to the entire slice, and so is not used for ordinary partitions. -image::disk-layout.png[] +image::disk-layout.png[Layout of a shared drive between Windows and FreeBSD] ==== [[mount-unmount]] == Mounting and Unmounting File Systems -The file system is best visualized as a tree, rooted, as it were, at [.filename]#/#. [.filename]#/dev#, [.filename]#/usr#, and the other directories in the root directory are branches, which may have their own branches, such as [.filename]#/usr/local#, and so on. +The file system is best visualized as a tree, rooted, as it were, at `/`. `/dev`, `/usr`, and the other directories in the root directory are branches, which may have their own branches, such as `/usr/local`, and so on. There are various reasons to house some of these directories on separate file systems. -[.filename]#/var# contains the directories [.filename]#log/#, [.filename]#spool/#, and various types of temporary files, and as such, may get filled up. -Filling up the root file system is not a good idea, so splitting [.filename]#/var# from [.filename]#/# is often favorable. +`/var` contains the directories `log/`, `spool/`, and various types of temporary files, and as such, may get filled up. +Filling up the root file system is not a good idea, so splitting `/var` from `/` is often favorable. Another common reason to contain certain directory trees on other file systems is if they are to be housed on separate physical disks, or are separate virtual disks, such as Network File System mounts, described in crossref:network-servers[network-nfs,“Network File System (NFS)”], or CDROM drives. [[disks-fstab]] -=== The [.filename]#fstab# File +=== The fstab File -During the boot process (crossref:boot[boot,The FreeBSD Booting Process]), file systems listed in [.filename]#/etc/fstab# are automatically mounted except for the entries containing `noauto`. +During the boot process (crossref:boot[boot,The FreeBSD Booting Process]), file systems listed in `/etc/fstab` are automatically mounted except for the entries containing `noauto`. This file contains entries in the following format: [.programlisting] @@ -1343,13 +1363,13 @@ If the field is missing, a value of zero is assumed. `passno`:: -Determines the order in which file systems should be checked. +Determines the order in which UFS file systems should be checked by man:fsck[8] after a reboot. File systems that should be skipped should have their `passno` set to zero. The root file system needs to be checked before everything else and should have its `passno` set to one. The other file systems should be set to values greater than one. If more than one file system has the same `passno`, man:fsck[8] will attempt to check file systems in parallel if possible. -Refer to man:fstab[5] for more information on the format of [.filename]#/etc/fstab# and its options. +Refer to man:fstab[5] for more information on the format of `/etc/fstab` and its options. [[disks-mount]] === Using man:mount[8] @@ -1369,7 +1389,7 @@ .Mount Options `-a`:: -Mount all the file systems listed in [.filename]#/etc/fstab#, except those marked as "noauto", excluded by the `-t` flag, or those that are already mounted. +Mount all the file systems listed in `/etc/fstab`, except those marked as "noauto", excluded by the `-t` flag, or those that are already mounted. `-d`:: Do everything except for the actual mount system call. @@ -1534,46 +1554,6 @@ Instead, send the daemon the `SIGHUP` signal. Be aware that different daemons will have different behavior, so refer to the documentation for the daemon to determine if `SIGHUP` will achieve the desired results. -[.procedure] -**** -.Procedure: Sending a Signal to a Process - -This example shows how to send a signal to man:inetd[8]. -The man:inetd[8] configuration file is [.filename]#/etc/inetd.conf#, and man:inetd[8] will re-read this configuration file when it is sent a `SIGHUP`. - -. Find the PID of the process to send the signal to using man:pgrep[1]. In this example, the PID for man:inetd[8] is 198: -+ -[source,shell] -.... -% pgrep -l inetd -198 inetd -.... -+ -. Use man:kill[1] to send the signal. As man:inetd[8] is owned by `root`, use man:su[1] to become `root` first. -+ -[source,shell] -.... -% su -Password: -# /bin/kill -s HUP 198 -.... - -Like most UNIX(R) commands, man:kill[1] will not print any output if it is successful. -If a signal is sent to a process not owned by that user, the message `kill: _PID_: Operation not permitted` will be displayed. -Mistyping the PID will either send the signal to the wrong process, which could have negative results, or will send the signal to a PID that is not currently in use, resulting in the error `kill: _PID_: No such process`. - -[NOTE] -==== -*Why Use `/bin/kill`?:* + - -Many shells provide `kill` as a built in command, meaning that the shell will send the signal directly, rather than running [.filename]#/bin/kill#. -Be aware that different shells have a different syntax for specifying the name of the signal to send. -Rather than try to learn all of them, it can be simpler to specify `/bin/kill`. -==== -**** - -When sending other signals, substitute `TERM` or `KILL` with the name of the signal. - [IMPORTANT] ==== Killing a random process on the system is a bad idea. @@ -1598,11 +1578,11 @@ One common shell feature is filename completion. After a user types the first few letters of a command or filename and presses kbd:[Tab], the shell completes the rest of the command or filename. -Consider two files called [.filename]#foobar# and [.filename]#football#. -To delete [.filename]#foobar#, the user might type `rm foo` and press kbd:[Tab] to complete the filename. +Consider two files called `foobar` and `football`. +To delete `foobar`, the user might type `rm foo` and press kbd:[Tab] to complete the filename. But the shell only shows `rm foo`. -It was unable to complete the filename because both [.filename]#foobar# and [.filename]#football# start with `foo`. +It was unable to complete the filename because both `foobar` and `football` start with `foo`. Some shells sound a beep or show all the choices if more than one name matches. The user must then type more characters to identify the desired filename. Typing a `t` and pressing kbd:[Tab] again is enough to let the shell determine which filename is desired and fill in the rest. @@ -1615,7 +1595,7 @@ [[shell-env-vars]] .Common Environment Variables -[cols="1,1", frame="none", options="header"] +[cols="25h,~"] |=== | Variable | Description @@ -1657,7 +1637,7 @@ How to set an environment variable differs between shells. In man:tcsh[1] and man:csh[1], use `setenv` to set environment variables. In man:sh[1] and `bash`, use `export` to set the current environment variables. -This example sets the default `EDITOR` to [.filename]#/usr/local/bin/emacs# for the man:tcsh[1] shell: +This example sets the default `EDITOR` to `/usr/local/bin/emacs` for the man:tcsh[1] shell: [source,shell] .... @@ -1699,7 +1679,7 @@ [NOTE] ==== -The new shell _must_ be present in [.filename]#/etc/shells#. +The new shell _must_ be present in `/etc/shells`. If the shell was installed from the FreeBSD Ports Collection as described in crossref:ports[ports,Installing Applications: Packages and Ports], it should be automatically added to this file. If it is missing, add it using this command, replacing the path with the path of the shell: @@ -1724,7 +1704,7 @@ % ls > directory_listing.txt .... -The directory contents will now be listed in [.filename]#directory_listing.txt#. +The directory contents will now be listed in `directory_listing.txt`. Some commands can be used to read input, such as man:sort[1]. To sort this listing, redirect the input: @@ -1759,7 +1739,7 @@ % cat directory_listing.txt | sort | less .... -In that example, the contents of [.filename]#directory_listing.txt# will be sorted and the output passed to man:less[1]. +In that example, the contents of `directory_listing.txt` will be sorted and the output passed to man:less[1]. This allows the user to scroll through the output at their own pace and prevent it from scrolling off the screen. [[editors]] @@ -1788,12 +1768,12 @@ A device is a term used mostly for hardware-related activities in a system, including disks, printers, graphics cards, and keyboards. When FreeBSD boots, the majority of the boot messages refer to devices being detected. -A copy of the boot messages are saved to [.filename]#/var/run/dmesg.boot#. +A copy of the boot messages is saved to `/var/run/dmesg.boot`. Each device has a device name and number. -For example, [.filename]#ada0# is the first SATA hard drive, while [.filename]#kbd0# represents the keyboard. +For example, `ada0` is the first SATA hard drive, while `kbd0` represents the keyboard. -Most devices in FreeBSD must be accessed through special files called device nodes, which are located in [.filename]#/dev#. +Most devices in FreeBSD must be accessed through special files called device nodes, which are located in `/dev`. [[basics-more-information]] == Manual Pages @@ -1850,7 +1830,7 @@ This command displays a list of commands that have the keyword "mail" in their descriptions. This is equivalent to using man:apropos[1]. -To read the descriptions for all of the commands in [.filename]#/usr/sbin#, type: +To read the descriptions for all of the commands in `/usr/sbin`, type: [source,shell] .... diff --git a/documentation/content/en/books/handbook/ports/_index.adoc b/documentation/content/en/books/handbook/ports/_index.adoc --- a/documentation/content/en/books/handbook/ports/_index.adoc +++ b/documentation/content/en/books/handbook/ports/_index.adoc @@ -69,15 +69,6 @@ [[ports-overview]] == Overview of Software Installation -The typical steps for installing third-party software on a UNIX(R) system include: - -[.procedure] -. Find and download the software, which might be distributed in source code format or as a binary. -. Unpack the software from its distribution format. This is typically a tarball compressed with a program such as man:compress[1], man:gzip[1], man:bzip2[1] or man:xz[1]. -. Locate the documentation in [.filename]#INSTALL#, [.filename]#README# or some file in a [.filename]#doc/# subdirectory and read up on how to install the software. -. If the software was distributed in source format, compile it. This may involve editing a [.filename]#Makefile# or running a `configure` script. -. Test and install the software. - A FreeBSD _port_ is a collection of files designed to automate the process of compiling an application from source code. The files that comprise a port contain all the necessary information to automatically download, extract, patch, compile, and install the application. @@ -99,14 +90,14 @@ .Package Benefits * A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application. -* Packages do not require compilation time. For large applications, such as Mozilla, KDE, or GNOME, this can be important on a slow system. +* Packages do not require compilation time. For large applications, such as Firefox, KDE Plasma, or GNOME, this can be important on a slow system. * Packages do not require any understanding of the process involved in compiling software on FreeBSD. .Port Benefits * Packages are normally compiled with conservative options because they have to run on the maximum number of systems. By compiling from the port, one can change the compilation options. -* Some applications have compile-time options relating to which features are installed. For example, Apache can be configured with a wide variety of different built-in options. +* Some applications have compile-time options relating to which features are installed. For example, NGINX(R) can be configured with a wide variety of different built-in options. + -In some cases, multiple packages will exist for the same application to specify certain settings. For example, Ghostscript is available as a [.filename]#ghostscript# package and a [.filename]#ghostscript-nox11# package, depending on whether or not Xorg is installed. Creating multiple packages rapidly becomes impossible if an application has more than one or two different compile-time options. +In some cases, multiple packages will exist for the same application to specify certain settings. For example, NGINX(R) is available as a `nginx` package and a `nginx-lite` package, depending on whether or not Xorg is installed. Creating multiple packages rapidly becomes impossible if an application has more than one or two different compile-time options. * The licensing conditions of some software forbid binary distribution. Such software must be distributed as source code which must be compiled by the end-user. * Some people do not trust binary distributions or prefer to read through source code in order to look for potential problems. * Source code is needed in order to apply custom patches. @@ -115,7 +106,6 @@ [WARNING] ==== - Before installing any application, check https://vuxml.freebsd.org/[] for security issues related to the application or type `pkg audit -F` to check all installed applications for known vulnerabilities. ==== @@ -127,210 +117,66 @@ FreeBSD's list of available applications is growing all the time. There are a number of ways to find software to install: -* The FreeBSD web site maintains an up-to-date searchable list of all the available applications, at link:https://www.FreeBSD.org/ports/[https://www.FreeBSD.org/ports/]. The ports can be searched by application name or by software category. -* Dan Langille maintains http://www.FreshPorts.org/[FreshPorts.org] which provides a comprehensive search utility and also tracks changes to the applications in the Ports Collection. Registered users can create a customized watch list in order to receive an automated email when their watched ports are updated. -* If finding a particular application becomes challenging, try searching a site like http://www.sourceforge.net/[SourceForge.net] or http://www.github.com/[GitHub.com] then check back at the link:https://www.FreeBSD.org/ports/[FreeBSD site] to see if the application has been ported. -* To search the binary package repository for an application: -+ -[source,shell] -.... -# pkg search subversion -git-subversion-1.9.2 -java-subversion-1.8.8_2 -p5-subversion-1.8.8_2 -py27-hgsubversion-1.6 -py27-subversion-1.8.8_2 -ruby-subversion-1.8.8_2 -subversion-1.8.8_2 -subversion-book-4515 -subversion-static-1.8.8_2 -subversion16-1.6.23_4 -subversion17-1.7.16_2 -.... -+ -Package names include the version number and, in the case of ports based on python, the version number of the version of python the package was built with. -Some ports also have multiple versions available. -In the case of Subversion, there are different versions available, as well as different compile options. -In this case, the statically linked version of Subversion. -When indicating which package to install, it is best to specify the application by the port origin, which is the path in the ports tree. -Repeat the `pkg search` with `-o` to list the origin of each package: -+ -[source,shell] -.... -# pkg search -o subversion -devel/git-subversion -java/java-subversion -devel/p5-subversion -devel/py-hgsubversion -devel/py-subversion -devel/ruby-subversion -devel/subversion16 -devel/subversion17 -devel/subversion -devel/subversion-book -devel/subversion-static -.... -+ -Searching by shell globs, regular expressions, exact match, by description, or any other field in the repository database is also supported by `pkg search`. -After installing package:ports-mgmt/pkg[] or package:ports-mgmt/pkg-devel[], see man:pkg-search[8] for more details. -* If the Ports Collection is already installed, there are several methods to query the local version of the ports tree. To find out which category a port is in, type `whereis _file_`, where _file_ is the program to be installed: -+ -[source,shell] -.... -# whereis lsof -lsof: /usr/ports/sysutils/lsof -.... -+ -Alternately, an man:echo[1] statement can be used: -+ -[source,shell] -.... -# echo /usr/ports/*/*lsof* -/usr/ports/sysutils/lsof -.... -+ -Note that this will also return any matched files downloaded into the [.filename]#/usr/ports/distfiles# directory. -* Another way to find software is by using the Ports Collection's built-in search mechanism. To use the search feature, cd to [.filename]#/usr/ports# then run `make search name=program-name` where _program-name_ is the name of the software. For example, to search for `lsof`: -+ -[source,shell] -.... -# cd /usr/ports -# make search name=lsof -Port: lsof-4.88.d,8 -Path: /usr/ports/sysutils/lsof -Info: Lists information about open files (similar to fstat(1)) -Maint: ler@lerctr.org -Index: sysutils -B-deps: -R-deps: -.... -+ -[TIP] -==== -The built-in search mechanism uses a file of index information. -If a message indicates that the [.filename]#INDEX# is required, run `make fetchindex` to download the current index file. -With the [.filename]#INDEX# present, `make search` will be able to perform the requested search. -==== -+ -The "Path:" line indicates where to find the port. -+ -To receive less information, use the `quicksearch` feature: -+ -[source,shell] -.... -# cd /usr/ports -# make quicksearch name=lsof -Port: lsof-4.88.d,8 -Path: /usr/ports/sysutils/lsof -Info: Lists information about open files (similar to fstat(1)) -.... -+ -For more in-depth searching, use `make search key=_string_` or `make quicksearch key=_string_`, where _string_ is some text to search for. -The text can be in comments, descriptions, or dependencies in order to find ports which relate to a particular subject when the name of the program is unknown. -+ -When using `search` or `quicksearch`, the search string is case-insensitive. -Searching for "LSOF" will yield the same results as searching for "lsof". +* The FreeBSD web site maintains an up-to-date searchable list of all the available applications, at link:https://www.FreeBSD.org/ports/[Ports Portal]. The ports can be searched by application name or by software category. +* Dan Langille maintains https://www.freshports.org/[FreshPorts] which provides a comprehensive search utility and also tracks changes to the applications in the Ports Collection. Registered users can create a customized watch list in order to receive an automated email when their watched ports are updated. +* If finding a particular application becomes challenging, try searching a site like https://sourceforge.net/[SourceForge] or https://github.com/[GitHub] then check back at the link:https://www.FreeBSD.org/ports/[Ports Portal] to see if the application has been ported. +* Search the binary package repository for an application using the man:pkg[8] command [[pkgng-intro]] == Using pkg for Binary Package Management -pkg is the next generation replacement for the traditional FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. +man:pkg[8] provides an interface for manipulating packages: registering, adding, removing and upgrading packages. -For sites wishing to only use prebuilt binary packages from the FreeBSD mirrors, managing packages with pkg can be sufficient. +For sites wishing to only use prebuilt binary packages from the FreeBSD mirrors, managing packages with man:pkg[8] can be sufficient. -However, for those sites building from source or using their own repositories, a separate <> will be needed. +However, for those sites building from source a separate <> will be needed. -Since pkg only works with binary packages, it is not a replacement for such tools. -Those tools can be used to install software from both binary packages and the Ports Collection, while pkg installs only binary packages. +Since man:pkg[8] only works with binary packages, it is not a replacement for such tools. +Those tools can be used to install software from both binary packages and the Ports Collection, while man:pkg[8] installs only binary packages. [[pkgng-initial-setup]] === Getting Started with pkg -FreeBSD includes a bootstrap utility which can be used to download and install pkg and its manual pages. -This utility is designed to work with versions of FreeBSD starting with 10._X_. +All supported versions of FreeBSD now contain `/usr/sbin/pkg` a.k.a man:pkg[7]. +This is a small placeholder that has just the minimum functionality required to install the real man:pkg[8]. [NOTE] ==== -Not all FreeBSD versions and architectures support this bootstrap process. -The current list is at https://pkg.freebsd.org/[]. -For other cases, pkg must instead be installed from the Ports Collection or as a binary package. +An Internet working connection is required for the bootstrap process to succeed. ==== -To bootstrap the system, run: - -[source,shell] -.... -# /usr/sbin/pkg -.... - -You must have a working Internet connection for the bootstrap process to succeed. - -Otherwise, to install the port, run: +Run man:pkg[8] command line: [source,shell] .... -# cd /usr/ports/ports-mgmt/pkg -# make -# make install clean +# pkg .... -When upgrading an existing system that originally used the older pkg_* tools, -the database must be converted to the new format, so that the new tools are aware of the already installed packages. -Once pkg has been installed, the package database must be converted from the traditional format to the new format by running this command: - -[source,shell] -.... -# pkg2ng -.... - -[NOTE] -==== -This step is not required for new installations that do not yet have any third-party software installed. -==== - -[IMPORTANT] -==== -This step is not reversible. -Once the package database has been converted to the pkg format, the traditional `pkg_*` tools should no longer be used. -==== - -[NOTE] -==== -The package database conversion may emit errors as the contents are converted to the new version. -Generally, these errors can be safely ignored. -However, a list of software that was not successfully converted is shown after `pkg2ng` finishes. -These applications must be manually reinstalled. -==== - -To ensure that the Ports Collection registers new software with pkg instead of the traditional packages database, -FreeBSD versions earlier than 10._X_ require this line in [.filename]#/etc/make.conf#: +The output should be similar to the following: [.programlisting] .... -WITH_PKGNG= yes +The package management tool is not yet installed on your system. +Do you want to fetch and install it not? [y/N] .... -By default, pkg uses the binary packages from the FreeBSD package mirrors (the _repository_). -For information about building a custom package repository, see <>. +man:pkg[7] will intercept the command, and if you confirm that is your intention, download the man:pkg[8] tarball, install man:pkg[8] from it, bootstrap the local package database and then proceed to run the command you originally requested. -Additional pkg configuration options are described in man:pkg.conf[5]. +More recent versions of man:pkg[7] understand `pkg -N` as a test to see if man:pkg[8] is installed without triggering the installation, and conversely, pkg bootstrap[-f] to install man:pkg[8] (or force it to be reinstalled) without performing any other actions. Usage information for pkg is available in the man:pkg[8] manual page or by running `pkg` without additional arguments. +Additional pkg configuration options are described in man:pkg.conf[5]. Each pkg command argument is documented in a command-specific manual page. -To read the manual page for `pkg install`, for example, run either of these commands: -[source,shell] -.... -# pkg help install -.... +To read the manual page for `pkg install`, for example, run this command: [source,shell] .... -# man pkg-install +# pkg help install .... -The rest of this section demonstrates common binary package management tasks which can be performed using pkg. +The rest of this section demonstrates common binary package management tasks which can be performed using man:pkg[8]. Each demonstrated command provides many switches to customize its use. Refer to a command's help or man page for details and more examples. @@ -342,7 +188,7 @@ Quarterly branches aim to receive security fixes (that may be version updates, or backports of commits), bug fixes and ports compliance or framework changes. The Quarterly branch is cut from HEAD at the beginning of every (yearly) quarter in January, April, July, and October. Branches are named according to the year (YYYY) and quarter (Q1-4) they are created in. -For example, the quarterly branch created in January 2016, is named 2016Q1. +For example, the quarterly branch created in January 2023, is named 2023Q1. And the `Latest` branch provides the latest versions of the packages to the users. To switch from quarterly to latest run the following commands: @@ -353,7 +199,7 @@ # cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/FreeBSD.conf .... -Edit the file [.filename]#/usr/local/etc/pkg/repos/FreeBSD.conf# and change the string _quarterly_ to _latest_ in the `url:` line. +Edit the file `/usr/local/etc/pkg/repos/FreeBSD.conf` and change the string _quarterly_ to _latest_ in the `url:` line. The result should be similar to the following: @@ -375,56 +221,95 @@ # pkg update -f .... -[[pkgng-pkg-info]] -=== Obtaining Information About Installed Packages +[[pkg-configuration]] +=== Configure pkg -Information about the packages installed on a system can be viewed by running `pkg info` which, when run without any switches, -will list the package version for either all installed packages or the specified package. +man:pkg.conf[5] is the system-wide configuration file used by the man:pkg[8] tools. +The default location of this file is `/usr/local/etc/pkg.conf`. -For example, to see which version of pkg is installed, run: +[NOTE] +==== +FreeBSD does not need to have a `pkg.conf` file. +Many installations will work well with no `pkg.conf` at all or with an empty `pkg.conf` (other than comment lines). +==== -[source,shell] -.... -# pkg info pkg -pkg-1.1.4_1 -.... +Lines in the file beginning with a "#" are comments and are ignored. + +The file is in UCL format. +For more information on the syntax of man:libucl[3], please visit the link:https://github.com/vstakhov/libucl[official UCL website]. + +The following types of options are recognized - boolean, string and list options. + +A boolean option is marked as enabled if one of the following values is specified in the configuration file - YES, TRUE and ON. -[[pkgng-installing-deinstalling]] -=== Installing and Removing Packages +[[pkg-search]] +=== Searching Packages -To install a binary package use the following command, where _packagename_ is the name of the package to install: +To search a package man:pkg-search[8] can be used: [source,shell] .... -# pkg install packagename +# pkg search nginx .... +The output should be similar to the following: + +[.programlisting] +.... +modsecurity3-nginx-1.0.3 Instruction detection and prevention engine / nginx Wrapper +nginx-1.22.1_2,3 Robust and small WWW server +nginx-devel-1.23.2_4 Robust and small WWW server +nginx-full-1.22.1_1,3 Robust and small WWW server (full package) +nginx-lite-1.22.1,3 Robust and small WWW server (lite package) +nginx-naxsi-1.22.1,3 Robust and small WWW server (plus NAXSI) +nginx-prometheus-exporter-0.10.0_7 Prometheus exporter for NGINX and NGINX Plus stats +nginx-ultimate-bad-bot-blocker-4.2020.03.2005_1 Nginx bad bot and other things blocker +nginx-vts-exporter-0.10.7_7 Server that scraps NGINX vts stats and export them via HTTP +p5-Nginx-ReadBody-0.07_1 Nginx embeded perl module to read and evaluate a request body +p5-Nginx-Simple-0.07_1 Perl 5 module for easy to use interface for Nginx Perl Module +p5-Test-Nginx-0.30 Testing modules for Nginx C module development +py39-certbot-nginx-2.0.0 NGINX plugin for Certbot +rubygem-passenger-nginx-6.0.15 Modules for running Ruby on Rails and Rack applications +.... + +[[pkg-installing-fetching]] +=== Installing and Fetching Packages + +To install a binary package man:pkg-install[8] can be used. This command uses repository data to determine which version of the software to install and if it has any uninstalled dependencies. For example, to install curl: [source,shell] .... # pkg install curl -Updating repository catalogue -/usr/local/tmp/All/curl-7.31.0_1.txz 100% of 1181 kB 1380 kBps 00m01s +.... -/usr/local/tmp/All/ca_root_nss-3.15.1_1.txz 100% of 288 kB 1700 kBps 00m00s +The output should be similar to the following: -Updating repository catalogue -The following 2 packages will be installed: +[.programlisting] +.... +Updating FreeBSD repository catalogue... +FreeBSD repository is up to date. +All repositories are up to date. +The following 9 package(s) will be affected (of 0 checked): - Installing ca_root_nss: 3.15.1_1 - Installing curl: 7.31.0_1 +New packages to be INSTALLED: + ca_root_nss: 3.83 + curl: 7.86.0 + gettext-runtime: 0.21 + indexinfo: 0.3.1 + libidn2: 2.3.3 + libnghttp2: 1.48.0 + libpsl: 0.21.1_4 + libssh2: 1.10.0.3 + libunistring: 1.0 -The installation will require 3 MB more space +Number of packages to be installed: 9 -0 B to be downloaded +The process will require 11 MiB more space. +3 MiB to be downloaded -Proceed with installing packages [y/N]: y -Checking integrity... done -[1/2] Installing ca_root_nss-3.15.1_1... done -[2/2] Installing curl-7.31.0_1... done -Cleaning up cache files...Done +Proceed with this action? [y/N] .... The new package and any additional packages that were installed as dependencies can be seen in the installed packages list: @@ -432,31 +317,115 @@ [source,shell] .... # pkg info -ca_root_nss-3.15.1_1 The root certificate bundle from the Mozilla Project -curl-7.31.0_1 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers -pkg-1.1.4_6 New generation package manager .... -Packages that are no longer needed can be removed with `pkg delete`. -For example: +The output should be similar to the following: + +[.programlisting] +.... +ca_root_nss-3.83 Root certificate bundle from the Mozilla Project +curl-7.86.0 Command line tool and library for transferring data with URLs +gettext-runtime-0.21.1 GNU gettext runtime libraries and programs +indexinfo-0.3.1 Utility to regenerate the GNU info page index +libidn2-2.3.3 Implementation of IDNA2008 internationalized domain names +libnghttp2-1.48.0 HTTP/2.0 C Library +libpsl-0.21.1_6 C library to handle the Public Suffix List +libssh2-1.10.0.3 Library implementing the SSH2 protocol +libunistring-1.0 Unicode string library +pkg-1.18.4 Package manager +.... + +To fetch a package and install it later or in another place use man:pkg-fetch[8]. +For example, to download `nginx-lite`: [source,shell] .... -# pkg delete curl -The following packages will be deleted: +# pkg fetch -d -o /usr/home/user/packages/ nginx-lite +.... + +* `-d`: used to fetch all the dependencies +* `-o`: used to specify the download directory + +The output should be similar to the following: + +[.programlisting] +.... +Updating FreeBSD repository catalogue... +FreeBSD repository is up to date. +All repositories are up to date. +The following packages will be fetched: + +New packages to be FETCHED: + nginx-lite: 1.22.1,3 (342 KiB: 22.20% of the 2 MiB to download) + pcre: 8.45_3 (1 MiB: 77.80% of the 2 MiB to download) + +Number of packages to be fetched: 2 + +The process will require 2 MiB more space. +2 MiB to be downloaded. + +Proceed with fetching packages? [y/N]: +.... + +To install the downloaded packages man:pkg-install[8] can be used as follows: + +[source,shell] +.... +# cd /usr/home/user/packages/ +.... + +[source,shell] +.... +# pkg install nginx-lite-1.22.1,3.pkg +.... + +[[pkgng-pkg-info]] +=== Obtaining Information About Installed Packages + +Information about the packages installed on a system can be viewed by running man:pkg-info[8] which, when run without any switches, will list the package version for either all installed packages or the specified package. + +For example, to see which version of pkg is installed, run: - curl-7.31.0_1 +[source,shell] +.... +# pkg info pkg +.... -The deletion will free 3 MB +The output should be similar to the following: -Proceed with deleting packages [y/N]: y -[1/1] Deleting curl-7.31.0_1... done +[.programlisting] +.... +pkg-1.19.0 +Name : pkg +Version : 1.19.0 +Installed on : Sat Dec 17 11:05:28 2022 CET +Origin : ports-mgmt/pkg +Architecture : FreeBSD:13:amd64 +Prefix : /usr/local +Categories : ports-mgmt +Licenses : BSD2CLAUSE +Maintainer : pkg@FreeBSD.org +WWW : https://github.com/freebsd/pkg +Comment : Package manager +Options : + DOCS : on +Shared Libs provided: + libpkg.so.4 +Annotations : + FreeBSD_version: 1301000 + repo_type : binary + repository : FreeBSD +Flat size : 33.2MiB +Description : +Package management tool + +WWW: https://github.com/freebsd/pkg .... [[pkgng-upgrading]] === Upgrading Installed Packages -Installed packages can be upgraded to their latest versions by running: +Installed packages can be upgraded to their latest versions using man:pkg-upgrade[8]: [source,shell] .... @@ -470,29 +439,85 @@ Software vulnerabilities are regularly discovered in third-party applications. To address this, pkg includes a built-in auditing mechanism. -To determine if there are any known vulnerabilities for the software installed on the system, run: +To determine if there are any known vulnerabilities for the software installed on the system, use man:pkg-audit[8]: [source,shell] .... # pkg audit -F .... +The output should be similar to the following: + +[.programlisting] +.... +Fetching vuln.xml.xz: 100% 976 KiB 499.5kB/s 00:02 +chromium-108.0.5359.98 is vulnerable: + chromium -- multiple vulnerabilities + CVE: CVE-2022-4440 + CVE: CVE-2022-4439 + CVE: CVE-2022-4438 + CVE: CVE-2022-4437 + CVE: CVE-2022-4436 + WWW: https://vuxml.FreeBSD.org/freebsd/83eb9374-7b97-11ed-be8f-3065ec8fd3ec.html +.... + +[[pkg-delete]] +=== Removing Packages + +Packages that are no longer needed can be removed with man:pkg-delete[8]. + +For example: + +[source,shell] +.... +# pkg delete curl +.... + +The output should be similar to the following: + +[.programlisting] +.... +Checking integrity... done (0 conflicting) +Deinstallation has been requested for the following 1 packages (of 0 packages in the universe): + +Installed packages to be REMOVED: + curl :7.86.0 + +Number of packages to be removed: 1 + +The operation will free 4 MiB. + +Proceed with deinstallation packages? [y/N]: y +[1/1] Deinstalling curl-7.86.0... +[1/1] Deleting files for curl-7.86.0: 100% +.... + [[pkgng-autoremove]] === Automatically Removing Unused Packages Removing a package may leave behind dependencies which are no longer required. -Unneeded packages that were installed as dependencies (leaf packages) can be automatically detected and removed using: +Unneeded packages that were installed as dependencies (leaf packages) can be automatically detected and removed using man:pkg-autoremove[8]: [source,shell] .... # pkg autoremove -Packages to be autoremoved: - ca_root_nss-3.15.1_1 +.... + +The output should be similar to the following: + +[.programlisting] +.... +Checking integrity... done (0 conflicting) +Deinstallation has been requested for the following 1 packages: -The autoremoval will free 723 kB +Installed packages to be REMOVED: + ca_root_nss-3.83 -Proceed with autoremoval of packages [y/N]: y -Deinstalling ca_root_nss-3.15.1_1... done +Number of packages to be removed: 1 + +The operation will free 723 KiB. + +Proceed with deinstalling packages? [y/N]: .... Packages installed as dependencies are called _automatic_ packages. @@ -501,18 +526,30 @@ [source,shell] .... # pkg prime-list +.... + +The output should be similar to the following: + +[.programlisting] +.... nginx openvpn sudo .... -`pkg prime-list` is an alias command declared in [.filename]#/usr/local/etc/pkg.conf#. +`pkg prime-list` is an alias command declared in `/usr/local/etc/pkg.conf`. There are many others that can be used to query the package database of the system. For instance, command `pkg prime-origins` can be used to get the origin port directory of the list mentioned above: [source,shell] .... # pkg prime-origins +.... + +The output should be similar to the following: + +[.programlisting] +.... www/nginx security/openvpn security/sudo @@ -587,6 +624,28 @@ # pkg clean -a .... +[[pkg-locking-unlocking]] +=== Locking and Unlocking Packages + +man:pkg-lock[8] is used to lock packages against reinstallation, modification or deletion. +man:pkg-unlock[8] unlocks the named packages. +Either variant only has an effect on currently installed packages. +Consequently it is impossible to block installation of a new package by using this mechanism, unless such an installation implies updating a locked package. + +For example, to lock `nginx-lite`: + +[source,shell] +.... +# pkg lock nginx-lite +.... + +And to unlock `nginx-lite`: + +[source,shell] +.... +# pkg unlock nginx-lite +.... + [[pkgng-set]] === Modifying Package Metadata @@ -608,7 +667,7 @@ # pkg set -o lang/ruby18:lang/ruby19 .... -As a final example, to change the origin of the [.filename]#libglut# shared libraries from package:graphics/libglut[] to package:graphics/freeglut[], run: +As a final example, to change the origin of the `libglut` shared libraries from package:graphics/libglut[] to package:graphics/freeglut[], run: [source,shell] .... @@ -624,16 +683,17 @@ .... # pkg install -Rf graphics/freeglut .... - ==== + + [[ports-using]] == Using the Ports Collection -The Ports Collection is a set of [.filename]##Makefile##s, patches, and description files. +The Ports Collection is a set of `Makefiles`, patches, and description files. Each set of these files is used to compile and install an individual application on FreeBSD, and is called a _port_. -By default, the Ports Collection itself is stored as a subdirectory of [.filename]#/usr/ports#. +By default, the Ports Collection itself is stored as a subdirectory of `/usr/ports`. [WARNING] ==== @@ -648,17 +708,17 @@ Each application subdirectory contains a set of files that tells FreeBSD how to compile and install that program, called a _ports skeleton_. Each port skeleton includes these files and directories: -* [.filename]#Makefile#: contains statements that specify how the application should be compiled and where its components should be installed. -* [.filename]#distinfo#: contains the names and checksums of the files that must be downloaded to build the port. -* [.filename]#files/#: this directory contains any patches needed for the program to compile and install on FreeBSD. This directory may also contain other files used to build the port. -* [.filename]#pkg-descr#: provides a more detailed description of the program. -* [.filename]#pkg-plist#: a list of all the files that will be installed by the port. It also tells the ports system which files to remove upon deinstallation. +* *Makefile*: contains statements that specify how the application should be compiled and where its components should be installed. +* *distinfo*: contains the names and checksums of the files that must be downloaded to build the port. +* *files/*: this directory contains any patches needed for the program to compile and install on FreeBSD. This directory may also contain other files used to build the port. +* *pkg-descr*: provides a more detailed description of the program. +* *pkg-plist*: a list of all the files that will be installed by the port. It also tells the ports system which files to remove upon deinstallation. -Some ports include [.filename]#pkg-message# or other files to handle special situations. +Some ports include `pkg-message` or other files to handle special situations. For more details on these files, and on ports in general, refer to the extref:{porters-handbook}[FreeBSD Porter's Handbook]. -The port does not include the actual source code, also known as a [.filename]#distfile#. -The extract portion of building a port will automatically save the downloaded source to [.filename]#/usr/ports/distfiles#. +The port does not include the actual source code, also known as a `distfile`. +The extract portion of building a port will automatically save the downloaded source to `/usr/ports/distfiles`. [[ports-using-installation-methods]] === Installing the Ports Collection @@ -704,14 +764,14 @@ # git clone https://git.FreeBSD.org/ports.git -b 2020Q3 /usr/ports .... + -. As needed, update [.filename]#/usr/ports# after the initial Git checkout: +. As needed, update `/usr/ports` after the initial Git checkout: + [source,shell] .... # git -C /usr/ports pull .... + -. As needed, switch [.filename]#/usr/ports# to a different quarterly branch: +. As needed, switch `/usr/ports` to a different quarterly branch: + [source,shell] .... @@ -729,7 +789,7 @@ Before compiling any port, be sure to update the Ports Collection as described in the previous section. Since the installation of any third-party software can introduce security vulnerabilities, it is recommended to first check https://vuxml.freebsd.org/[] for known security issues related to the port. -Alternately, run `pkg audit -F` before installing a new port. +Alternatively, run `pkg audit -F` before installing a new port. This command can be configured to automatically perform a security audit and an update of the vulnerability database during the daily security system check. For more information, refer to man:pkg-audit[8] and man:periodic[8]. ==== @@ -824,12 +884,12 @@ The `FTP_PASSIVE_MODE`, `FTP_PROXY`, and `FTP_PASSWORD` variables may need to be set if the FreeBSD system is behind a firewall or FTP/HTTP proxy. See man:fetch[3] for the complete list of supported variables. -For users who cannot be connected to the Internet all the time, `make fetch` can be run within [.filename]#/usr/ports#, -to fetch all distfiles, or within a category, such as [.filename]#/usr/ports/net#, or within the specific port skeleton. +For users who cannot be connected to the Internet all the time, `make fetch` can be run within `/usr/ports`, +to fetch all distfiles, or within a category, such as `/usr/ports/net`, or within the specific port skeleton. Note that if a port has any dependencies, running this command in a category or ports skeleton will _not_ fetch the distfiles of ports from another category. Instead, use `make fetch-recursive` to also fetch the distfiles for all the dependencies of a port. -In rare cases, such as when an organization has a local distfiles repository, the `MASTER_SITES` variable can be used to override the download locations specified in the [.filename]#Makefile#. +In rare cases, such as when an organization has a local distfiles repository, the `MASTER_SITES` variable can be used to override the download locations specified in the `Makefile`. When using, specify the alternate location: [source,shell] @@ -846,14 +906,14 @@ # make WRKDIRPREFIX=/usr/home/example/ports install .... -will compile the port in [.filename]#/usr/home/example/ports# and install everything under [.filename]#/usr/local#. +will compile the port in `/usr/home/example/ports` and install everything under `/usr/local`. [source,shell] .... # make PREFIX=/usr/home/example/local install .... -will compile the port in [.filename]#/usr/ports# and install it in [.filename]#/usr/home/example/local#. And: +will compile the port in `/usr/ports` and install it in `/usr/home/example/local`. And: [source,shell] .... @@ -871,7 +931,7 @@ Installed ports can be uninstalled using `pkg delete`. Examples for using this command can be found in the man:pkg-delete[8] manual page. -Alternately, `make deinstall` can be run in the port's directory: +Alternately, `make deinstall` can be run in the port\'s directory: [source,shell] .... @@ -898,24 +958,17 @@ This section describes how to determine which software can be upgraded and how to perform the upgrade. To determine if newer versions of installed ports are available, ensure that the latest version of the ports tree is installed, -using the updating command described in <>. -On FreeBSD 10 and later, or if the system has been converted to pkg, the following command will list the installed ports which are out of date: +using the updating command described in <>. +The following command will list the installed ports which are out of date: [source,shell] .... # pkg version -l "<" .... -For FreeBSD 9._X_ and lower, the following command will list the installed ports that are out of date: - -[source,shell] -.... -# pkg_version -l "<" -.... - [IMPORTANT] ==== -Before attempting an upgrade, read [.filename]#/usr/ports/UPDATING# from the top of the file to the date closest to the last time ports were upgraded or the system was installed. +Before attempting an upgrade, read `/usr/ports/UPDATING` from the top of the file to the date closest to the last time ports were upgraded or the system was installed. This file describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or any incompatibilities with previous versions. Make note of any instructions which match any of the ports that need upgrading and follow these instructions when performing the upgrade. ==== @@ -1014,7 +1067,7 @@ # portmaster shells/bash .... -More information about package:ports-mgmt/portmaster[] may be found in its [.filename]#pkg-descr#. +More information about package:ports-mgmt/portmaster[] may be found in its `pkg-descr`. [[portupgrade]] ==== Upgrading Ports Using Portupgrade @@ -1061,22 +1114,22 @@ To just fetch the port distfiles, or packages, if `-P` is specified, without building or installing anything, use `-F`. For further information on all of the available switches, refer to the manual page for `portupgrade`. -More information about package:ports-mgmt/portupgrade[] may be found in its [.filename]#pkg-descr#. +More information about package:ports-mgmt/portupgrade[] may be found in its `pkg-descr`. [[ports-disk-space]] === Ports and Disk Space Using the Ports Collection will use up disk space over time. -After building and installing a port, running `make clean` within the ports skeleton will clean up the temporary [.filename]#work# directory. +After building and installing a port, running `make clean` within the ports skeleton will clean up the temporary `work` directory. If Portmaster is used to install a port, it will automatically remove this directory unless `-K` is specified. -If Portupgrade is installed, this command will remove all [.filename]#work# directories found within the local copy of the Ports Collection: +If Portupgrade is installed, this command will remove all `work` directories found within the local copy of the Ports Collection: [source,shell] .... # portsclean -C .... -In addition, outdated source distribution files accumulate in [.filename]#/usr/ports/distfiles# over time. +In addition, outdated source distribution files accumulate in `/usr/ports/distfiles` over time. To use Portupgrade to delete all the distfiles that are no longer referenced by any ports: [source,shell] @@ -1112,14 +1165,14 @@ These packages are usable by man:pkg[8] and other package management tools. Poudriere is installed using the package:ports-mgmt/poudriere[] package or port. -The installation includes a sample configuration file [.filename]#/usr/local/etc/poudriere.conf.sample#. -Copy this file to [.filename]#/usr/local/etc/poudriere.conf#. +The installation includes a sample configuration file `/usr/local/etc/poudriere.conf.sample`. +Copy this file to `/usr/local/etc/poudriere.conf`. Edit the copied file to suit the local configuration. While `ZFS` is not required on the system running poudriere, it is beneficial. -When `ZFS` is used, `ZPOOL` must be specified in [.filename]#/usr/local/etc/poudriere.conf# and `FREEBSD_HOST` should be set to a nearby mirror. +When `ZFS` is used, `ZPOOL` must be specified in `/usr/local/etc/poudriere.conf` and `FREEBSD_HOST` should be set to a nearby mirror. Defining `CCACHE_DIR` enables the use of package:devel/ccache[] to cache compilation and reduce build times for frequently-compiled code. -It may be convenient to put poudriere datasets in an isolated tree mounted at [.filename]#/poudriere#. +It may be convenient to put poudriere datasets in an isolated tree mounted at `/poudriere`. Defaults for the other configuration values are adequate. The number of processor cores detected is used to define how many builds will run in parallel. @@ -1193,11 +1246,11 @@ Custom configurations for these combinations are called _sets_. See the CUSTOMIZATION section of man:poudriere[8] for details after package:ports-mgmt/poudriere[] or package:ports-mgmt/poudriere-devel[] is installed. -The basic configuration shown here puts a single jail-, port-, and set-specific [.filename]#make.conf# in [.filename]#/usr/local/etc/poudriere.d#. -The filename in this example is created by combining the jail name, port name, and set name: [.filename]#13amd64-local-workstation-make.conf#. -The system [.filename]#make.conf# and this new file are combined at build time to create the [.filename]#make.conf# used by the build jail. +The basic configuration shown here puts a single jail-, port-, and set-specific `make.conf` in `/usr/local/etc/poudriere.d`. +The filename in this example is created by combining the jail name, port name, and set name: `13amd64-local-workstation-make.conf`. +The system `make.conf` and this new file are combined at build time to create the `make.conf` used by the build jail. -Packages to be built are entered in [.filename]#13amd64-local-workstation-pkglist#: +Packages to be built are entered in `13amd64-local-workstation-pkglist`: [.programlisting] .... @@ -1222,7 +1275,7 @@ .... While running, pressing kbd:[Ctrl+t] displays the current state of the build. -Poudriere also builds files in [.filename]#/poudriere/logs/bulk/jailname# that can be used with a web server to display build information. +Poudriere also builds files in `/poudriere/logs/bulk/jailname` that can be used with a web server to display build information. After completion, the new packages are now available for installation from the poudriere repository. @@ -1232,7 +1285,7 @@ While it is possible to use both a custom repository along side of the official repository, sometimes it is useful to disable the official repository. This is done by creating a configuration file that overrides and disables the official configuration file. -Create [.filename]#/usr/local/etc/pkg/repos/FreeBSD.conf# that contains the following: +Create `/usr/local/etc/pkg/repos/FreeBSD.conf` that contains the following: [.programlisting] .... @@ -1242,10 +1295,10 @@ .... Usually it is easiest to serve a poudriere repository to the client machines via HTTP. -Set up a webserver to serve up the package directory, for instance: [.filename]#/usr/local/poudriere/data/packages/13amd64#, where [.filename]#13amd64# is the name of the build. +Set up a webserver to serve up the package directory, for instance: `/usr/local/poudriere/data/packages/13amd64`, where `13amd64` is the name of the build. If the URL to the package repository is: `http://pkg.example.com/13amd64`, -then the repository configuration file in [.filename]#/usr/local/etc/pkg/repos/custom.conf# would look like: +then the repository configuration file in `/usr/local/etc/pkg/repos/custom.conf` would look like: [.programlisting] .... @@ -1261,9 +1314,9 @@ Regardless of whether the software was installed from a binary package or port, most third-party applications require some level of configuration after installation. The following commands and locations can be used to help determine what was installed with the application. -* Most applications install at least one default configuration file in [.filename]#/usr/local/etc#. In cases where an application has a large number of configuration files, a subdirectory will be created to hold them. Often, sample configuration files are installed which end with a suffix such as [.filename]#.sample#. The configuration files should be reviewed and possibly edited to meet the system's needs. To edit a sample file, first copy it without the [.filename]#.sample# extension. -* Applications which provide documentation will install it into [.filename]#/usr/local/share/doc# and many applications also install manual pages. This documentation should be consulted before continuing. -* Some applications run services which must be added to [.filename]#/etc/rc.conf# before starting the application. These applications usually install a startup script in [.filename]#/usr/local/etc/rc.d#. See crossref:config[configtuning-starting-services,Starting Services] for more information. +* Most applications install at least one default configuration file in `/usr/local/etc`. In cases where an application has a large number of configuration files, a subdirectory will be created to hold them. Often, sample configuration files are installed which end with a suffix such as `.sample`. The configuration files should be reviewed and possibly edited to meet the system's needs. To edit a sample file, first copy it without the `.sample` extension. +* Applications which provide documentation will install it into `/usr/local/share/doc` and many applications also install manual pages. This documentation should be consulted before continuing. +* Some applications run services which must be added to `/etc/rc.conf` before starting the application. These applications usually install a startup script in `/usr/local/etc/rc.d`. See crossref:config[configtuning-starting-services,Starting Services] for more information. + [NOTE] ==== @@ -1280,7 +1333,7 @@ When a port does not build or install, try the following: . Search to see if there is a fix pending for the port in the link:https://www.FreeBSD.org/support/[Problem Report database]. If so, implementing the proposed fix may fix the issue. -. Ask the maintainer of the port for help. Type `make maintainer` in the ports skeleton or read the port's [.filename]#Makefile# to find the maintainer's email address. Remember to include the output leading up to the error in the email to the maintainer. +. Ask the maintainer of the port for help. Type `make maintainer` in the ports skeleton or read the port's `Makefile` to find the maintainer's email address. Remember to include the output leading up to the error in the email to the maintainer. + [NOTE] ====