Use correct syntax markup for shell
Approved by: carlavilla
This commit is contained in:
parent
55c95407aa
commit
a9a9e66105
666 changed files with 17924 additions and 17924 deletions
|
|
@ -65,7 +65,7 @@ After reading this chapter, you will know:
|
|||
|
||||
Unless FreeBSD has been configured to automatically start a graphical environment during startup, the system will boot into a command line login prompt, as seen in this example:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
FreeBSD/amd64 (pc3.example.org) (ttyv0)
|
||||
|
||||
|
|
@ -143,21 +143,21 @@ _Be careful when changing this setting to `insecure`!_ If the `root` password is
|
|||
|
||||
The FreeBSD console default video mode may be adjusted to 1024x768, 1280x1024, or any other size supported by the graphics chip and monitor. To use a different video mode load the `VESA` module:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# kldload vesa
|
||||
....
|
||||
|
||||
To determine which video modes are supported by the hardware, use man:vidcontrol[1]. To get a list of supported video modes issue the following:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# vidcontrol -i mode
|
||||
....
|
||||
|
||||
The output of this command lists the video modes that are supported by the hardware. To select a new video mode, specify the mode using man:vidcontrol[1] as the `root` user:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# vidcontrol MODE_279
|
||||
....
|
||||
|
|
@ -260,7 +260,7 @@ In this example, the user only becomes superuser in order to run `make install`
|
|||
.Install a Program As the Superuser
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% configure
|
||||
% make
|
||||
|
|
@ -313,7 +313,7 @@ The man:adduser[8] utility is interactive and walks through the steps for creati
|
|||
.Adding a User on FreeBSD
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# adduser
|
||||
Username: jru
|
||||
|
|
@ -375,7 +375,7 @@ By default, an interactive mode is used, as shown in the following example.
|
|||
.`rmuser` Interactive Account Removal
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# rmuser jru
|
||||
Matching password entry:
|
||||
|
|
@ -405,7 +405,7 @@ In <<users-modifying-chpass-su>>, the superuser has typed `chpass jru` and is no
|
|||
.Using `chpass` as Superuser
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
#Changing user database information for jru.
|
||||
Login: jru
|
||||
|
|
@ -429,7 +429,7 @@ Other information:
|
|||
.Using `chpass` as Regular User
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
#Changing user database information for jru.
|
||||
Shell: /usr/local/bin/zsh
|
||||
|
|
@ -454,7 +454,7 @@ Any user can easily change their password using man:passwd[1]. To prevent accide
|
|||
.Changing Your Password
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% passwd
|
||||
Changing local password for jru.
|
||||
|
|
@ -471,7 +471,7 @@ The superuser can change any user's password by specifying the username when run
|
|||
.Changing Another User's Password as the Superuser
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# passwd jru
|
||||
Changing local password for jru.
|
||||
|
|
@ -504,7 +504,7 @@ The superuser can modify [.filename]#/etc/group# using a text editor. Alternativ
|
|||
.Adding a Group Using man:pw[8]
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# pw groupadd teamtwo
|
||||
# pw groupshow teamtwo
|
||||
|
|
@ -517,7 +517,7 @@ In this example, `1100` is the GID of `teamtwo`. Right now, `teamtwo` has no mem
|
|||
.Adding User Accounts to a New Group Using man:pw[8]
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# pw groupmod teamtwo -M jru
|
||||
# pw groupshow teamtwo
|
||||
|
|
@ -530,7 +530,7 @@ The argument to `-M` is a comma-delimited list of users to be added to a new (em
|
|||
.Adding a New Member to a Group Using man:pw[8]
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# pw groupmod teamtwo -m db
|
||||
# pw groupshow teamtwo
|
||||
|
|
@ -543,7 +543,7 @@ In this example, the argument to `-m` is a comma-delimited list of users who are
|
|||
.Using man:id[1] to Determine Group Membership
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% id jru
|
||||
uid=1001(jru) gid=1001(jru) groups=1001(jru), 1100(teamtwo)
|
||||
|
|
@ -607,7 +607,7 @@ Table 4.1 summarizes the possible numeric and alphabetic possibilities. When rea
|
|||
|
||||
Use the `-l` argument to man:ls[1] to view a long directory listing that includes a column of information about a file's permissions for the owner, group, and everyone else. For example, an `ls -l` in an arbitrary directory may show:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ls -l
|
||||
total 530
|
||||
|
|
@ -688,14 +688,14 @@ Symbolic permissions use characters instead of octal values to assign permission
|
|||
|
||||
These values are used with man:chmod[1], but with letters instead of numbers. For example, the following command would block other users from accessing _FILE_:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% chmod go= FILE
|
||||
....
|
||||
|
||||
A 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:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% chmod go-w,a+x FILE
|
||||
....
|
||||
|
|
@ -706,21 +706,21 @@ In addition to file permissions, FreeBSD supports the use of "file flags". These
|
|||
|
||||
File flags are modified using man:chflags[1]. For example, to enable the system undeletable flag on the file [.filename]#file1#, issue the following command:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# chflags sunlink file1
|
||||
....
|
||||
|
||||
To disable the system undeletable flag, put a "no" in front of the `sunlink`:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# chflags nosunlink file1
|
||||
....
|
||||
|
||||
To view the flags of a file, use `-lo` with man:ls[1]:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# ls -lo file1
|
||||
....
|
||||
|
|
@ -742,7 +742,7 @@ The real user ID is the UID who owns or starts the process. The effective UID is
|
|||
|
||||
The setuid permission may be set by prefixing a permission set with the number four (4) as shown in the following example:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# chmod 4755 suidexample.sh
|
||||
....
|
||||
|
|
@ -765,7 +765,7 @@ To view this in real time, open two terminals. On one, type `passwd` as a normal
|
|||
|
||||
In terminal A:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
Changing local password for trhodes
|
||||
Old Password:
|
||||
|
|
@ -773,12 +773,12 @@ Old Password:
|
|||
|
||||
In terminal B:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# ps aux | grep passwd
|
||||
....
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
trhodes 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 passwd
|
||||
|
|
@ -790,14 +790,14 @@ The `setgid` permission performs the same function as the `setuid` permission; e
|
|||
|
||||
To set the `setgid` permission on a file, provide man:chmod[1] with a leading two (2):
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# chmod 2755 sgidexample.sh
|
||||
....
|
||||
|
||||
In the following listing, notice that the `s` is now in the field designated for the group permission settings:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
-rwxr-sr-x 1 trhodes trhodes 44 Aug 31 01:49 sgidexample.sh
|
||||
....
|
||||
|
|
@ -811,19 +811,19 @@ The `setuid` and `setgid` permission bits may lower system security, by allowing
|
|||
|
||||
When the `sticky bit` is set on a directory, it allows file deletion only by the file owner. This is useful to prevent file deletion in public directories, such as [.filename]#/tmp#, by users who do not own the file. To utilize this permission, prefix the permission set with a one (1):
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# chmod 1777 /tmp
|
||||
....
|
||||
|
||||
The `sticky bit` permission will display as a `t` at the very end of the permission set:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# ls -al / | grep tmp
|
||||
....
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
drwxrwxrwt 10 root wheel 512 Aug 31 01:49 tmp
|
||||
....
|
||||
|
|
@ -1147,7 +1147,7 @@ File systems are mounted using man:mount[8]. The most basic syntax is as follows
|
|||
|
||||
[example]
|
||||
====
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# mount device mountpoint
|
||||
....
|
||||
|
|
@ -1211,7 +1211,7 @@ To see the processes running on the system, use man:ps[1] or man:top[1]. To disp
|
|||
|
||||
By default, man:ps[1] only shows the commands that are running and owned by the user. For example:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ps
|
||||
PID TT STAT TIME COMMAND
|
||||
|
|
@ -1225,7 +1225,7 @@ A number of different options are available to change the information that is di
|
|||
|
||||
The output from man:top[1] is similar:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% top
|
||||
last pid: 9609; load averages: 0.56, 0.45, 0.36 up 0+00:20:03 10:21:46
|
||||
|
|
@ -1278,7 +1278,7 @@ This example shows how to send a signal to man:inetd[8]. The man:inetd[8] config
|
|||
|
||||
. Find the PID of the process to send the signal to using man:pgrep[1]. In this example, the PID for man:inetd[8] is 198:
|
||||
+
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% pgrep -l inetd
|
||||
198 inetd -wW
|
||||
|
|
@ -1286,7 +1286,7 @@ This example shows how to send a signal to man:inetd[8]. The man:inetd[8] config
|
|||
+
|
||||
. Use man:kill[1] to send the signal. As man:inetd[8] is owned by `root`, use man:su[1] to become `root` first.
|
||||
+
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% su
|
||||
Password:
|
||||
|
|
@ -1366,14 +1366,14 @@ Another feature of the shell is the use of environment variables. Environment va
|
|||
|
||||
How to set an environment variable differs between shells. In man:tcsh[1] and man:csh[1], use `setenv` to set environment variables. In man:sh[1] and `bash`, use `export` to set the current environment variables. This example sets the default `EDITOR` to [.filename]#/usr/local/bin/emacs# for the man:tcsh[1] shell:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% setenv EDITOR /usr/local/bin/emacs
|
||||
....
|
||||
|
||||
The equivalent command for `bash` would be:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% export EDITOR="/usr/local/bin/emacs"
|
||||
....
|
||||
|
|
@ -1391,7 +1391,7 @@ The easiest way to permanently change the default shell is to use `chsh`. Runnin
|
|||
|
||||
Alternately, use `chsh -s` which will set the specified shell without opening an editor. For example, to change the shell to `bash`:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% chsh -s /usr/local/bin/bash
|
||||
....
|
||||
|
|
@ -1400,7 +1400,7 @@ Alternately, use `chsh -s` which will set the specified shell without opening an
|
|||
====
|
||||
The new shell _must_ be present in [.filename]#/etc/shells#. If the shell was installed from the FreeBSD Ports Collection as described in crossref:ports[ports,Installing Applications: Packages and Ports], it should be automatically added to this file. If it is missing, add it using this command, replacing the path with the path of the shell:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
# echo /usr/local/bin/bash >> /etc/shells
|
||||
....
|
||||
|
|
@ -1414,21 +1414,21 @@ The UNIX(R) shell is not just a command interpreter, it acts as a powerful tool
|
|||
|
||||
Shell redirection is the action of sending the output or the input of a command into another command or into a file. To capture the output of the man:ls[1] command, for example, into a file, redirect the output:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ls > directory_listing.txt
|
||||
....
|
||||
|
||||
The directory contents will now be listed in [.filename]#directory_listing.txt#. Some commands can be used to read input, such as man:sort[1]. To sort this listing, redirect the input:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% sort < directory_listing.txt
|
||||
....
|
||||
|
||||
The input will be sorted and placed on the screen. To redirect that input into another file, one could redirect the output of man:sort[1] by mixing the direction:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% sort < directory_listing.txt > sorted.txt
|
||||
....
|
||||
|
|
@ -1439,7 +1439,7 @@ Through the use of these descriptors, the shell allows output and input to be pa
|
|||
|
||||
The UNIX(R) pipe operator, "|" allows the output of one command to be directly passed or directed to another program. Basically, a pipe allows the standard output of a command to be passed as standard input to another command, for example:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% cat directory_listing.txt | sort | less
|
||||
....
|
||||
|
|
@ -1471,14 +1471,14 @@ Most devices in FreeBSD must be accessed through special files called device nod
|
|||
|
||||
The most comprehensive documentation on FreeBSD 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`:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% man command
|
||||
....
|
||||
|
||||
where _command_ is the name of the command to learn about. For example, to learn more about man:ls[1], type:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% man ls
|
||||
....
|
||||
|
|
@ -1497,7 +1497,7 @@ Manual pages are divided into sections which represent the type of topic. In Fre
|
|||
|
||||
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:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% man 1 chmod
|
||||
....
|
||||
|
|
@ -1506,7 +1506,7 @@ This will display the manual page for the user command man:chmod[1]. References
|
|||
|
||||
If the name of the manual page is unknown, use `man -k` to search for keywords in the manual page descriptions:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% man -k mail
|
||||
....
|
||||
|
|
@ -1515,7 +1515,7 @@ This command displays a list of commands that have the keyword "mail" in their d
|
|||
|
||||
To read the descriptions for all of the commands in [.filename]#/usr/bin#, type:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% cd /usr/bin
|
||||
% man -f * | more
|
||||
|
|
@ -1523,7 +1523,7 @@ To read the descriptions for all of the commands in [.filename]#/usr/bin#, type:
|
|||
|
||||
or
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% cd /usr/bin
|
||||
% whatis * |more
|
||||
|
|
@ -1536,7 +1536,7 @@ FreeBSD includes several applications and utilities produced by the Free Softwar
|
|||
|
||||
To use man:info[1], type:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% info
|
||||
....
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue