Getting started with FreeBSD ③

Source: Internet
Author: User
Tags ftp site dmesg

Original: http://ewangsoft.blog.163.com/blog/static/7721558220096269174637/

------------------------

51. A process ID or PID is used to identify a process.
In addition, like a file, each process also has its users and groups. Users and groups are used to determine which files and devices the process can open and use files in the initial stage.
. Most processes have a parent process,
The process is started by the parent process. For example, if you input a command to the shell, the shell is a process, and the commands you run are also processes, the shell is your
The parent process of the running process. There is an exception in the process called Init (8 ).
Init is always the first process, so its PID is always 1. init is automatically started by the kernel during FreeBSD startup.

52. There are two commands for viewing processes: PS and top. The ps command is used to observe the status of the currently running process, display their PID, How much memory is used, and the command line they start. While
The top command displays all running processes and updates data within seconds.

53. PS (1) supports various options to change the displayed content. The most useful one is auxww. Option A shows the content of all running processes,
Not just your process. The U option displays the username and memory usage of the process, and the X option displays the background process. The WW option indicates PS (1)
Display the entire command line of each process, instead of taking it off the screen because the command line is too long.

54. Top (1) is automatically refreshed every two seconds. You can use-s to change the refresh seconds.

55. You may need to communicate with the daemon. Signals are a communication mechanism. Can send signals to the daemon (or other related processes)
To communicate with it. Different signals have their own numbers-some of which have special meanings, and others can be explained by the application itself,
In general, the application documentation will tell which signals will be processed. You can only send signals to processes that belong to you. If you send signals to other processes, the process uses kill (1) or
Kill (2) Permission is denied. Of course, the root user can send various signals to each process.

56. There are two signals to stop the process: sigterm and sigkill.
Sigterm is relatively friendly, and processes can capture this signal and close the program as needed. Before closing the program, you can end the opened record file and complete ongoing tasks. In some cases,
If the process is running and cannot be interrupted, the process can ignore this sigterm signal. Processes cannot ignore sigkill signals. This is
'Whatever you are doing, stop immediately. If you send a sigkill signal to the process, FreeBSD stops the process.

57. Almost all daemon processes specify responses to the sighup signal when writing to re-read the configuration file. Therefore, the best way is not to kill and restart
Httpd, but sends a sighup signal to it. Because there is no standard in this regard, different Daemon have different usage, so you should read the daemon document if you do not know.

58. Example: send a signal to inetd: 1) Find the process ID you want to send the signal to. You can use PS (1) and grep (1) to complete PS-ax |
Grep inetd; 2) use kill (1) to send signals. Because inetd (8) is started by root, you must use SU (1) to change
Root User: #/bin/kill-s hup 198

59. You can add a $ character on the command line before the variable to obtain the environment variable. For example, the value of $ term is displayed with ECHO $ term,
In fact, the shell obtains $ term and sends it to echo for display. Shell contains many special characters, which are called meta-characters.
The most common character is *, which can represent any character of the file name. These special characters are applied to the file name domain. If the input echo * is the same as the input ls
Shell obtains all file names that match * and sends them to echo to display them in the command line. To prevent shell from analyzing these special characters, we can add
/Character indicates that it is only a common character. Echo $ term will show your terminal information, while echo/$ term will show the words $ term.
Change
Volume description
User: the username currently logged on.
Path: searches for program paths separated by colons.
Display
If this variable exists, it is the Network Name of the X11 display.
The current shell used by the shell.
Term
The name of a user terminal, usually used to determine the terminal's capabilities.
Basic data items for separating terminals used by various termcap terminal functions.
Ostype
The operating system type. The default value is FreeBSD.
Machtype refers to the CPU architecture running on the system.
Editor user's preferred text editor.
Pager
Your preferred text page scheduler.
Manpath searches for the path of the online manual, which is separated by two colons.

Different shell settings have different environment variables. For example, in C-style shell such as tcsh and CSH,
You must use setenv to set environment variables. In the Bourne shell such as SH and Bash, you must use export to set the current environment variable.
For another example, to set or change the editor environment variable, set the editor to/usr/local/bin/Emacs under CSH or tcsh:
%
Setenv Editor/usr/local/bin/Emacs, while in the Bourne shell, it is: % Export
Editor = "/usr/local/bin/Emacs"

