diff --git a/en_US.ISO8859-1/books/handbook/basics/chapter.xml b/en_US.ISO8859-1/books/handbook/basics/chapter.xml
index dfa2d22d5a..8cfa367f3a 100644
--- a/en_US.ISO8859-1/books/handbook/basics/chapter.xml
+++ b/en_US.ISO8859-1/books/handbook/basics/chapter.xml
@@ -1,3646 +1,3645 @@
UNIX BasicsSynopsisThis chapter covers the basic commands and functionality of
the &os; operating system. Much of this material is relevant
for any &unix;-like operating system. New &os; users are
encouraged to read through this chapter carefully.After reading this chapter, you will know:How to use and configure virtual consoles.How to create and manage users and groups on
&os;.How &unix; file permissions and &os; file flags
work.The default &os; file system layout.The &os; disk organization.How to mount and unmount file systems.What processes, daemons, and signals are.What a shell is, and how to change the default login
environment.How to use basic text editors.What devices and device nodes are.How to read manual pages for more information.Virtual Consoles and Terminalsvirtual consolesterminalsconsoleUnless &os; 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:FreeBSD/amd64 (pc3.example.org) (ttyv0)
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 &os;. The hostname is
pc3.example.org, and
ttyv0 indicates that this is the
system console. The second line is the login
prompt.Since &os; 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.To log into the system console, type the username that
was configured during system installation, as described in
, 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. 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 &os; system console and ready
to try the available commands.Virtual ConsolesWhile the system console can be used to interact with
the system, a user working from the command line at the
keyboard of a &os; system will typically instead log into a
virtual console. This is because system messages are
configured by default to display on the system console.
These messages will appear over the command or file that the
user is working on, making it difficult to concentrate on
the work at hand.By default, &os; is configured to provide several virtual
consoles for inputting commands. Each virtual console has
its own login prompt and shell and it is easy to switch
between virtual consoles. This essentially provides the
command line equivalent of having several windows open at the
same time in a graphical environment.The key combinations
AltF1
through
AltF8
have been reserved by &os; for switching between virtual
consoles. Use
AltF1
to switch to the system console
(ttyv0),
AltF2
to access the first virtual console
(ttyv1),
AltF3
to access the second virtual console
(ttyv2), and so on.When switching from one console to the next, &os; takes
manages the screen output. The result is an illusion of
having multiple virtual screens and keyboards that can be used
to type commands for &os; to run. The programs that are
launched in one virtual console do not stop running when
the user switches to a different virtual console.Refer to &man.syscons.4;, &man.atkbd.4;,
&man.vidcontrol.1; and &man.kbdcontrol.1; for a more
technical description of the &os; console and its keyboard
drivers.In &os;, the number of available virtual consoles is
configured in this section of
/etc/ttys:# name getty type status comments
#
ttyv0 "/usr/libexec/getty Pc" cons25 on secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" cons25 on secure
ttyv2 "/usr/libexec/getty Pc" cons25 on secure
ttyv3 "/usr/libexec/getty Pc" cons25 on secure
ttyv4 "/usr/libexec/getty Pc" cons25 on secure
ttyv5 "/usr/libexec/getty Pc" cons25 on secure
ttyv6 "/usr/libexec/getty Pc" cons25 on secure
ttyv7 "/usr/libexec/getty Pc" cons25 on secure
ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secureTo 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
.For a detailed description of every column in this file
and the available options for the virtual consoles, refer to
&man.ttys.5;.Single User ModeThe &os; boot menu provides an option labelled as
Boot Single User. If this option is selected,
the system will boot into a special mode known as
single user mode. This mode is typically used
to repair a system that will not boot or to reset the
root password when
it is not known. While in single user mode, networking and
other virtual consoles are not available. 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 &os; system.The settings which control single user mode are found in
this section of /etc/ttys:# name getty type status comments
#
# If console is marked "insecure", then init will ask for the root password
# when going to single-user mode.
console none unknown off secureBy default, the status is set to
secure. This assumes that who has physical
access to the keyboard is either not important or it is
controlled by a physical security policy. If this setting is
changed to insecure, the assumption is that
the environment itself is insecure because anyone can access
the keyboard. When this line is changed to
insecure, &os; will prompt for the
root password when a
user selects to boot into single user mode.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 familiar with
the &os; booting process.Changing Console Video ModesThe &os; 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:&prompt.root; kldload vesaTo determine which video modes are supported by the
hardware, use &man.vidcontrol.1;. To get a list of supported
video modes issue the following:&prompt.root; vidcontrol -i modeThe output of this command lists the video modes that are
supported by the hardware. To select a new video mode,
specify the mode using &man.vidcontrol.1; as the
root user:&prompt.root; vidcontrol MODE_279If the new video mode is acceptable, it can be permanently
set on boot by adding it to
/etc/rc.conf:allscreens_flags="MODE_279"Users and Basic Account Management&os; allows multiple users to use the computer at the same
time. While only one user can sit in front of the screen and
use the keyboard at any one time, any number of users can log
in to the system through the network. To use the system, each
user should have their own user account.This chapter describes:The different types of user accounts on a
&os; system.How to add, remove, and modify user accounts.How to set limits to control the
resources that users and
groups are allowed to access.How to create groups and add users as members of a
group.Account TypesSince all access to the &os; system is achieved using
accounts and all processes are run by users, user and account
management is important.There are three main types of accounts: system accounts,
user accounts, and the superuser account.System AccountsaccountssystemSystem accounts are used to run services such as DNS,
mail, and web servers. The reason for this is security; if
all services ran as the superuser, they could act without
restriction.accountsdaemonaccountsoperatorExamples of system accounts are
daemon,
operator,
bind,
news, and
www.accountsnobodynobody 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.User AccountsaccountsuserUser accounts are assigned to real people and are used
to log in and use the system. Every person accessing the
system should have a unique user account. This allows the
administrator to find out who is doing what and prevents
users from clobbering the settings of other users.Each user can set up their own environment to
accommodate their use of the system, by configuring their
default shell, editor, key bindings, and language
settings.Every user account on a &os; system has certain
information associated with it:User nameThe user name is typed at the
- login: prompt. User names must be
- unique on the system as no two users can have the same
+ login: prompt. 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.Password
- Each user account should have an associated
- password. While the password can be blank, this is
- highly discouraged.
+ Each account has an associated password.User ID (UID)The User ID (UID) is a number
used to uniquely identify the user to the &os; system.
Commands that allow a user name to be specified will
first convert it to the UID. It is
recommended to use a UID of 65535 or lower as higher
UIDs may cause compatibility issues with software that
does not support integers larger than 32-bits.Group ID (GID)The Group ID (GID) is a number
used to uniquely identify the primary group that the
user belongs to. Groups are a mechanism for
controlling access to resources based on a user's
GID rather than their
UID. This can significantly reduce
the size of some configuration files and allows users
to be members of more than one group. It is
recommended to use a GID of 65535 or lower as higher
GIDs may break some software.Login classLogin classes are an extension to the group
mechanism that provide additional flexibility when
tailoring the system to different users. Login
classes are discussed further in
Password change time
- By default, &os; does not force users to change
- their passwords periodically. Password expiration can
- be enforced on a per-user basis using &man.pw.8;,
+ By default, passwords do not expire. However,
+ password expiration can be enabled on a per-user basis,
forcing some or all users to change their passwords
after a certain amount of time has elapsed.Account expiry timeBy default, &os; does not expire accounts. When
creating accounts that need a limited lifespan, such
as student accounts in a school, specify the account
expiry date using &man.pw.8;. After the expiry time
has elapsed, the account cannot be used to log in to
the system, although the account's directories and
files will remain.User's full nameThe user name uniquely identifies the account to
&os;, but does not necessarily reflect the user's real
name. Similar to a comment, this information can
contain a space, uppercase characters, and be more
than 8 characters long.Home directoryThe 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
/home/username or
/usr/home/username. Each user
stores their personal files and subdirectories in
their own home directory.User shellThe shell provides the user's default environment
for interacting with the system. There are many
different kinds of shells and experienced users will
have their own preferences, which can be reflected in
their account settings.The Superuser Accountaccountssuperuser (root)The superuser account, usually called
root, is used to
manage the system with no limitations on privileges. For
this reason, it should not be used for day-to-day tasks like
sending and receiving mail, general exploration of the
system, or programming.The superuser, unlike other user accounts, can operate
without limits, and misuse of the superuser account may
result in spectacular disasters. User accounts are unable
to destroy the operating system by mistake, so it is
recommended to login as a user account and to only become
the superuser when a command requires extra
privilege.Always double and triple-check any commands issued as
the superuser, since an extra space or missing character can
mean irreparable data loss.
- There are several ways to become gain superuser
+ There are several ways to gain superuser
privilege. While one can log in as
root, this is
highly discouraged.Instead, use &man.su.1; to become the superuser. If
- is specified when running this command,
the user will also inherit the root user's environment. The
user running this command must be in the
wheel group or
else the command will fail. The user must also know the
password for the
root user
account.In this example, the user only becomes superuser in
order to run make install as this step
requires superuser privilege. Once the command completes,
the user types exit to leave the
superuser account and return to the privilege of their user
account.Install a Program As the Superuser&prompt.user; configure
&prompt.user; make
&prompt.user; su -
Password:
&prompt.root; make install
&prompt.root; exit
&prompt.user;The built-in &man.su.1; framework works well for single
systems or small networks with just one system
administrator. An alternative is to install the
security/sudo package or port. This
software provides activity logging and allows the
administrator to configure which users can run which
commands as the superuser.Managing Accountsaccountsmodifying&os; provides a variety of different commands to manage
user accounts. The most common commands are summarized in
Table 4.1, followed by some examples of their usage. Refer to
the manual page for each utility for more details and usage
examples.
Utilities for Managing User AccountsCommandSummary&man.adduser.8;The recommended command-line application for
adding new users.&man.rmuser.8;The recommended command-line application for
removing users.&man.chpass.1;A flexible tool for changing user database
information.&man.passwd.1;The command-line tool to change user
passwords.&man.pw.8;A powerful and flexible tool for modifying all
aspects of user accounts.
adduseraccountsaddingadduser/usr/share/skelskeleton directoryThe recommended program for adding new users is
&man.adduser.8;. 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
+ superuser.
The &man.adduser.8; utility is interactive and walks
through the steps for creating a new user account. As seen
- in Example 4.2, either input the required information or
+ in ,
+ either input the required information or
press Return to accept the default value
shown in square brackets. In this example, the user has
been invited into the
wheel group,
which is required to provide the account with superuser
access. When finished, the utility will prompt to either
create another user or to exit.
-
+ Adding a User on &os;&prompt.root; adduser
Username: jru
Full name: J. Random User
Uid (Leave empty for default):
Login group [jru]:
Login group is jru. Invite jru into other groups? []: wheel
Login class [default]:
Shell (sh csh tcsh zsh nologin) [sh]: zsh
Home directory [/home/jru]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : jru
Password : ****
Full Name : J. Random User
Uid : 1001
Class :
Groups : jru wheel
Home : /home/jru
Shell : /usr/local/bin/zsh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (jru) to the user database.
Add another user? (yes/no): no
Goodbye!
&prompt.root;Since the password is not echoed when typed, be
careful to not mistype the password when creating the user
account.rmuserrmuseraccountsremovingTo completely remove a user from the system, run
&man.rmuser.8; as the superuser. This command performs the
following steps: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.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 /var/mail.Removes all files owned by the user from temporary
file storage areas such as
/tmp.Finally, 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
the per-user unique groups created by
&man.adduser.8;.&man.rmuser.8; cannot be used to remove superuser
accounts since that is almost always an indication of
massive destruction.By default, an interactive mode is used, as shown
in the following example.rmuser Interactive Account
Removal&prompt.root; rmuser jru
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.
&prompt.root;chpasschpassAny 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.When passed no options, aside from an optional username,
&man.chpass.1; displays an editor containing user
- information. When the user exists from the editor, the user
+ information. When the user exits from the editor, the user
database is updated with the new information.This utility will prompt for the user's password when
exiting the editor, unless the utility is run as the
superuser.
- In Example 4.4, the superuser has typed
+ In ,
+ 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 Example
- 4.5.
+ and available for editing. This is shown in
+ .
-
+ Using chpass as
Superuser#Changing user database information for jru.
Login: jru
Password: *
Uid [#]: 1001
Gid [# or name]: 1001
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /home/jru
Shell: /usr/local/bin/zsh
Full Name: J. Random User
Office Location:
Office Phone:
Home Phone:
Other information:
-
+ Using chpass as Regular
User#Changing user database information for jru.
Shell: /usr/local/bin/zsh
Full Name: J. Random User
Office Location:
Office Phone:
Home Phone:
Other information:&man.chfn.1; and &man.chsh.1; are links to
&man.chpass.1;, as are &man.ypchpass.1;, &man.ypchfn.1;,
and &man.ypchsh.1;. Since NIS support
is automatic, specifying the yp before
the command is not necessary. How to configure NIS is
covered in .passwdpasswdaccountschanging passwordAny 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:Changing Your Password&prompt.user; passwd
Changing local password for jru.
Old password:
New password:
Retype new password:
passwd: updating the database...
passwd: doneThe superuser can change any user's password by
specifying the username when running &man.passwd.1;. When
this utility is run as the superuser, it will not prompt for
the user's current password. This allows the password to be
changed when a user cannot remember the original
password.Changing Another User's Password as the
Superuser&prompt.root; passwd jru
Changing local password for jru.
New password:
Retype new password:
passwd: updating the database...
passwd: doneAs with &man.chpass.1;, &man.yppasswd.1; is a link to
&man.passwd.1;, so NIS works with
either command.pwpw&man.pw.8; is a command line utility to create, remove,
modify, and display users and groups. It functions as a
front end to the system user and group files. &man.pw.8;
has a very powerful set of command line options that make it
suitable for use in shell scripts, but new users may find it
more complicated than the other commands presented in this
section.Limiting Userslimiting usersaccountslimiting&os; provides several methods for an administrator to
limit the amount of system resources an individual may use.
These limits are discussed in two sections: disk quotas and
other resource limits.quotaslimiting usersquotasdisk quotasDisk quotas limit the amount of disk space available to
users and provide a way to quickly check that usage without
calculating it every time. Quotas are discussed in
.The other resource limits include ways to limit the amount
of CPU, memory, and other resources a user may consume. These
are defined using login classes and are discussed here./etc/login.confLogin classes are defined in
/etc/login.conf and are described in
detail in &man.login.conf.5;. Each user account is assigned
to a login class, default by default, and
each login class has a set of login capabilities associated
with it. A login capability is a
name=value pair, where
name is a well-known identifier and
value is an arbitrary string which
is processed accordingly depending on the
name. Setting up login classes and
capabilities is rather straightforward and is also described
in &man.login.conf.5;.&os; does not normally read the configuration in
/etc/login.conf directly, but instead
reads the /etc/login.conf.db database
which provides faster lookups. Whenever
/etc/login.conf is edited, the
/etc/login.conf.db must be updated by
executing the following command:&prompt.root; cap_mkdb /etc/login.confResource limits differ from the default login capabilities
in two ways. First, for every limit, there is a soft
(current) and hard limit. A soft limit may be adjusted by the
user or application, but may not be set higher than the hard
limit. The hard limit may be lowered by the user, but can
only be raised by the superuser. Second, most resource limits
apply per process to a specific user, not to the user as a
whole. These differences are mandated by the specific
handling of the limits, not by the implementation of the login
capability framework.Below are the most commonly used resource limits. The
rest of the limits, along with all the other login
capabilities, can be found in &man.login.conf.5;.coredumpsizeThe limit on the size of a core file
coredumpsize
generated by a program is subordinate to other limits
limiting userscoredumpsize
on disk usage, such as filesize, or
disk quotas. This limit is often used as a less-severe
method of controlling disk space consumption. Since
users do not generate core files themselves, and often
do not delete them, setting this may save them from
running out of disk space should a large program
crash.cputimeThe maximum amount of CPU
cputimelimiting userscputime
time a user's process may consume. Offending processes
will be killed by the kernel.This is a limit on CPU time
consumed, not percentage of the CPU as displayed in
some fields by &man.top.1; and &man.ps.1;.filesizeThe maximum size of a file
filesizelimiting usersfilesize
the user may own. Unlike
disk quotas, this limit is
enforced on individual files, not the set of all files a
user owns.maxprocThe maximum number of processes
maxproclimiting usersmaxproc
a user can run. This includes foreground and background
processes. This limit may not be larger than the system
limit specified by the kern.maxproc
&man.sysctl.8;. Setting this limit too small may hinder
a user's productivity as it is often useful to be logged
in multiple times or to execute pipelines. Some tasks,
- such as compiling a large program, spawn multiple
- processes and other intermediate preprocessors.
+ such as compiling a large program, start lots of
+ processes.
memorylockedThe maximum amount of memory
memorylockedlimiting usersmemorylocked
a process may request to be locked into main memory
using &man.mlock.2;. Some system-critical programs,
such as &man.amd.8;, lock into main memory so that if
the system begins to swap, they do not contribute to
disk thrashing.memoryuseThe maximum amount of memory
memoryuselimiting usersmemoryuse
a process may consume at any given time. It includes
both core memory and swap usage. This is not a
catch-all limit for restricting memory consumption, but
is a good start.openfilesThe maximum number of files a process may have open
openfileslimiting usersopenfiles.
In &os;, files are used to represent sockets and IPC
channels, so be careful not to set this too low. The
system-wide limit for this is defined by the
kern.maxfiles &man.sysctl.8;.sbsizeThe limit on the amount of network memory, and
thus mbufs
sbsizelimiting userssbsize,
- a user may consume in order to limit network
- communications.
+ a user may consume. This can be generally used to limit
+ network communications.
stacksizeThe maximum size of a process stack
stacksizelimiting usersstacksize.
This alone is not sufficient to limit the amount of
memory a program may use so it should be used in
conjunction with other limits.There are a few other things to remember when setting
resource limits. Following are some general tips,
suggestions, and miscellaneous comments.Processes started at system startup by
/etc/rc are assigned to the
daemon login class.Although the /etc/login.conf that
comes with the system is a good source of reasonable
values for most limits, they may not be appropriate for
every system. Setting a limit too high may open the
system up to abuse, while setting it too low may put a
strain on productivity.Users of &xorg; should
probably be granted more resources than other users.
&xorg; by itself takes a lot of
resources, but it also encourages users to run more
programs simultaneously.Many limits apply to individual processes, not the
user as a whole. For example, setting
openfiles to 50 means that each process
the user runs may open up to 50 files. The total amount
of files a user may open is the value of
openfiles multiplied by the value of
maxproc. This also applies to memory
consumption.For further information on resource limits and login
classes and capabilities in general, refer to
&man.cap.mkdb.1;, &man.getrlimit.2;, and
&man.login.conf.5;.Managing Groupsgroups/etc/groupsaccountsgroupsA group is a list of users. A group is identified by its
group name and GID. In &os;, 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 /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 /etc/group
using a text editor. 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:Adding a Group Using &man.pw.8;&prompt.root; pw groupadd teamtwo
&prompt.root; pw groupshow teamtwo
teamtwo:*:1100:In this example, 1100 is the
GID of
teamtwo. Right
now, teamtwo has no
members. This command will add
jru as a member of
teamtwo.Adding User Accounts to a New Group Using
&man.pw.8;&prompt.root; pw groupmod teamtwo -M jru
&prompt.root; pw groupshow teamtwo
teamtwo:*:1100:jruThe argument to 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
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 /etc/group and does not
attempt to read additional data from
/etc/passwd.Adding a New Member to a Group Using &man.pw.8;&prompt.root; pw groupmod teamtwo -m db
&prompt.root; pw groupshow teamtwo
teamtwo:*:1100:jru,dbIn this example, the argument to is a
comma-delimited list of users who are to be added to the
group. Unlike the previous example, these users are appended
- to the group list and do not replace the list of existing
+ to the group and do not replace existing
users in the group.Using &man.id.1; to Determine Group Membership&prompt.user; id jru
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
/etc/group, refer to &man.pw.8; and
&man.group.5;.PermissionsUNIXIn &os;, 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; permissions
used in &os;. For finer grained file system access control,
refer to .In &unix;, 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). The read, write, and execute
permissions can be represented as the letters
r, w, and
x. They can also be represented as binary
numbers as each permission is either on or off
(0). When represented as a number, the
order is always read as rwx, where
r has an on value of 4,
w has an on value of 2
and x has an on value of
1.Table 4.1 summarizes the possible numeric and alphabetic
possibilities. When reading the Directory
Listing column, a - is used to
represent a permission that is set to off.permissionsfile permissions
&unix; PermissionsValuePermissionDirectory Listing0No read, no write, no execute---1No read, no write, execute--x2No read, write, no execute-w-3No read, write, execute-wx4Read, no write, no executer--5Read, no write, executer-x6Read, write, no executerw-7Read, write, executerwx
&man.ls.1;directoriesUse the 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, a ls -l in an arbitrary
directory may show:&prompt.user; ls -l
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.txtThe 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. 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. The final
three characters, r--, give the permissions
for the rest of the world. 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? &os;
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. The executable bit for a
directory has a slightly different meaning than that of files.
When a directory is marked executable, it means it is possible
to change into that directory using &man.cd.1;. This also
means that it is possible to access the files within that
directory, subject to the permissions on the files
themselves.In order to perform a directory listing, the read permission
must be set on the directory. In order to delete a file that
one knows the name of, it is necessary to have write
and execute permissions to the directory
containing the file.There are more permission bits, but they are primarily used
in special circumstances such as setuid binaries and sticky
directories. For more information on file permissions and how
to set them, refer to &man.chmod.1;.Symbolic PermissionsTomRhodesContributed by permissionssymbolicSymbolic permissions use characters instead of octal
values to assign permissions to files or directories.
Symbolic permissions use the syntax of (who) (action)
(permissions), where the following values are
available:OptionLetterRepresents(who)uUser(who)gGroup owner(who)oOther(who)aAll (world)(action)+Adding permissions(action)-Removing permissions(action)=Explicitly set permissions(permissions)rRead(permissions)wWrite(permissions)xExecute(permissions)tSticky bit(permissions)sSet UID or GIDThese 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:&prompt.user; chmod go= FILEA comma separated list can be provided when more than one
set of changes to a file must be made. For example, the
following command removes the group and
world write permission on
FILE, and adds the execute
permissions for everyone:&prompt.user; chmod go-w,a+x FILE&os; File FlagsTomRhodesContributed by In addition to file permissions, &os; supports the use of
file flags. These flags add an additional
level of security and control over files, but not directories.
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
file1, issue the following
command:&prompt.root; chflags sunlink file1To disable the system undeletable flag, put a
no in front of the
:&prompt.root; chflags nosunlink file1To view the flags of a file, use with
&man.ls.1;:&prompt.root; ls -lo file1-rw-r--r-- 1 trhodes trhodes sunlnk 0 Mar 1 05:54 file1Several 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
PermissionsTomRhodesContributed by 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.These settings are important for some &unix; operations
as they provide functionality not normally granted to normal
users. To understand them, the difference between the real
user ID and effective user ID must be noted.The real user ID is the UID who owns
or starts the process. The effective UID
is the user ID the process runs as. As an example,
&man.passwd.1; runs with the real user ID when a user changes
their password. 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:&prompt.root; chmod 4755 suidexample.shThe permissions on
suidexample.sh
now look like the following:-rwsr-xr-x 1 trhodes trhodes 63 Aug 29 06:36 suidexample.shNote that a s is now part of the
permission set designated for the file owner, replacing the
executable bit. This allows utilities which need elevated
permissions, such as &man.passwd.1;.The nosuid &man.mount.8; option will
cause such binaries to silently fail without alerting
the user. That option is not completely reliable as a
nosuid wrapper may be able to circumvent
it.To view this in real time, open two terminals. On
one, type passwd as a normal user.
While it waits for a new password, check the process
table and look at the user information for
&man.passwd.1;:In terminal A:Changing local password for trhodes
Old Password:In terminal B:&prompt.root; ps aux | grep passwdtrhodes 5232 0.0 0.2 3420 1608 0 R+ 2:10AM 0:00.00 grep passwd
root 5211 0.0 0.2 3620 1724 2 I+ 2:09AM 0:00.01 passwdAlthough &man.passwd.1; is run as a normal user, it is
using the effective UID of
root.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):&prompt.root; chmod 2755 sgidexample.shIn the following listing, notice that the
s is now in the field designated for the
group permission settings:-rwxr-sr-x 1 trhodes trhodes 44 Aug 31 01:49 sgidexample.shIn these examples, even though the shell script in
question is an executable file, it will not run with
a different EUID or effective user ID.
This is because shell scripts may not access the
&man.setuid.2; system calls.The setuid and
setgid permission bits may lower system
security, by allowing for elevated permissions. 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 /tmp, by users
who do not own the file. To utilize this permission, prefix
the permission set with a one (1):&prompt.root; chmod 1777 /tmpThe sticky bit permission will display
as a t at the very end of the permission
set:&prompt.root; ls -al / | grep tmpdrwxrwxrwt 10 root wheel 512 Aug 31 01:49 tmpDirectory Structuredirectory hierarchyThe &os; 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. 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
. 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
/etc/fstab are mounted automatically at
boot time from the script &man.rc.8; unless their entry includes
. 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.DirectoryDescription/Root directory of the file system./bin/User utilities fundamental to both single-user
and multi-user environments./boot/Programs and configuration files used during
operating system bootstrap./boot/defaults/Default boot configuration files. Refer to
&man.loader.conf.5; for details./dev/Device nodes. Refer to &man.intro.4; for
details./etc/System configuration files and scripts./etc/defaults/Default system configuration files. Refer to
&man.rc.8; for details./etc/mail/Configuration files for mail transport agents
such as &man.sendmail.8;./etc/namedb/&man.named.8; configuration files./etc/periodic/Scripts that run daily, weekly, and monthly,
via &man.cron.8;. Refer to &man.periodic.8; for
details./etc/ppp/&man.ppp.8; configuration files./mnt/Empty directory commonly used by system
administrators as a temporary mount point./proc/Process file system. Refer to &man.procfs.5;,
&man.mount.procfs.8; for details./rescue/Statically linked programs for emergency
recovery as described in &man.rescue.8;./root/Home directory for the
root
account./sbin/System programs and administration utilities
fundamental to both single-user and multi-user
environments./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./usr/The majority of user utilities and
applications./usr/bin/Common utilities, programming tools, and
applications./usr/include/Standard C include files./usr/lib/Archive libraries./usr/libdata/Miscellaneous utility data files./usr/libexec/System daemons and system utilities executed
by other programs./usr/local/Local executables and libraries. Also used as
the default destination for the &os; 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./usr/obj/Architecture-specific target tree produced by
building the /usr/src
tree./usr/ports/The &os; Ports Collection (optional)./usr/sbin/System daemons and system utilities executed
by users./usr/share/Architecture-independent files./usr/src/BSD and/or local source files./var/Multi-purpose log, temporary, transient, and
spool files. A memory-based file system is sometimes
mounted at
/var. This can
be automated using the varmfs-related variables in
&man.rc.conf.5; or with an entry in
/etc/fstab; refer to
&man.mdmfs.8; for details./var/log/Miscellaneous system log files./var/mail/User mailbox files./var/spool/Miscellaneous printer and mail system spooling
directories./var/tmp/Temporary files which are usually preserved
across a system reboot, unless
/var is a
memory-based file system./var/yp/NIS maps.Disk OrganizationThe smallest unit of organization that &os; uses to find
files is the filename. Filenames are case-sensitive, which
means that readme.txt and
README.TXT are two separate files. &os;
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. 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
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; which uses \ to
separate file and directory names. &os; does not use drive
letters, or other drive names in the path. For example, one
would not type c:/foo/bar/readme.txt on
&os;.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. This root directory can contain other directories.
One file system is designated the
root file system or /.
Every other file system is mounted under
the root file system. No matter how many disks are on the &os;
system, every directory appears to be part of the same
disk.Consider three file systems, called A,
B, and C. Each file
system has one root directory, which contains two other
directories, called A1, A2
(and likewise B1, B2 and
C1, C2).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: /
|
+--- A1
|
`--- A2A 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: /
|
+--- A1
| |
| +--- B1
| |
| `--- B2
|
`--- A2Any 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: /
|
+--- A1
|
`--- A2
|
+--- B1
|
`--- B2and 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: /
|
+--- A1
|
`--- A2
|
+--- B1
| |
| +--- C1
| |
| `--- C2
|
`--- B2Or C could be mounted directly on to the
A file system, under the
A1 directory: /
|
+--- A1
| |
| +--- C1
| |
| `--- C2
|
`--- A2
|
+--- B1
|
`--- B2It 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 SystemsDifferent 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.&os; 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.&os;'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.Benefit of a Single File SystemFile systems are a fixed size. If you create a file
system when you install &os; and give it a specific size,
you may later discover that you need to make the partition
bigger. This is not easily accomplished without backing up,
recreating the file system with the new size, and then
restoring the backed up data.&os; features the &man.growfs.8; command, which makes
it possible to increase the size of file system on the
fly, removing this limitation.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; partition), because of &os;'s &unix;
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.&os; 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 &os; 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.Some partitions have certain conventions associated with
them.PartitionConventionaNormally contains the root file system.bNormally contains swap space.cNormally the same size as the enclosing slice.
This allows utilities that need to work on the entire
slice, such as a bad block scanner, to work on the
c partition. A file system would not
normally be created on this partition.dPartition 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 &os; are divided into slices, referred to in
&windows; as partitions, which are numbered from 1 to 4. These
are then divided into partitions, which contain file systems,
and are labeled using letters.slicespartitionsdangerously dedicatedSlice numbers follow the device name, prefixed with an
s, starting at 1. So
da0s1 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 ad0s5 is
the first extended slice on the first IDE 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. This
letter is appended to the device name, so
da0a is the
a partition on the first
da drive, which is
dangerously dedicated.
ad1s3e is the fifth
partition in the third slice of the second IDE 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
.When referring to a partition, include the disk name,
s, the slice number, and then the partition
letter. Examples are shown in
. shows a
conceptual model of a disk layout.When installing &os;, configure the disk slices, create
partitions within the slice to be used for &os;, create a file
system or swap space in each partition, and decide where each
file system will be mounted.
Disk Device CodesCodeMeaningadATAPI (IDE) diskdaSCSI direct access diskacdATAPI (IDE) CDROMcdSCSI CDROMfdFloppy disk
Sample Disk, Slice, and Partition NamesNameMeaningad0s1aThe first partition (a) on the
first slice (s1) on the first IDE
disk (ad0).da1s2eThe fifth partition (e) on the
second slice (s2) on the second
SCSI disk (da1).Conceptual Model of a DiskThis diagram shows &os;'s view of the first IDE disk
attached to the system. Assume that the disk is 4 GB in
size, and contains two 2 GB slices (&ms-dos; partitions).
The first slice contains a &ms-dos; disk,
C:, and the second slice contains a
&os; installation. This example &os; installation has three
data partitions, and a swap partition.The three partitions will each hold a file system.
Partition a will be used for the root file
system, e for the
/var/ directory
hierarchy, and f for the
/usr/ directory
hierarchy..-----------------. --.
| | |
| DOS / Windows | |
: : > First slice, ad0s1
: : |
| | |
:=================: ==: --.
| | | Partition a, mounted as / |
| | > referred to as ad0s2a |
| | | |
:-----------------: ==: |
| | | Partition b, used as swap |
| | > referred to as ad0s2b |
| | | |
:-----------------: ==: | Partition c, no
| | | Partition e, used as /var > file system, all
| | > referred to as ad0s2e | of FreeBSD slice,
| | | | ad0s2c
:-----------------: ==: |
| | | |
: : | Partition f, used as /usr |
: : > referred to as ad0s2f |
: : | |
| | | |
| | --' |
`-----------------' --'Mounting and Unmounting File SystemsThe 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.root file systemThere are various reasons to house some of these
directories on separate file systems.
/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 ,
or CDROM drives.The fstab Filefile systemsmounted with fstabDuring the boot process (), file
systems listed in /etc/fstab are
automatically mounted except for the entries containing
. This file contains entries in the
following format:device/mount-pointfstypeoptionsdumpfreqpassnodeviceAn existing device name as explained in
.mount-pointAn existing directory on which to mount the file
system.fstypeThe file system type to pass to &man.mount.8;. The
default &os; file system is
ufs.optionsEither for read-write file
systems, or for read-only file
systems, followed by any other options that may be
needed. A common option is for
file systems not normally mounted during the boot
sequence. Other options are listed in
&man.mount.8;.dumpfreqUsed by &man.dump.8; to determine which file systems
require dumping. If the field is missing, a value of
zero is assumed.passnoDetermines the order in which file systems should be
checked. 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 /etc/fstab and its options.Using &man.mount.8;file systemsmountingFile systems are mounted using &man.mount.8;. The most
basic syntax is as follows:&prompt.root; mount device mountpointThis command provides many options which are described in
&man.mount.8;, The most commonly used options include:Mount OptionsMount all the file systems listed in
/etc/fstab, except those marked as
noauto, excluded by the
flag, or those that are already
mounted.Do everything except for the actual mount system
call. This option is useful in conjunction with the
flag to determine what &man.mount.8;
is actually trying to do.Force the mount of an unclean file system
(dangerous), or the revocation of write access when
downgrading a file system's mount status from read-write
to read-only.Mount the file system read-only. This is identical
to using .fstypeMount the specified file system type or mount only
file systems of the given type, if
is included. ufs is the default file
system type.Update mount options on the file system.Be verbose.Mount the file system read-write.The following options can be passed to
as a comma-separated list:nosuidDo not interpret setuid or setgid flags on the
file system. This is also a useful security
option.Using &man.umount.8;file systemsunmountingTo unmount a file system use &man.umount.8;. This command
takes one parameter which can be a mountpoint, device name,
or .All forms take to force unmounting,
and for verbosity. Be warned that
is not generally a good idea as it might
crash the computer or damage data on the file system.To unmount all mounted file systems, or just the file
system types listed after , use
or . Note that
does not attempt to unmount the root file
system.Processes and Daemons&os; is a multi-tasking operating system. Each program
running at any one time is called a
process. Every running command starts
at least one new process and there are a number of system
processes that are run by &os;.Each process is uniquely identified by a number called a
process ID (PID).
Similar to files, each process has one owner and group, and
the owner and group permissions are used to determine which
files and devices the process can open. Most processes also
have a parent process that started them. For example, the
shell is a process, and any command started in the shell is a
process which has the shell as its parent process. The
exception is a special process called &man.init.8; which is
always the first process to start at boot time and which always
has a PID of 1.Some programs are not designed to be run with continuous
user input and disconnect from the terminal at the first
opportunity. For example, a web server responds to web
requests, rather than user input. Mail servers are another
example of this type of application. These types of programs
are known as daemons. The term daemon
comes from Greek mythology and represents an entity that is
neither good nor evil, and which invisibly performs useful
tasks. This is why the BSD mascot is the cheerful-looking
daemon with sneakers and a pitchfork.There is a convention to name programs that normally run as
daemons with a trailing d. For example,
BIND is the Berkeley Internet Name
Domain, but the actual program that executes is
named. The
Apache web server program is
httpd and the line printer spooling daemon
is lpd. This is only a naming convention.
For example, the main mail daemon for the
Sendmail application is
sendmail, and not
maild.Viewing ProcessesTo see the processes running on the system, use &man.ps.1;
or &man.top.1;. To display a static list of the currently
running processes, their PIDs, how much
memory they are using, and the command they were started with,
use &man.ps.1;. To display all the running processes and
update the display every few seconds in order to interactively
see what the computer is doing, use &man.top.1;.By default, &man.ps.1; only shows the commands that are
running and owned by the user. For example:&prompt.user; ps
PID TT STAT TIME COMMAND
8203 0 Ss 0:00.59 /bin/csh
8895 0 R+ 0:00.00 psThe output from &man.ps.1; is organized into a number of
columns. The PID column displays the
process ID. PIDs are assigned starting at
1, go up to 99999, then wrap around back to the beginning.
However, a PID is not reassigned if it is
already in use. The TT column shows the
tty the program is running on and STAT
shows the program's state. TIME is the
amount of time the program has been running on the CPU. This
is usually not the elapsed time since the program was started,
as most programs spend a lot of time waiting for things to
happen before they need to spend time on the CPU. Finally,
COMMAND is the command that was used to
start the program.A number of different options are available to change the
information that is displayed. One of the most useful sets is
auxww, where displays
information about all the running processes of all users,
displays the username and memory usage of
the process' owner, displays
information about daemon processes, and
causes &man.ps.1; to display the full command line for each
process, rather than truncating it once it gets too long to
fit on the screen.The output from &man.top.1; is similar:&prompt.user; top
last pid: 72257; load averages: 0.13, 0.09, 0.03 up 0+13:38:33 22:39:10
47 processes: 1 running, 46 sleeping
CPU states: 12.6% user, 0.0% nice, 7.8% system, 0.0% interrupt, 79.7% idle
Mem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K Free
Swap: 256M Total, 38M Used, 217M Free, 15% Inuse
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
Mem: 541M Active, 450M Inact, 1333M Wired, 4064K Cache, 1498M Free
ARC: 992M Total, 377M MFU, 589M MRU, 250K Anon, 5280K Header, 21M Other
Swap: 2048M Total, 2048M Free
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
557 root 1 -21 r31 136M 42296K select 0 2:20 9.96% Xorg
8198 dru 2 52 0 449M 82736K select 3 0:08 5.96% kdeinit4
8311 dru 27 30 0 1150M 187M uwait 1 1:37 0.98% firefox
431 root 1 20 0 14268K 1728K select 0 0:06 0.98% moused
9551 dru 1 21 0 16600K 2660K CPU3 3 0:01 0.98% top
2357 dru 4 37 0 718M 141M select 0 0:21 0.00% kdeinit4
8705 dru 4 35 0 480M 98M select 2 0:20 0.00% kdeinit4
8076 dru 6 20 0 552M 113M uwait 0 0:12 0.00% soffice.bin
2623 root 1 30 10 12088K 1636K select 3 0:09 0.00% powerd
2338 dru 1 20 0 440M 84532K select 1 0:06 0.00% kwin
1427 dru 5 22 0 605M 86412K select 1 0:05 0.00% kdeinit4The output is split into two sections. The header (the
first five or six lines) shows the PID of
the last process to run, the system load averages (which are a
measure of how busy the system is), the system uptime (time
since the last reboot) and the current time. The other
figures in the header relate to how many processes are
running, how much memory and swap space has been used, and how
much time the system is spending in different CPU states. If
the system has been formatted with the ZFS
file system, the ARC line provides an
indication of how much data was read from the memory cache
instead of from disk.Below the header is a series of columns containing similar
information to the output from &man.ps.1;, such as the
PID, username, amount of CPU time, and the
command that started the process. By default, &man.top.1;
also displays the amount of memory space taken by the process.
This is split into two columns: one for total size and one for
resident size. Total size is how much memory the application
has needed and the resident size is how much it is actually
using now.&man.top.1; automatically updates the display every two
seconds. A different interval can be specified with
.Killing ProcessesOne way to communicate with any running process or daemon
is to send a signal using &man.kill.1;.
There are a number of different signals; some have a specific
meaning while others are described in the application's
documentation. A user can only send a signal to a process
they own and sending a signal to someone else's process will
result in a permission denied error. The exception is the
root user, who can
send signals to anyone's processes.The operating system can also send a signal to a process.
If an application is badly written and tries to access memory
that it is not supposed to, &os; will send the process the
Segmentation Violation signal
(SIGSEGV). If an application has been
written to use the &man.alarm.3; system call to be alerted
after a period of time has elapsed, it will be sent the
Alarm signal
(SIGALRM).Two signals can be used to stop a process:
SIGTERM and SIGKILL.
SIGTERM is the polite way to kill a process
as the process can read the signal, close any log files it may
have open, and attempt to finish what it is doing before
shutting down. In some cases, a process may ignore
SIGTERM if it is in the middle of some task
that can not be interrupted.SIGKILL can not be ignored by a
process. Sending a SIGKILL to a
process will usually stop that process there and then.
There are a few tasks that can not be
interrupted. For example, if the process is trying to
read from a file that is on another computer on the
network, and the other computer is unavailable, the
process is said to be uninterruptible.
Eventually the process will time out, typically after two
minutes. As soon as this time out occurs the process will
be killed..Other commonly used signals are SIGHUP,
SIGUSR1, and SIGUSR2.
Since these are general purpose signals, different
applications will respond differently.For example, after changing a web server's configuration
file, the web server needs to be told to re-read its
configuration. 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.Sending a Signal to a ProcessThis example shows how to send a signal to
&man.inetd.8;. The &man.inetd.8; configuration file is
/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:&prompt.user; pgrep -l inetd
198 inetd -wWUse &man.kill.1; to send the signal. Because
&man.inetd.8; is owned by
root, use
&man.su.1; to become
root
first.&prompt.user; suPassword:
&prompt.root; /bin/kill -s HUP 198Like most &unix; 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.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
/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.Killing a random process on the system is a bad idea.
In particular, &man.init.8;, PID 1, is
special. Running /bin/kill -s KILL 1 is
a quick, and unrecommended, way to shutdown the system.
Always double check the arguments to
&man.kill.1; before pressing
Return.Shellsshellscommand lineA shell provides a command line
interface for interacting with the operating system. A shell
receives commands from the input channel and executes them.
Many shells provide built in functions to help with everyday
tasks such as file management, file globbing, command line
editing, command macros, and environment variables. &os; comes
with several shells, including the Bourne shell (&man.sh.1;) and
the extended C shell (&man.tcsh.1;). Other shells are available
from the &os; Ports Collection, such as
zsh and bash.The shell that is used is really a matter of taste. A C
programmer might feel more comfortable with a C-like shell such
as &man.tcsh.1;. A &linux; 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 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 Tab to
complete the filename.But the shell only shows rm 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 Tab
again is enough to let the shell determine which filename is
desired and fill in the rest.environment variablesAnother 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. provides a list
of common environment variables and their meanings. Note that
the names of environment variables are always in
uppercase.
Common Environment VariablesVariableDescriptionUSERCurrent logged in user's name.PATHColon-separated list of directories to search for
binaries.DISPLAYNetwork name of the
&xorg;
display to connect to, if available.SHELLThe current shell.TERMThe name of the user's type of terminal. Used to
determine the capabilities of the terminal.TERMCAPDatabase entry of the terminal escape codes to
perform various terminal functions.OSTYPEType of operating system.MACHTYPEThe system's CPU architecture.EDITORThe user's preferred text editor.PAGERThe user's preferred utility for viewing text one
page at a time.MANPATHColon-separated list of directories to search for
manual pages.
Bourne shellsHow 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 /usr/local/bin/emacs for the
&man.tcsh.1; shell:&prompt.user; setenv EDITOR /usr/local/bin/emacsThe equivalent command for bash
would be:&prompt.user; export EDITOR="/usr/local/bin/emacs"To expand an environment variable in order to see its
current setting, type a $ character in front
of its name on the command line. For example,
echo $TERM displays the current
$TERM setting.Shells treat special characters, known as meta-characters,
as special representations of data. The most common
meta-character is *, which represents any
number of characters in a filename. Meta-characters can be used
to perform filename globbing. For example, echo
* is equivalent to ls because
the shell takes all the files that match *
and echo lists them on the command
line.To prevent the shell from interpreting a special character,
escape it from the shell by starting it with a backslash
(\). For example, echo
$TERM prints the terminal setting whereas
echo \$TERM literally prints the string
$TERM.Changing the ShellThe easiest way to permanently change the default shell is
to use chsh. Running this command will
open the editor that is configured in the
EDITOR environment variable, which by default
is set to &man.vi.1;. Change the Shell:
line to the full path of the new shell.Alternately, use chsh -s which will set
the specified shell without opening an editor. For example,
to change the shell to bash:&prompt.user; chsh -s /usr/local/bin/bashThe new shell must be present in
/etc/shells. If the shell was
installed from the &os; Ports Collection as described in
, 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:&prompt.root; echo /usr/local/bin/bash >> /etc/shellsThen, rerun &man.chsh.1;.Text Editorstext editorseditorsMost &os; configuration is done by editing text files.
Because of this, it is a good idea to become familiar with a
text editor. &os; comes with a few as part of the base system,
and many more are available in the Ports Collection.eeeditors&man.ee.1;A simple editor to learn is &man.ee.1;, which stands for
easy editor. To start this editor, type ee
filename where
filename is the name of the file to
be edited. Once inside the editor, all of the commands for
manipulating the editor's functions are listed at the top of the
display. The caret (^) represents
Ctrl, so ^e expands to
Ctrle. To leave &man.ee.1;, press Esc,
then choose the leave editor option from the main
menu. The editor will prompt to save any changes if the file
has been modified.vieditorsemacs&os; also comes with more powerful text editors, such as
&man.vi.1;, as part of the base system. Other editors, like
editors/emacs and
editors/vim, are part of the
&os; Ports Collection. These editors offer more functionality
at the expense of being more complicated to learn. 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 .Devices and Device NodesA device is a term used mostly for hardware-related
activities in a system, including disks, printers, graphics
cards, and keyboards. When &os; boots, the majority of the boot
messages refer to devices being detected. A copy of the boot
messages are saved to
/var/run/dmesg.boot.Each device has a device name and number. For example,
acd0 is the first IDE CD-ROM drive,
while kbd0 represents the
keyboard.Most devices in a &os; must be accessed through special
files called device nodes, which are located in
/dev.Manual Pagesmanual pagesThe most comprehensive documentation on &os; is in the form
of manual pages. Nearly every program on the system comes with
a short reference manual explaining the basic operation and
available arguments. These manuals can be viewed using
man:&prompt.user; man commandwhere command is the name of the
command to learn about. For example, to learn more about
&man.ls.1;, type:&prompt.user; man lsManual pages are divided into sections which represent the
type of topic. In &os;, the following sections are
available:User commands.System calls and error numbers.Functions in the C libraries.Device drivers.File formats.Games and other diversions.Miscellaneous information.System maintenance and operation commands.System kernel interfaces.In some cases, the same topic may appear in more than one
section of the online manual. For example, there is a
chmod user command and a
chmod() system call. To tell &man.man.1;
which section to display, specify the section number:&prompt.user; man 1 chmodThis will display the manual page for the user command
&man.chmod.1;. References to a particular section of the
online manual are traditionally placed in parenthesis in
written documentation, so &man.chmod.1; refers to the user
command and &man.chmod.2; refers to the system call.If the name of the manual page is unknown, use man
-k to search for keywords in the manual page
descriptions:&prompt.user; man -k mailThis 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 the commands in
/usr/bin, type:&prompt.user; cd /usr/bin
&prompt.user; man -f * | moreor&prompt.user; cd /usr/bin
&prompt.user; whatis * |moreGNU Info FilesFree Software Foundation&os; includes many applications and utilities produced by
the Free Software Foundation (FSF). In addition to manual
pages, these programs may include hypertext documents called
info files. These can be viewed using
&man.info.1; or, if editors/emacs is
installed, the info mode of
emacs.To use &man.info.1;, type:&prompt.user; infoFor a brief introduction, type h. For
a quick command reference, type ?.
diff --git a/en_US.ISO8859-1/books/handbook/users/Makefile b/en_US.ISO8859-1/books/handbook/users/Makefile
deleted file mode 100644
index b44bd80628..0000000000
--- a/en_US.ISO8859-1/books/handbook/users/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Build the Handbook with just the content from this chapter.
-#
-# $FreeBSD$
-#
-
-CHAPTERS= users/chapter.xml
-
-VPATH= ..
-
-MASTERDOC= ${.CURDIR}/../${DOC}.${DOCBOOKSUFFIX}
-
-DOC_PREFIX?= ${.CURDIR}/../../../..
-
-.include "../Makefile"
diff --git a/en_US.ISO8859-1/books/handbook/users/chapter.xml b/en_US.ISO8859-1/books/handbook/users/chapter.xml
deleted file mode 100644
index 03f2dcca59..0000000000
--- a/en_US.ISO8859-1/books/handbook/users/chapter.xml
+++ /dev/null
@@ -1,1026 +0,0 @@
-
-
-
- Users and Basic Account Management
-
- NeilBlakey-MilnerContributed by
-
-
-
-
-
-
-
- Synopsis
-
- &os; allows multiple users to use the computer at the same
- time. While only one user can sit in front of the screen and
- use the keyboard at any one time, any number of users can log
- in to the system through the network. To use the system, every
- user must have a user account.
-
- After reading this chapter, you will know:
-
-
-
- The differences between the various user accounts on a
- &os; system.
-
-
-
- How to add and remove user accounts.
-
-
-
- How to change account details, such as the user's full
- name or preferred shell.
-
-
-
- How to set limits on a per-account basis to control the
- resources, such as memory and CPU time, that accounts and
- groups of accounts are allowed to access.
-
-
-
- How to use groups to make account management
- easier.
-
-
-
- Before reading this chapter, you should:
-
-
-
- Understand the basics of &unix;
- and &os;.
-
-
-
-
-
- Introduction
-
- Since all access to the &os; system is achieved via accounts
- and all processes are run by users, user and account management
- is important.
-
- Every account on a &os; system has certain information
- associated with it to identify the account.
-
-
-
- User name
-
-
- The user name is typed at the login:
- prompt. User names must be unique on the system as no two
- users can have the same user name. There are a number of
- rules for creating valid user names, documented in
- &man.passwd.5;. Typically user names consist of eight or
- fewer all lower case characters in order to maintain
- backwards compatibility with applications.
-
-
-
-
- Password
-
-
- Each account has an associated password. While the
- password can be blank, this is highly discouraged and
- every account should have a password.
-
-
-
-
- User ID (UID)
-
-
- The User ID (UID) is a number,
- traditionally from 0 to 65535
- It is possible to use
- UIDs/GIDs as
- large as 4294967295, but such IDs can cause serious
- problems with software that makes assumptions about
- the values of IDs.
- , used to uniquely identify the user to the
- system. Internally, &os; uses the
- UID to identify users. Commands that
- allow a user name to be specified will first convert it to
- the UID. Though unlikely, it is
- possible for several accounts with different user names to
- share the same UID. As far as &os; is
- concerned, these accounts are one user.
-
-
-
-
- Group ID (GID)
-
-
- The Group ID (GID) is a number,
- traditionally from 0 to 65535, used to uniquely identify
- the primary group that the user belongs to. Groups are a
- mechanism for controlling access to resources based on a
- user's GID rather than their
- UID. This can significantly reduce the
- size of some configuration files. A user may also be a
- member of more than one group.
-
-
-
-
- Login class
-
-
- Login classes are an extension to the group mechanism
- that provide additional flexibility when tailoring the
- system to different users.
-
-
-
-
- Password change time
-
-
- By default &os; does not force users to change their
- passwords periodically. Password expiration can be
- enforced on a per-user basis, forcing some or all users to
- change their passwords after a certain amount of time has
- elapsed.
-
-
-
-
- Account expiry time
-
-
- By default &os; does not expire accounts. When
- creating accounts that need a limited lifespan, such as
- student accounts in a school, specify the account expiry
- date. After the expiry time has elapsed, the account
- cannot be used to log in to the system, although the
- account's directories and files will remain.
-
-
-
-
- User's full name
-
-
- The user name uniquely identifies the account to &os;,
- but does not necessarily reflect the user's real name.
- This information can be associated with the
- account.
-
-
-
-
- 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 /home/username
- or /usr/home/username.
- Each user stores their personal files and subdirectories
- in their own home directory.
-
-
-
-
- User shell
-
-
- The shell provides the default environment users use
- to interact with the system. There are many different
- kinds of shells, and experienced users will have their own
- preferences, which can be reflected in their account
- settings.
-
-
-
-
- There are three main types of accounts: the superuser, system accounts, and user accounts. The superuser
- account, usually called root, is used to
- manage the system with no limitations on privileges. System
- accounts are used to run services. User accounts are
- assigned to real people and are used to log in and use the
- system.
-
-
- The Superuser Account
-
-
- accounts
- superuser (root)
-
- The superuser account, usually called
- root, is used to perform system
- administration tasks and should not be used for day-to-day
- tasks like sending and receiving mail, general exploration of
- the system, or programming.
-
- This is because the superuser, unlike normal user
- accounts, can operate without limits, and misuse of the
- superuser account may result in spectacular disasters. User
- accounts are unable to destroy the system by mistake, so it is
- generally best to use normal user accounts whenever possible,
- unless extra privilege is required.
-
- Always double and triple-check any commands issued as the
- superuser, since an extra space or missing character can mean
- irreparable data loss.
-
- Always create a user account for the system administrator
- and use this account to log in to the system for general
- usage. This applies equally to multi-user or single-user
- systems. Later sections will discuss how to create additional
- accounts and how to change between the normal user and
- superuser.
-
-
-
- System Accounts
-
-
- accounts
- system
-
- System accounts are used to run services such as DNS,
- mail, and web servers. The reason for this is security; if
- all services ran as the superuser, they could act without
- restriction.
-
-
- accounts
- daemon
-
-
- accounts
- operator
-
- Examples of system accounts are
- daemon, operator,
- bind, news, and
- www.
-
-
- accounts
- nobody
-
- 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.
-
-
-
- User Accounts
-
-
- accounts
- user
-
- User accounts are the primary means of access for real
- people to the system. User accounts insulate the user and
- the environment, preventing users from damaging the system
- or other users, and allowing users to customize their
- environment without affecting others.
-
- Every person accessing the system should have a unique
- user account. This allows the administrator to find out who
- is doing what, prevents users from clobbering each others'
- settings or reading each others' mail, and so forth.
-
- Each user can set up their own environment to accommodate
- their use of the system, by using alternate shells, editors,
- key bindings, and language.
-
-
-
-
- Modifying Accounts
-
-
- accounts
- modifying
-
-
- &os; provides a variety of different commands to manage
- user accounts. The most common commands are summarized below,
- followed by more detailed examples of their usage.
-
-
-
-
-
-
-
-
- Command
- Summary
-
-
-
-
- &man.adduser.8;
- The recommended command-line application for adding
- new users.
-
-
-
- &man.rmuser.8;
- The recommended command-line application for
- removing users.
-
-
-
- &man.chpass.1;
- A flexible tool for changing user database
- information.
-
-
-
- &man.passwd.1;
- The simple command-line tool to change user
- passwords.
-
-
-
- &man.pw.8;
- A powerful and flexible tool for modifying all
- aspects of user accounts.
-
-
-
-
-
-
- adduser
-
-
- accounts
- adding
-
-
- adduser
-
-
- /usr/share/skel
-
- skeleton directory
- &man.adduser.8; is a simple program for adding new users
- 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.
-
-
- Adding a User on &os;
-
- &prompt.root; adduser
-Username: jru
-Full name: J. Random User
-Uid (Leave empty for default):
-Login group [jru]:
-Login group is jru. Invite jru into other groups? []: wheel
-Login class [default]:
-Shell (sh csh tcsh zsh nologin) [sh]: zsh
-Home directory [/home/jru]:
-Home directory permissions (Leave empty for default):
-Use password-based authentication? [yes]:
-Use an empty password? (yes/no) [no]:
-Use a random password? (yes/no) [no]:
-Enter password:
-Enter password again:
-Lock out the account after creation? [no]:
-Username : jru
-Password : ****
-Full Name : J. Random User
-Uid : 1001
-Class :
-Groups : jru wheel
-Home : /home/jru
-Shell : /usr/local/bin/zsh
-Locked : no
-OK? (yes/no): yes
-adduser: INFO: Successfully added (jru) to the user database.
-Add another user? (yes/no): no
-Goodbye!
-&prompt.root;
-
-
-
- Since the password is not echoed when typed, be careful
- to not mistype the password when creating the user
- account.
-
-
-
-
- rmuser
-
- rmuser
-
- accounts
- removing
-
-
- To completely remove a user from the system use
- &man.rmuser.8;. This command performs the following
- steps:
-
-
-
- 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.
-
-
-
- Removes the user from the system's local password
- file.
-
-
-
- Removes the user's home directory, if it is owned by
- the user.
-
-
-
- Removes the incoming mail files belonging to the user
- from /var/mail.
-
-
-
- Removes all files owned by the user from temporary
- file storage areas such as /tmp.
-
-
-
- Finally, 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 the per-user unique groups created by
- &man.adduser.8;.
-
-
-
-
- &man.rmuser.8; cannot be used to remove superuser
- accounts since that is almost always an indication of massive
- destruction.
-
- By default, an interactive mode is used, as shown
- in the following example.
-
-
- rmuser Interactive Account
- Removal
-
- &prompt.root; rmuser jru
-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
-Updating password file, updating databases, done.
-Updating group file: trusted (removing group jru -- personal group is empty) done.
-Removing user's incoming mail file /var/mail/jru: done.
-Removing files belonging to jru from /tmp: done.
-Removing files belonging to jru from /var/tmp: done.
-Removing files belonging to jru from /var/tmp/vi.recover: done.
-&prompt.root;
-
-
-
-
- chpass
-
- chpass
- &man.chpass.1; can be used to change user database
- information such as passwords, shells, and personal
- information.
-
- Only the superuser can change other users' information and
- passwords with &man.chpass.1;.
-
- When passed no options, aside from an optional username,
- &man.chpass.1; displays an editor containing user information.
- When the user exists from the editor, the user database is
- updated with the new information.
-
-
- You will be asked for your password after exiting the
- editor if you are not the superuser.
-
-
-
- Interactive chpass by
- Superuser
-
- #Changing user database information for jru.
-Login: jru
-Password: *
-Uid [#]: 1001
-Gid [# or name]: 1001
-Change [month day year]:
-Expire [month day year]:
-Class:
-Home directory: /home/jru
-Shell: /usr/local/bin/zsh
-Full Name: J. Random User
-Office Location:
-Office Phone:
-Home Phone:
-Other information:
-
-
- A user can change only a small subset of this
- information, and only for their own user account.
-
-
- Interactive chpass by Normal
- User
-
- #Changing user database information for jru.
-Shell: /usr/local/bin/zsh
-Full Name: J. Random User
-Office Location:
-Office Phone:
-Home Phone:
-Other information:
-
-
-
- &man.chfn.1; and &man.chsh.1; are links to
- &man.chpass.1;, as are &man.ypchpass.1;, &man.ypchfn.1;, and
- &man.ypchsh.1;. NIS support is
- automatic, so specifying the yp before
- the command is not necessary. How to configure NIS is
- covered in .
-
-
-
- passwd
-
- passwd
-
- accounts
- changing password
-
- &man.passwd.1; is the usual way to change your own
- password as a user, or another user's password as the
- superuser.
-
-
- To prevent accidental or unauthorized changes, the user
- must enter their original password before a new password can
- be set. This is not the case when the superuser changes a
- user's password.
-
-
-
- Changing Your Password
-
- &prompt.user; passwd
-Changing local password for jru.
-Old password:
-New password:
-Retype new password:
-passwd: updating the database...
-passwd: done
-
-
-
- Changing Another User's Password as the
- Superuser
-
- &prompt.root; passwd jru
-Changing local password for jru.
-New password:
-Retype new password:
-passwd: updating the database...
-passwd: done
-
-
-
- As with &man.chpass.1;, &man.yppasswd.1; is a link to
- &man.passwd.1;, so NIS works with either command.
-
-
-
-
-
- pw
-
- pw
-
- &man.pw.8; is a command line utility to create, remove,
- modify, and display users and groups. It functions as a front
- end to the system user and group files. &man.pw.8; has a very
- powerful set of command line options that make it suitable for
- use in shell scripts, but new users may find it more
- complicated than the other commands presented in this
- section.
-
-
-
-
-
-
- Limiting Users
-
- limiting users
-
- accounts
- limiting
-
- &os; provides several methods for an administrator to limit
- the amount of system resources an individual may use. These
- limits are discussed in two sections: disk quotas and other
- resource limits.
-
- quotas
-
- limiting users
- quotas
-
- disk quotas
- Disk quotas limit the amount of disk space available to
- users and provide a way to quickly check that usage without
- calculating it every time. Quotas are discussed in .
-
- The other resource limits include ways to limit the amount
- of CPU, memory, and other resources a user may consume. These
- are defined using login classes and are discussed here.
-
-
- /etc/login.conf
-
- Login classes are defined in
- /etc/login.conf and are described in detail
- in &man.login.conf.5;. Each user account is assigned to a login
- class, default by default, and each login
- class has a set of login capabilities associated with it. A
- login capability is a
- name=value
- pair, where name is a well-known
- identifier and value is an arbitrary
- string which is processed accordingly depending on the
- name. Setting up login classes and
- capabilities is rather straightforward and is also described in
- &man.login.conf.5;.
-
-
- &os; does not normally read the configuration in
- /etc/login.conf directly, but instead
- reads the /etc/login.conf.db database
- which provides faster lookups. Whenever
- /etc/login.conf is edited, the
- /etc/login.conf.db must be updated by
- executing the following command:
-
- &prompt.root; cap_mkdb /etc/login.conf
-
-
- Resource limits differ from the default login capabilities
- in two ways. First, for every limit, there is a soft (current)
- and hard limit. A soft limit may be adjusted by the user or
- application, but may not be set higher than the hard limit. The
- hard limit may be lowered by the user, but can only be raised
- by the superuser. Second, most resource limits apply per
- process to a specific user, not to the user as a whole. These
- differences are mandated by the specific handling of the limits,
- not by the implementation of the login capability
- framework.
-
- Below are the most commonly used resource limits. The rest
- of the limits, along with all the other login capabilities, can
- be found in &man.login.conf.5;.
-
-
-
- coredumpsize
-
-
- The limit on the size of a core filecoredumpsize generated by a
- program is subordinate to other limitslimiting userscoredumpsize on disk usage, such
- as filesize, or disk quotas.
- This limit is often used as a less-severe method of
- controlling disk space consumption. Since users do not
- generate core files themselves, and often do not delete
- them, setting this may save them from running out of disk
- space should a large program crash.
-
-
-
-
- cputime
-
-
- The maximum amount of CPUcputimelimiting userscputime time a user's process may
- consume. Offending processes will be killed by the
- kernel.
-
-
- This is a limit on CPU time
- consumed, not percentage of the CPU as displayed in
- some fields by &man.top.1; and &man.ps.1;.
-
-
-
-
-
- filesize
-
-
- The maximum size of a filefilesizelimiting usersfilesize the user may own. Unlike
- disk quotas, this limit is
- enforced on individual files, not the set of all files a
- user owns.
-
-
-
-
- maxproc
-
-
- The maximum number of processesmaxproclimiting usersmaxproc a user can run. This
- includes foreground and background processes. This limit
- may not be larger than the system limit specified by the
- kern.maxproc &man.sysctl.8;. Setting
- this limit too small may hinder a user's productivity as
- it is often useful to be logged in multiple times or to
- execute pipelines. Some tasks, such as compiling a large
- program, spawn multiple processes and other intermediate
- preprocessors.
-
-
-
-
- memorylocked
-
-
- The maximum amount of memorymemorylockedlimiting usersmemorylocked a process may request
- to be locked into main memory using &man.mlock.2;. Some
- system-critical programs, such as &man.amd.8;, lock into
- main memory so that if the system begins to swap, they do
- not contribute to disk thrashing.
-
-
-
-
- memoryuse
-
-
- The maximum amount of memorymemoryuselimiting usersmemoryuse a process may consume at
- any given time. It includes both core memory and swap
- usage. This is not a catch-all limit for restricting
- memory consumption, but is a good start.
-
-
-
-
- openfiles
-
-
- The maximum number of files a process may have openopenfileslimiting usersopenfiles.
- In &os;, files are used to represent sockets and IPC
- channels, so be careful not to set this too low. The
- system-wide limit for this is defined by the
- kern.maxfiles &man.sysctl.8;.
-
-
-
-
- sbsize
-
-
- The limit on the amount of network memory, and
- thus mbufssbsizelimiting userssbsize, a user may consume in order to limit network
- communications.
-
-
-
-
- stacksize
-
-
- The maximum size of a process stackstacksizelimiting usersstacksize. This alone is
- not sufficient to limit the amount of memory a program
- may use so it should be used in conjunction with other
- limits.
-
-
-
-
- There are a few other things to remember when setting
- resource limits. Following are some general tips, suggestions,
- and miscellaneous comments.
-
-
-
- Processes started at system startup by
- /etc/rc are assigned to the
- daemon login class.
-
-
-
- Although the /etc/login.conf that
- comes with the system is a good source of reasonable values
- for most limits, they may not be appropriate for every
- system. Setting a limit too high may open the system up to
- abuse, while setting it too low may put a strain on
- productivity.
-
-
-
- Users of &xorg; should
- probably be granted more resources than other users.
- &xorg; by itself takes a lot of
- resources, but it also encourages users to run more programs
- simultaneously.
-
-
-
- Many limits apply to individual processes, not the user
- as a whole. For example, setting
- openfiles to 50 means that each process
- the user runs may open up to 50 files. The total amount
- of files a user may open is the value of
- openfiles multiplied by the value of
- maxproc. This also applies to memory
- consumption.
-
-
-
- For further information on resource limits and login classes
- and capabilities in general, refer to &man.cap.mkdb.1;,
- &man.getrlimit.2;, and &man.login.conf.5;.
-
-
-
- Groups
-
- groups
-
- /etc/groups
-
-
- accounts
- groups
-
- A group is a list of users. A group is identified by its
- group name and GID. In &os;, 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 /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 /etc/group
- using a text editor. 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:
-
-
- Adding a Group Using &man.pw.8;
-
- &prompt.root; pw groupadd teamtwo
-&prompt.root; pw groupshow teamtwo
-teamtwo:*:1100:
-
-
- In this example, 1100 is the
- GID of teamtwo. Right
- now, teamtwo has no members. This
- command will add jru as a member of
- teamtwo.
-
-
- Adding User Accounts to a New Group Using
- &man.pw.8;
-
- &prompt.root; pw groupmod teamtwo -M jru
-&prompt.root; pw groupshow teamtwo
-teamtwo:*:1100:jru
-
-
- The argument to 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
- 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 /etc/group and does not attempt
- to read additional data from
- /etc/passwd.
-
-
- Adding a New Member to a Group Using &man.pw.8;
-
- &prompt.root; pw groupmod teamtwo -m db
-&prompt.root; pw groupshow teamtwo
-teamtwo:*:1100:jru,db
-
-
- In this example, the argument to is a
- comma-delimited list of users who are to be added to the group.
- Unlike the previous example, these users are appended to the
- group list and do not replace the list of existing users in the
- group.
-
-
- Using &man.id.1; to Determine Group Membership
-
- &prompt.user; id jru
-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
- /etc/group, refer to &man.pw.8; and
- &man.group.5;.
-
-
-
- Becoming Superuser
-
- There are several ways to do things as the superuser. The
- worst way is to log in as root directly.
- Usually very little activity requires root
- so logging off and logging in as root,
- performing tasks, then logging off and on again as a normal user
- is a waste of time.
-
- A better way is to use &man.su.1; without providing a login
- but using - to inherit the root environment.
- Not providing a login will imply super user. For this to work
- the login that must be in the wheel group.
- An example of a typical software installation would involve the
- administrator unpacking the software as a normal user and then
- elevating their privileges for the build and installation of
- the software.
-
-
- Install a Program As The Superuser
-
- &prompt.user; configure
-&prompt.user; make
-&prompt.user; su -
-Password:
-&prompt.root; make install
-&prompt.root; exit
-&prompt.user;
-
-
- Note in this example the transition to
- root is less painful than logging off
- and back on twice.
-
- Using &man.su.1; works well for single systems or small
- networks with just one system administrator. For more complex
- environments (or even for these simple environments)
- sudo should be used. It is provided as a port,
- security/sudo. It allows for
- things like activity logging, granting users the ability to only
- run certain commands as the superuser, and several other
- options.
-
-