aboutsummaryrefslogtreecommitdiff
path: root/documentation/content/en/books/handbook/basics/_index.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/content/en/books/handbook/basics/_index.adoc')
-rw-r--r--documentation/content/en/books/handbook/basics/_index.adoc532
1 files changed, 306 insertions, 226 deletions
diff --git a/documentation/content/en/books/handbook/basics/_index.adoc b/documentation/content/en/books/handbook/basics/_index.adoc
index aa6583ca95..0abb750dab 100644
--- a/documentation/content/en/books/handbook/basics/_index.adoc
+++ b/documentation/content/en/books/handbook/basics/_index.adoc
@@ -7,7 +7,8 @@ description: Basic commands and functionality of the FreeBSD operating system
tags: ["basics", "virtual consoles", "users", "management", "permissions", "directory structure", "disk organization", "mounting", "processes", "daemons", "shell", "editor", "manual pages", "devices"]
showBookMenu: true
weight: 5
-path: "/books/handbook/"
+params:
+ path: "/books/handbook/basics/"
---
[[basics]]
@@ -74,7 +75,7 @@ After reading this chapter, you will know:
Unless FreeBSD has been configured to automatically start a graphical environment during startup, the system will boot into a command line login prompt, as seen in this example:
-[source,shell]
+[.programlisting]
....
FreeBSD/amd64 (pc3.example.org) (ttyv0)
@@ -82,20 +83,20 @@ login:
....
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 `amd64` indicates that FreeBSD is running on a 64-bit x86 system.
+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].
The password is _not echoed_ for security reasons.
Once the correct password is input, the message of the day (MOTD) will be displayed followed by a command prompt.
-Depending upon the shell that was selected when the user was created, this prompt will be a `#`, `$`, or `%` character.
+Depending upon the shell that was selected when the user was created, this prompt will be a `+#+`, `$`, or `%` character.
The prompt indicates that the user is now logged into the FreeBSD system console and ready to try the available commands.
[[consoles-virtual]]
@@ -110,7 +111,7 @@ Each virtual console has its own login prompt and shell and it is easy to switch
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.
@@ -119,7 +120,7 @@ The programs that are launched in one virtual console do not stop running when t
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]
....
@@ -137,10 +138,10 @@ ttyv7 "/usr/libexec/getty Pc" xterm on secure
ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure
....
-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].
+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 `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].
@@ -154,7 +155,7 @@ While in single user mode, networking and other virtual consoles are not availab
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]
....
@@ -202,7 +203,7 @@ To select a new video mode, specify the mode using man:vidcontrol[1] as the `roo
# 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]
....
@@ -238,12 +239,6 @@ The reason for this is security; if all services ran as the superuser, they coul
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.
@@ -260,7 +255,7 @@ Every user account on a FreeBSD system has certain information associated with i
User name::
The user name is typed at the `login:` prompt.
-Each user must have a unique user name.
+Each user must have a unique user name.
There are a number of rules for creating valid user names which are documented in man:passwd[5].
It is recommended to use user names that consist of eight or fewer, all lower case characters in order to maintain backwards compatibility with applications.
@@ -268,7 +263,7 @@ Password::
Each account has an associated password.
User ID (UID)::
-The User ID (UID) is a number used to uniquely identify the user to the FreeBSD system.
+The User ID (UID) is a number used to uniquely identify the user to the FreeBSD system.
Commands that allow a user name to be specified will first convert it to the UID.
It is recommended to use a UID less than 65535, since higher values may cause compatibility issues with some software.
@@ -298,7 +293,7 @@ Similar to a comment, this information can contain spaces, uppercase characters,
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::
@@ -350,12 +345,13 @@ This software provides activity logging and allows the administrator to configur
=== Managing Accounts
FreeBSD provides a variety of different commands to manage user accounts.
-The most common commands are summarized in <<users-modifying-utilities>>, followed by some examples of their usage.
+The most common commands are summarized in
+crossref:basics[users-modifying-utilities,Utilities for Managing User Accounts], followed by some examples of their usage.
See the manual page for each utility for more details and usage examples.
[[users-modifying-utilities]]
.Utilities for Managing User Accounts
-[cols="1,1", frame="none", options="header"]
+[cols="25h,~"]
|===
| Command
| Summary
@@ -374,18 +370,21 @@ See the manual page for each utility for more details and usage examples.
|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.
-As seen in <<users-modifying-adduser>>, either input the required information or press kbd:[Return] to accept the default value shown in square brackets.
+As seen in crossref:basics[users-modifying-adduser, Adding a User on FreeBSD], either input the required information or press kbd:[Return] to accept the default value shown in square brackets.
In this example, the user has been invited into the `wheel` group, allowing them to become the superuser with man:su[1].
When finished, the utility will prompt to either create another user or to exit.
@@ -396,6 +395,12 @@ When finished, the utility will prompt to either create another user or to exit.
[source,shell]
....
# adduser
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
Username: jru
Full name: J. Random User
Uid (Leave empty for default):
@@ -424,7 +429,6 @@ OK? (yes/no): yes
adduser: INFO: Successfully added (jru) to the user database.
Add another user? (yes/no): no
Goodbye!
-#
....
====
@@ -434,20 +438,23 @@ Since the password is not echoed when typed, be careful to not mistype the passw
====
[[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.
@@ -459,17 +466,23 @@ By default, an interactive mode is used, as shown in the following example.
[source,shell]
....
# rmuser jru
+
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
Matching password entry:
jru:*:1001:1001::0:0:J. Random User:/home/jru:/usr/local/bin/zsh
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.
@@ -482,9 +495,9 @@ When the user exits from the editor, the user database is updated with the new i
This utility will prompt for the user's password when exiting the editor, unless the utility is run as the superuser.
====
-In <<users-modifying-chpass-su>>, the superuser has typed `chpass jru` and is now viewing the fields that can be changed for this user
+In crossref:basics[users-modifying-chpass-su,Using `chpass` as Superuser], the superuser has typed `chpass jru` and is now viewing the fields that can be changed for this user.
If `jru` runs this command instead, only the last six fields will be displayed and available for editing.
-This is shown in <<users-modifying-chpass-ru>>.
+This is shown in crossref:basics[users-modifying-chpass-ru,Using `chpass` as Regular User].
[[users-modifying-chpass-su]]
.Using `chpass` as Superuser
@@ -492,7 +505,14 @@ This is shown in <<users-modifying-chpass-ru>>.
====
[source,shell]
....
-#Changing user database information for jru.
+# chpass jru
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
+# Changing user database information for jru.
Login: jru
Password: *
Uid [#]: 1001
@@ -534,7 +554,7 @@ How to configure NIS is covered in crossref:network-servers[network-servers,Netw
====
[[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:
@@ -545,6 +565,12 @@ To prevent accidental or unauthorized changes, this command will prompt for the
[source,shell]
....
% passwd
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
Changing local password for jru.
Old password:
New password:
@@ -564,6 +590,12 @@ This allows the password to be changed when a user cannot remember the original
[source,shell]
....
# passwd jru
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
Changing local password for jru.
New password:
Retype new password:
@@ -578,7 +610,7 @@ As with man:chpass[1], man:yppasswd[1] is a link to man:passwd[1], so NIS works
====
[[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.
@@ -591,15 +623,20 @@ A group is a list of users. A group is identified by its group name and GID.
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].
+For a 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]
====
@@ -607,6 +644,12 @@ For example, to add a group called `teamtwo` and then confirm that it exists:
....
# pw groupadd teamtwo
# pw groupshow teamtwo
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
teamtwo:*:1100:
....
====
@@ -622,6 +665,12 @@ This command will add `jru` as a member of `teamtwo`.
....
# pw groupmod teamtwo -M jru
# pw groupshow teamtwo
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
teamtwo:*:1100:jru
....
====
@@ -629,7 +678,7 @@ teamtwo:*:1100:jru
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]
@@ -638,6 +687,12 @@ When man:pw[8] is used to add a user to a group, it only manipulates [.filename]
....
# pw groupmod teamtwo -m db
# pw groupshow teamtwo
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
teamtwo:*:1100:jru,db
....
====
@@ -651,22 +706,28 @@ Unlike the previous example, these users are appended to the group and do not re
[source,shell]
....
% id jru
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
uid=1001(jru) gid=1001(jru) groups=1001(jru), 1100(teamtwo)
....
====
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
-In FreeBSD, every file and directory has an associated set of permissions and several utilities are available for viewing and modifying these permissions.
+In FreeBSD, every file and directory has an associated set of permissions and several utilities are available for viewing and modifying these permissions.
Understanding how permissions work is necessary to make sure that users are able to access the files that they need and are unable to improperly access the files used by the operating system or owned by other users.
This section discusses the traditional UNIX(R) permissions used in FreeBSD.
-For finer grained file system access control, refer to crossref:security[fs-acl,“Access Control Lists”].
+For finer-grained file system access control, refer to crossref:security[fs-acl,Access Control Lists].
In UNIX(R), basic permissions are assigned using three types of access: read, write, and execute.
These access types are used to determine file access to the file's owner, group, and others (everyone else).
@@ -717,19 +778,25 @@ When reading the "Directory Listing" column, a `-` is used to represent a permis
|`rwx`
|===
-Use the `-l` argument to man:ls[1] to view a long directory listing that includes a column of information about a file's permissions for the owner, group, and everyone else.
-For example, an `ls -l` in an arbitrary directory may show:
+Use the `-l` argument with man:ls[1] to view a long directory listing that includes a column of information about a file's permissions for the owner, group, and everyone else.
+For example, `ls -l` in an arbitrary directory may show:
[source,shell]
....
% ls -l
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
total 530
-rw-r--r-- 1 root wheel 512 Sep 5 12:31 myfile
-rw-r--r-- 1 root wheel 512 Sep 5 12:31 otherfile
-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 first `(leftmost)` 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.
@@ -738,8 +805,8 @@ A dash means that the permission is turned off.
In this example, the permissions are set so the owner can read and write to the file, the group can read the file, and the rest of the world can only read the file.
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/#.
+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 `/dev/`.
Directories are also treated as files.
They have read, write, and execute permissions.
@@ -815,7 +882,7 @@ Symbolic permissions use the syntax of (who) (action) (permissions), where the f
|===
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]
....
@@ -837,7 +904,7 @@ These flags add an additional level of security and control over files, but not
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]
....
@@ -867,7 +934,7 @@ Several file flags may only be added or removed by the `root` user.
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.
@@ -881,14 +948,21 @@ As an example, man:passwd[1] runs with the real user ID when a user changes thei
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]
....
@@ -934,7 +1008,14 @@ Although man:passwd[1] is run as a normal user, it is using the effective UID of
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]
....
@@ -958,8 +1039,15 @@ The `setuid` and `setgid` permission bits may lower system security, by allowing
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]
....
@@ -983,134 +1071,128 @@ drwxrwxrwt 10 root wheel 512 Aug 31 01:49 tmp
The FreeBSD directory hierarchy is fundamental to obtaining an overall understanding of the system.
The most important directory is root or, "/".
-This directory is the first one mounted at boot time and it contains the base system necessary to prepare the operating system for multi-user operation.
+This directory is the first one mounted at boot time and it contains the base system necessary to prepare the operating system for multi-user operation.
The root directory also contains mount points for other file systems that are mounted during the transition to multi-user operation.
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 <<disk-organization>>.
-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#.
+This is further described in crossref:basics[disk-organization, Disk Organization].
+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`.
-Details can be found in <<disks-fstab>>.
+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 crossref:basics[disks-fstab, The fstab File].
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`
+
+|`/libexec/`
+|Critical system files
-|[.filename]#/mnt/#
+|`/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/#
-|Process file system. Refer to man:procfs[5], man:mount_procfs[8] for details.
+|`/net/`
+|Automounted NFS shares; see man:auto_master[5]
+
+|`/proc/`
+|Process file system. Refer to man:procfs[5] 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#.
+|`/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/obj/#
-|Architecture-specific target tree produced by building the [.filename]#/usr/src# tree.
-
-|[.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.
-
-|[.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.
+|`/var/tmp/`
+|Temporary files which are usually preserved across a system reboot.
-|[.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.
@@ -1118,10 +1200,13 @@ A directory may contain no files, or it may contain many hundreds of files.
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.
+
+[[disks-file-systems]]
+=== File systems
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.
@@ -1137,37 +1222,37 @@ Call `A` the root file system.
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.
@@ -1177,21 +1262,42 @@ There are some drawbacks to this approach, and one advantage.
[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.
-This does not have the same meaning as the common usage of the term partition (for example, MS-DOS(R) partition), because of FreeBSD's UNIX(R) heritage.
-Each partition is identified by a letter from `a` through to `h`.
-Each partition can contain only one file system, which means that file systems are often described by either their typical mount point in the file system hierarchy, or the letter of the partition they are contained in.
+[[disks-partitions]]
+=== Disk partitions
+
+File systems are contained in _partitions_.
+Disks are divided into partitions using one of several partitioning schemes;
+see crossref:bsdinstall[bsdinstall-part-manual, Manual Partitioning].
+The newer scheme is GPT; older BIOS-based computers use MBR.
+GPT supports division of a disk into partitions with a size, offset, and type.
+It supports a large number of partitions and partition types, and is recommended whenever its use is possible.
+GPT partitions use the disk name with a suffix, where the suffix is `p1` for the first partition, `p2` for the second, and so on.
+MBR, however, supports only a small number of partitions.
+The MBR partitions are known in FreeBSD as `slices`.
+Slices may be used for different operating systems.
+FreeBSD slices are subdivided into partitions using BSD labels (see man:bsdlabel[8]).
+
+Slice numbers follow the device name, prefixed with an `s`, starting at 1.
+So "da0__s1__" is the first slice on the first SCSI drive.
+There can only be four physical slices on a disk, but there can be logical slices inside physical slices of the appropriate type.
+These extended slices are numbered starting at 5, so "ada0__s5__" is the first extended slice on the first SATA disk.
+These devices are used by file systems that expect to occupy a slice.
+
+Each GPT or BSD partition can contain only one file system, which means that file systems are often described by either their typical mount point in the file system hierarchy, or the name of the partition they are contained in.
FreeBSD also uses disk space for _swap space_ to provide _virtual memory_.
This allows your computer to behave as though it has much more memory than it actually does.
When FreeBSD runs out of memory, it moves some of the data that is not currently being used to the swap space, and moves it back in (moving something else out) when it needs it.
+This is called _paging_.
-Some partitions have certain conventions associated with them.
+Some BSD partitions have certain conventions associated with them.
-[.informaltable]
-[cols="1,1", frame="none", options="header"]
+[cols="25h,~"]
|===
| Partition
| Convention
@@ -1209,30 +1315,25 @@ Some partitions have certain conventions associated with them.
|Partition `d` used to have a special meaning associated with it, although that is now gone and `d` may work as any normal partition.
|===
-Disks in FreeBSD are divided into slices, referred to in Windows(R) as partitions, which are numbered from 1 to 4.
-These are then divided into partitions, which contain file systems, and are labeled using letters.
-
-Slice numbers follow the device name, prefixed with an `s`, starting at 1.
-So "da0__s1__" is the first slice on the first SCSI drive.
-There can only be four physical slices on a disk, but there can be logical slices inside physical slices of the appropriate type.
-These extended slices are numbered starting at 5, so "ada0__s5__" is the first extended slice on the first SATA disk.
-These devices are used by file systems that expect to occupy a slice.
-
-Slices, "dangerously dedicated" physical drives, and other drives contain _partitions_, which are represented as letters from `a` to `h`.
+Slices and "dangerously dedicated" physical drives contain BSD partitions, which are represented as letters from `a` to `h`.
This letter is appended to the device name, so "da0__a__" is the `a` partition on the first `da` drive, which is "dangerously dedicated".
"ada1s3__e__" is the fifth partition in the third slice of the second SATA disk drive.
Finally, each disk on the system is identified.
A disk name starts with a code that indicates the type of disk, and then a number, indicating which disk it is.
-Unlike slices, disk numbering starts at 0.
-Common codes are listed in <<disks-naming>>.
+Unlike partitions and slices, disk numbering starts at 0.
+Common codes are listed in crossref:basics[disks-naming,Disk Device Names].
-When referring to a partition, include the disk name, `s`, the slice number, and then the partition letter.
-Examples are shown in <<basics-disk-slice-part>>.
+When referring to a partition in a slice, include the disk name, `s`, the slice number, and then the partition letter.
+Examples are shown in crossref:basics[basics-disk-slice-part,Sample Disk, Slice, and Partition Names].
+GPT partitions include the disk name, `p`, and then the partition number.
-<<basics-concept-disk-model>> shows a conceptual model of a disk layout.
+crossref:basics[basics-concept-disk-model,Conceptual Model of a Disk] shows a conceptual model of a disk layout using MBR slices.
-When installing FreeBSD, configure the disk slices, create partitions within the slice to be used for FreeBSD, create a file system or swap space in each partition, and decide where each file system will be mounted.
+When installing FreeBSD, configure the disk slices if using MBR, and create partitions within the slice to be used for FreeBSD.
+If using GPT, configure partitions for each file system.
+In either case, create a file system or swap space in each partition, and decide where each file system will be mounted.
+See man:gpart[8] for information on manipulating partitions.
[[disks-naming]]
.Disk Device Names
@@ -1253,7 +1354,7 @@ When installing FreeBSD, configure the disk slices, create partitions within the
|SATA and IDE CD-ROM drives
|`cd`
-|SCSICD-ROM drives
+|SCSI CD-ROM drives
|`cd`
|Floppy drives
@@ -1290,31 +1391,31 @@ When installing FreeBSD, configure the disk slices, create partitions within the
====
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]
@@ -1323,7 +1424,7 @@ device /mount-point fstype options dumpfreq passno
....
`device`::
-An existing device name as explained in <<disks-naming>>.
+An existing device name as explained in crossref:basics[disks-naming,Disk Device Names].
`mount-point`::
An existing directory on which to mount the file system.
@@ -1342,13 +1443,13 @@ Used by man:dump[8] to determine which file systems require dumping.
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]
@@ -1364,11 +1465,14 @@ The most basic syntax is as follows:
....
====
-This command provides many options which are described in man:mount[8], The most commonly used options include:
+A file system listed in `/etc/fstab` can also be mounted by providing just the mountpoint.
+
+This command provides many options which are described in man:mount[8].
+The most commonly used options include:
.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.
@@ -1450,6 +1554,12 @@ For example:
[source,shell]
....
% ps
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
PID TT STAT TIME COMMAND
8203 0 Ss 0:00.59 /bin/csh
8895 0 R+ 0:00.00 ps
@@ -1472,6 +1582,12 @@ The output from man:top[1] is similar:
[source,shell]
....
% top
+....
+
+The output should be similar to the following:
+
+[.programlisting]
+....
last pid: 9609; load averages: 0.56, 0.45, 0.36 up 0+00:20:03 10:21:46
107 processes: 2 running, 104 sleeping, 1 zombie
CPU: 6.2% user, 0.1% nice, 8.2% system, 0.4% interrupt, 85.1% idle
@@ -1533,46 +1649,6 @@ Restarting `httpd` would result in a brief outage period on the web server.
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.
@@ -1596,12 +1672,12 @@ A Linux(R) user might prefer `bash`.
Each shell has unique properties that may or may not work with a user's preferred working environment, which is why there is a choice of which shell to use.
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.
+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 `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.
@@ -1609,12 +1685,12 @@ Typing a `t` and pressing kbd:[Tab] again is enough to let the shell determine w
Another feature of the shell is the use of environment variables.
Environment variables are a variable/key pair stored in the shell's environment.
This environment can be read by any program invoked by the shell, and thus contains a lot of program configuration.
-<<shell-env-vars>> provides a list of common environment variables and their meanings.
+crossref:basics[shell-env-vars,Common Environment Variables] provides a list of common environment variables and their meanings.
Note that the names of environment variables are always in uppercase.
[[shell-env-vars]]
.Common Environment Variables
-[cols="1,1", frame="none", options="header"]
+[cols="25h,~"]
|===
| Variable
| Description
@@ -1656,7 +1732,7 @@ Note that the names of environment variables are always in uppercase.
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]
....
@@ -1696,9 +1772,12 @@ For example, to change the shell to `bash`:
% chsh -s /usr/local/bin/bash
....
+Enter your password at the prompt and press kbd:[Return] to change your shell.
+Log off and log in again to start using the new shell.
+
[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:
@@ -1723,7 +1802,7 @@ To capture the output of the man:ls[1] command, for example, into a file, redire
% 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:
@@ -1747,7 +1826,7 @@ Output could be a screen or paper in a printer.
And error would be anything that is used for diagnostic or error messages.
All three are considered I/O based file descriptors and sometimes considered streams.
-Through the use of these descriptors, the shell allows output and input to be passed around through various commands and redirected to or from a file.
+Through the use of these descriptors, the shell allows output and input to be passed around through various commands and redirected to or from a file.
Another method of redirection is the pipe operator.
The UNIX(R) pipe operator, "|" allows the output of one command to be directly passed or directed to another program.
@@ -1758,7 +1837,7 @@ Basically, a pipe allows the standard output of a command to be passed as standa
% 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]]
@@ -1780,19 +1859,20 @@ These editors offer more functionality at the expense of being more complicated
Learning a more powerful editor such as vim or Emacs can save more time in the long run.
Many applications which modify files or require typed input will automatically open a text editor.
-To change the default editor, set the `EDITOR` environment variable as described in <<shells>>.
+To change the default editor, set the `EDITOR` environment variable as described
+in crossref:basics[shells, Shells].
[[basics-devices]]
== Devices and Device Nodes
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
@@ -1849,7 +1929,7 @@ If the name of the manual page is unknown, use `man -k` to search for keywords i
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]
....