60. The simplest way to change shell is to use the CHSH command. Execute CHSH according to the editor You Set
The environment variable enters the editor. If it is not set, it will enter the VI editor. Change the value of "shell. You can use CHSH
In this way, you can set your shell without the editor. If you want to change shell to bash, use the following tips: % CHSH-S
/Usr/local/bin/bash. Note: The shells you are using must be listed in the/etc/shells file. Assume that you
Install a shell in ports, so you do not need to do this step. If you have a shell tool, you need to add it manually. If you manually install Bash
In/usr/local/bin, You need to perform this step: # echo "/usr/local/bin/bash">
/Etc/shells, and then run CHSH.

61. A text editor is automatically opened for many applications that need to modify files or input typing. Change the default editor. Set Editor
Environment variable. Different shell settings have different environment variables. For example, in C-style shell such as tcsh and CSH,
You must use setenv to set environment variables. In the Bourne shell such as SH and Bash, you must use export to set the current environment variable.
For another example, set or change the editor environment variable to/usr/local/bin/Emacs: % under CSH or tcsh.
Setenv Editor/usr/local/bin/Emacs; Under the Bourne shell: % Export
Editor = "/usr/local/bin/Emacs ".

62. Most devices can be detected and displayed during FreeBSD startup. For details, refer to/var/run/dmesg. boot,
All information is included during the boot. You can also run the dmesg command to view the information. In UNIX operating systems, most devices have special access files called device nodes, which are located in/dev.
Directory. After adding a new device to the system or compiling the support of additional devices into the kernel, you must create a device node for it.

63. If you do not know the name of a command, you can use Man's Search function. It will find the keyword to be searched in the description section of the Manual. Its option is-K: for example, man-K
Mail. Man will list the commands containing the keyword "mail" in the introduction, which is the same as the features of the apropos command. Use man-f * or whatis
* Command usage instructions are available.

64. Package usually uses conservative options during compilation to ensure that they can run on most systems. Through the port
Installation, You Can slightly adjust the compilation options to generate code suitable for the processor (for Pentium 4 or AMD's athlon
CPU ). Some software packages have compiled the options related to what they can do and what they cannot do. For example, Apache may have many options configured. From Port
During installation, you do not have to accept the default options. You can set them by yourself. To patch the software, you must have the source code.

65. Check http://vuxml.freebsd.org/
Whether there is a security issue report on the application you have installed. You can also install ports-mgmt/portaudit to automatically check vulnerabilities in installed applications;
In addition, before you install the program, it first checks for known vulnerabilities. You can also use portaudit-f-
This command checks after a software package is installed.

There is a list of all currently available applications that can be searched on the FreeBSD site, on the http://www.FreeBSD.org/ports/
. Dan
Langille maintains the site freshports, in http://www.FreshPorts.org/
.
Freshport "tracks" Application Changes in ports at all times. When any program is upgraded, they will send an email
Remind you. If you do not know the name of the desired application, you can use/
)
Website.

67. If you know the exact name of a port but do not know the type of the port, you can use the whereis (1) command to find it. Enter whereis
File is the name of the program you want to install. If the system finds it, you will be notified where it is. You can use the echo (1) Statement to find a port.
Whether it exists in the ports tree. For example, # echo/usr/ports/* lsof *. You can use ports collecton
Embedded search mechanism to search programs. To use this search, first go to the/usr/ports directory and then run make search
Name = Program-name, program-name is the name of the program you are looking. For example, if you want to find lsof: # cd
/Usr/ports # Make search name = lsof. You can also use make search
Key = string, string is part of the content you want to search. It will search for the port name, comment,
Description and subordination. If you do not know the name of the program you want to search for, you can use it to search for key topics to find what you need. The search keywords of these methods are case-insensitive.

68. Run pkg_add (1) to install FreeBSD from a local file or a server on the network.
Software Package. If you do not have an installation disk for the local package, such as the FreeBSD CD-ROM, you can run the pkg_add (1) command and add the-r option.
This will force the program to automatically determine the correct format and version of the target file, and then automatically find and install package: # pkg_add-r lsof from an FTP site.

69. If the image site of the FreeBSD package is specified and the master site is replaced, packagesite must be set accordingly.
This environment variable (setenv packagesite URL) overwrites the original settings. Pkg_add (1) Use fetch (3)
You can use multiple environment variables to download files, including ftp_passive_mode, ftp_proxy, and ftp_password. If you use
You may need to set these environment variables for the FTP/HTTP proxy or after the firewall. For a detailed list, see fetch (3 ). In the preceding example, lsof is used instead.
Lsof-4.56.4. When using the Remote Installation Package, the software name does not need to contain the version number. Pkg_add (1) Automatically finds the latest version of the software.

