FreeBSD can be used in various ways. One of them is typing commands to a text terminal. A lot of the flexibility and power of a UNIX® operating system is readily available when using FreeBSD this way. This section describes what “terminals” and “consoles” are, and how to use them in FreeBSD.
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:
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
ttyv0
indicates that this is the
system console.
The second line is the login prompt. The next section describes how to log into FreeBSD at this prompt.
FreeBSD is a multiuser, multiprocessing system. This is the formal description that is usually given to a system that can be used by many different people, who simultaneously run a lot of programs on a single machine.
Every multiuser system needs some way to distinguish one “user” from the rest. In FreeBSD (and all the UNIX®-like operating systems), this is accomplished by requiring that every user must “log into” the system before being able to run programs. Every user has a unique name (the “username”) and a personal, secret key (the “password”). FreeBSD will ask for these two before allowing a user to run any programs.
When a FreeBSD system boots, startup scripts are automatically executed in order to prepare the system and to start any services which have been configured to start at system boot. Once the system finishes running its startup scripts, it will present a login prompt:
Type the username that was configured during system installation, as described in Section 2.9.6, “Add Users”, and press Enter. Then enter the password associated with the username and press 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 (a #
,
$
, or %
character). You
are now logged into the FreeBSD console and ready to try the
available commands.
FreeBSD can be configured to provide many virtual consoles for inputting commands. Each virtual console has its own login prompt and output channel, and FreeBSD takes care of properly redirecting keyboard input and monitor output as switching occurs between virtual consoles.
Special key combinations have been reserved by FreeBSD for switching consoles.[1]. Use Alt+F1, Alt+F2, through Alt+F8 to switch to a different virtual console in FreeBSD.
When switching from one console to the next, FreeBSD takes care of saving and restoring the screen output. The result is an “illusion” of having multiple “virtual” screens and keyboards that can be used to type commands for FreeBSD to run. The programs that are launched in one virtual console do not stop running when that console is not visible because the user has switched to a different virtual console.
By default, FreeBSD is configured to start eight virtual
consoles. The configuration can be customized to start
more or fewer virtual consoles. To change the number of and
the settings of the virtual consoles, edit
/etc/ttys
.
Each uncommented line in /etc/ttys
(lines that do not start with a #
character) contains settings for a single terminal or virtual
console. The default version configures nine virtual
consoles, and enables eight of them. They are the lines that
start with ttyv
:
For a detailed description of every column in this file and the available options for the virtual consoles, refer to ttys(5).
A detailed description of “single user mode”
can be found in Section 13.6.2, “Single-User Mode”. There is
only one console when FreeBSD is in single user mode as no other
virtual consoles are available in this mode. The settings
for single user mode are found in this section of
/etc/ttys
:
As the comments above the console
line indicate, editing secure
to
insecure
will prompt for the
root
password when booting into single
user mode. The default setting enters single user mode
without prompting for a password.
Be careful when changing this setting to
insecure
. If the
root
password is forgotten, booting
into single user mode is still possible, but may be
difficult for someone who is not comfortable with the FreeBSD
booting process.
The FreeBSD console default video mode may be adjusted to
1024x768, 1280x1024, or any other size supported by the
graphics chip and monitor. To use a different video mode
load the VESA
module:
#
kldload vesa
To determine which video modes are supported by the hardware, use vidcontrol(1). To get a list of supported video modes issue the following:
#
vidcontrol -i mode
The output of this command lists the video modes that are
supported by the hardware. To select a new video mode,
specify the mode using vidcontrol(1) as the
root
user:
#
vidcontrol MODE_279
If the new video mode is acceptable, it can be permanently
set on boot by adding it to
/etc/rc.conf
:
[1] Refer to syscons(4), atkbd(4), vidcontrol(1) and kbdcontrol(1) for a more technical description of the FreeBSD console and its keyboard drivers.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.