70. pkg_info (1)
Is a program used to list the list and descriptions of all installed software packages. Pkg_version (1) is a tool used to count all installed software package versions. It can be used to compare local data
Package version and ports
Whether the current version in the directory is consistent. Use pkg_delete (1) to delete the previously installed software package. Pkg_delete (1) provides the complete package name;
If you only specify a name like xchat rather than a xchat-1.7.1, it rejects the operation. However, you can use pkg_version (1)
To understand the version of the installed package. You can also use the wildcard: # pkg_delete xchat /*.
All packages starting.

71. All installed package information is saved in the/var/DB/PKG directory. List of installation files and each package
The content and description can be found in the relevant files in this directory.

72. Before using ports, you must first obtain the ports collection-essentially a bunch of ports under the/usr/ports directory.
Makefile, patch, and description file.

73. When you install the FreeBSD system, sysinstall will ask if you need to install the ports collection. If you select
No, you can use the following command to install the ports collection: (1) CVSup method: Keep local ports
The latest quick method of the kit, which is updated using the CVSup protocol. Note: The implementation of CVSup In the FreeBSD system is called csup.
It appears in FreeBSD 6.2 for the first time. For FreeBSD users of earlier versions, you can install FreeBSD through Port/package.
Net/csup. Before Running csup for the first time, make sure that/usr/ports is empty! If you have installed a copy of Ports
Csup may not automatically delete the patch files that have been deleted on the upstream server. 1. Run csup: # csup-L 2-H
Cvsup.freebsd.org
/Usr/share/examples/CVSup/ports-supfile: Change cvsup.freebsd.org to the CVSup closest to you.
Server. See the complete list of image sites in a CVSup image (section A.6.7. Note: you may want to use your ports-supfile,
For example, if you do not want to use the command line to specify the CVSup server, you can perform the following operations:
/Usr/share/examples/CVSup/ports-supfile copy to a new location, such as/root or your home directory. Edit
Ports-supfile; change change_this.freebsd.org to a CVSup server close to you. For more information, see CVSup.
Complete list of image sites in the image (section A.6.7); run csup: # csup-L 2/root/ports-supfile. 2. Run
The csup (1) Command will download recent changes and apply them to your ports collection. However, this process does not recompile your system
Ports. (2) portsnap mode: 1. Download the compressed ports suite snapshot to/var/DB/portsnap. You can disable
Internet connection: # portsnap fetch; 2. If portsnap is run for the first time, you need to release the snapshot to/usr/ports :#
Portsnap extract. If you have installed/usr/ports and only want to update them, run the following command: # portsnap
Update. To make the above process run continuously: # portsnap fetch Update (3) sysinstall method: This method needs to be used
Sysinstall install ports kit from the installation media. Note that the old ports suite is installed when the release is released. 1. Run as root
Sysinstall (for versions earlier than FreeBSD 5.2, run/STAND/sysinstall ):#
Sysinstall; 2. Use the light indicator to select configure; 3. Select distributions; 4. Select ports; 5. Select
Exit; 6. Select the desired installation media, such as CDRom and FTP; 7. Select exit; 8. Press X to exit sysinstall.

74. Port skeleton is the minimum combination of files required for simple compilation and installation of a program on FreeBSD. Each port
Skeleton contains: A makefile. Makefile consists of several parts that indicate how the application is compiled and where it will be installed in the system. One
Distinfo file. This file includes this information: these files are used to check the downloaded file checksum (MD5 (1) and
Sha256 (1) to ensure that the file is not damaged during the download process. A file directory. This directory is included in FreeBSD
Patches required for compiling and installing programs on the system. These patches are basically small files that indicate the modifications made to specific files. They are all in plain text format, basically as follows:
The patch files are also called "diffs" and are generated by the diff (1) program. One
PKG-descr file. This is a multi-line description that provides more details and software. A pkg-plist file. This is a list of all files to be installed. It tells
Which files must be deleted when the ports system is detached.

75. The ports suite assumes that you have an available Internet connection. If you do not have one, you need to name the distfile (the program source code in ports is
To/usr/ports/distfiles. Enter the directory of the port to be installed: # cd
/Usr/ports/sysutils/lsof: Enter the lsof directory. You will see the port structure. The next step is "make" or "join"
This port. You only need to enter the make command in the command line to easily complete this task. Once the compilation is complete, you will return to the command line. Next Install port,
To install it, you only need to install the make command followed by the previous word: # Make
Install; Delete the working directory, which contains all temporary files used during compilation. These files not only occupy valuable disk space, but may also be updated to the new version.
Port: # Make clean. You can use make install clean to complete make, make install, and
Make clean.

76. Some shells cache executable files in the directory specified in the environment variable path to speed up searching for them. If you are using this type of shell,
After installing the port, you may need to run the rehash command before running the newly installed commands. This command can be used in Shell similar to tcsh.
For Shell similar to SH, the corresponding command is hash-R.

77. The ports system uses fetch (1) to download files. It has many environment variables that can be set, including ftp_passive_mode,
Ftp_proxy, and ftp_password. If you use an FTP/HTTP Proxy after the firewall,
You may need to set them. Make fetch can be used when users cannot connect to the network at all times. You only need to go to the top-level directory (/usr/ports)
Run this command. All required files will be downloaded. This command can also be used in a lower-level category directory, for example,/usr/ports/net. Note,
If a port has some dependent libraries or other ports, it will not download the distfile files of these dependent ports. If you want to obtain all the dependent ports
For all distfiles, replace the fetch-recursive command with the FETCH Command.

78. You may need to obtain a file package from a site other than master_sites (a local file that has been downloaded. You can use the following command not to use
Master_sites: # cd/usr/ports/directory; # Make master_site_override =
/Ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ fetch. In this example
Master_sites option changed to ftp.freebsd.org/pub/freebsd/ports/distfiles/
.

79. Sometimes, using different temporary working directories and target directories may be useful (or even necessary ). Wrkdirprefix and prefix can be used.
These two variables change the default directory. For example: # Make wrkdirprefix =/usr/home/example/ports install-
Compile the port in/usr/home/example/ports and install all the files to/usr/local. # Make
Prefix =/usr/home/example/local install will compile it in/usr/ports and install it
/Usr/home/example/local. Of course, you can also specify the two at a time: # Make wrkdirprefix = ../Ports
Prefix = ../local install.

Reconfigure ports: When you compile some ports, a menu based on ncurses may pop up for you to select some compilation options.
Users usually want to access this menu again after a port is compiled and installed to add, delete, or modify these options. There are actually many ways to do this.
Enter the port directory in one method and type make config. Then, the menu and selected project are displayed again. Another method is to use make
Showconfig. All configuration options are displayed. Another method is to execute make rmconfig, which will delete all selected items.

80. Uninstall installed ports: # pkg_delete programname; Use the pkg_version (1) command to list
Ports collection provides the updated versions of Port: # pkg_version-v.

81. Use portupgrade to update ports: It is provided through ports-mgmt/portupgrade port. Use
Make install clean command to install it: # cd/usr/ports-mgmt/portupgrade; # Make
Install clean. (1) run the/usr/local/sbin/pkgdb-F command to scan installed ports.
(2) When running/usr/local/sbin/portupgrade-a, portupgrade
All outdated ports installed in the system will be started and upgraded. If you want to confirm each upgrade operation, specify the-I parameter: # portupgrade
-AI. (3) If you only want to upgrade a specific application, use portupgrade pkgname. If portupgrade
First, you should specify the-R parameter: # portupgrade-r Firefox. Use a precompiled package instead
To install ports, you must specify-P. If this option is specified, portupgrade searches for pkg_path.
If the local directory is not found, it will be downloaded from the remote site. If no pre-compiled package is found locally and the remote site does not successfully download the package, portupgrade will use
Ports. To disable port usage, you can specify-PP: # portupgrade-PP gnome2. If you only want to download distfiles (or,
If-P is specified, it is packages. Instead of building or installing anything, you can use-f.

82. Use portmanager to upgrade ports: it can use ports-mgmt/portmanager
Port. Upgrade all installed ports: # portmanager-U. If you want portmanager to give a prompt before performing each step, use
-UI parameters. Portmanager can also be used to install new ports in the system. And the general make install clean
Different commands, it will upgrade all dependent packages before associating and installing the selected port. # Portmanager X11/gnome2. If
If there are any problems with dependencies, you can use portmanager to re-build them in the correct order. After that, the problematic port will be rebuilt. #
Portmanager graphics/gimp-f.

83. Use portmaster to upgrade ports: portmaster is designed to use "basic" as much as possible"
The tool (which does not depend on other ports) and the information in/var/DB/PKG/in the system to detect the ports to be upgraded. You can
Ports-mgmt/portmaster find it. You can use this command to upgrade all installed ports: # portmaster
-. If an error is found during the upgrade, you can use the-F option to upgrade/re-compile all ports: # portmaster-AF. You can also use
Portmaster installs new ports in the system, upgrades all dependencies, and installs the new port: # portmaster
Shells/bash.

84. Run the following command to clear the entire ports suite: # portsclean-C. Over time, you may
Directory to accumulate a large number of source code files. You can manually delete these files, or use the following command to delete files not referenced by all ports: # portsclean
-D. In addition, you can also use the following command to delete the source code package file not used by the currently installed port: # portsclean-dd. The portsclean tool is
Part of the portupgrade suite.

85. Delete ports that have been installed but are no longer in use. A good tool for automatically completing this kind of work is ports-mgmt/pkg_cutleaves.
Port.

86. Run the pkg_info (1) command to find the files installed and where they are installed. For example, if you have installed foopackage
Version 1.0.0, then this command # pkg_info-l foopackage-1.0.0 |
Less will display all the files installed in this package. Pay special attention to the files in the man/directory. They may be the configuration files in the manual, ETC/directory, and
More documents under the DOC/directory. If you are not sure about the installed software version, you can use this command # pkg_info | grep-I
Foopackage. If ports needs to run when the server is started (just like an internet server), it usually puts the sample of a script
/Usr/local/etc/rc. d directory. To ensure correctness, you can view the script and edit or change the script name.

87. FreeBSD installs xfree86 by default before any version including FreeBSD 5.2.1-release.
Xfree86 project, Inc. Released X11 service. From FreeBSD 5.3-release, which is officially supported by default
X11 is changed to Xorg, which is an X11 Service developed by the X. Org Foundation and uses the same authorization as FreeBSD.

88. X was designed for the network at the beginning, so the "client-server" model was adopted. In the X model, "X Server"
Run on a computer with a keyboard, monitor, or mouse. The server is used to manage display information, process input information from the keyboard and mouse, and interact with other input and output devices (such
"Tablet", or as the projector of the output device ). Every x application (such as xterm, or Netscape) is a "customer Program
(Client )". The client program sends information to the server, for example, "please draw a window on these coordinates", and the server returns the processing information, for example, "the user just clicked the OK button ".

89. X's design philosophy is very similar to Unix's design philosophy, "tools, not policy ". This means that X
Instead of trying to determine how the task should be completed, we only provide some tools for the user. As for how to use these tools, it is the user's own business. This philosophy is extended
X, it does not specify what the window should look like on the screen, how to move the mouse, what key should be used to switch the form (for example, ALT + TAB, in Microsoft
In Windows), the toolbar of each window should look like something, whether they should have a close button, and so on. In fact, X is called
Responsibilities of the "Window Manager" application.

90. Configure X11: (1) create a configuration file: Xorg-Configure. After executing this command, a file named
Xorg. conf. New configuration file. X11
The program will try to detect the graphics hardware in the system and write the hardware information to the configuration file to load the correct driver. (2) test configuration file: Xorg-config
Xorg. conf. New. If you see a dark grid and an X-shaped mouse pointer, the configuration is successful. To exit the test, you only need to press
CTRL + ALT + backspace (to enable this option in version 7.4 or later, you need to enable this option in the serverlayout or
Add option "dontzap" "off" to serverflags "). (3) Adjust Xorg. conf. New
Configuration file and test: 1) the first thing to do is to set the update rate for the current system display. These values include the vertical and horizontal synchronization frequencies. Add them to the Xorg. conf. New
In the "Monitor" section, there may be no horizsync or vertrefresh in the configuration file. If so, you need to manually add
Set appropriate values after horizsync and vertrefresh. 2) Select the default resolution and color depth. This is in the "screen"
The default color depth is defaultdepth and the resolution is modes. In the process of discovering and solving the problem
The X11 log file for information about each device on the server helps you identify and troubleshoot problems. Log File in/var/log/xorg.0.log
(4) Put the configuration file in a public directory: you can find the specific location in Xorg (1. This location is usually/etc/X11/Xorg. conf
Or/usr/local/etc/X11/Xorg. conf.

91. After installing Kde, you need to tell X server to start this application to replace the default window manager. This can be done by editing. xinitrc
File to complete: For kde3: % echo "Exec startkde"> ~ /. Xinitrc for kde4: % echo
"Exec/usr/local/kde4/bin/startkde"> ~ /. Xinitrc


92. Install the sound card: (1) # kldload snd_emu10k1, or in the file/boot/loader. conf
Add a line in: snd_emu10k1_load = "yes", this method is used for creative soundblaster live! Sound Card. (2 )#
Kldload snd_driver, which is a meta driver that loads the most common device driver at a time. This will speed up the search drive. You can also use
/Boot/loader. conf tool to load all sound card drivers. If you want to know which sound card is selected after loading the snd_driver meta driver,
You can use CAT/dev/sndstat to query the/dev/sndstat file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.