FreeBSD 12.1
Installed on 2021/09/19
FreeBSD with Virtualbox
Install
Download from USTC Mirror.
Do sha256 check on macbook: openssl dgst -sha256 xxx.iso
.
Create bootable USB drive:
sudo dd if=./Downloads/FreeBSD-12.1-RELEASE-amd64-dvd1.iso of=/dev/rdisk2 bs=1m
sync
diskutil eject /dev/disk2
安装到华硕2010款笔记本上,测试开机30s,关机17s
Config
whoami
shutdown -p now
网络配置
连接网线
ifconfig
Use DHCP
vi /etc/rc.conf
service netif restart
service routing restart
ping -c5 192.168.1.9
ping www.baidu.com
键盘设置Dvorak
kbdmap
重启失效
添加用户到wheel group
pw groupshow wheel
adduser直接新建用户
停止sendmail服务
矫正时间
tzsetup
ntpdate time1.aliyun.com
pkg换源
创建 /usr/local/etc/pkg/repos/FreeBSD.conf 覆盖配置,文件内容如下:
FreeBSD: {
url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly",
}
修改配置后,运行 pkg update -f 更新索引
pkg info
pkg install curl
pkg remove curl
pkg autoremove
pkg prime-list
pkg clean
pkg clean -a
pkg install axel
配置port,portsnap fetch太慢
pkg install subversion
svn checkout https://svn.FreeBSD.org/ports/head /usr/ports
svn update /usr/ports
给freebsd打补丁
freebsd-update fetch
freebsd-update install
安装xfce桌面环境
pkg install firefox xpdf nvidia-driver-340- nvidia-xconfig
Add the following line to /boot/loader.conf:
nvidia_load=“YES”
reboot
Run nvidia-xconfig to create xorg.conf
startx and you will see nvidia splash.
(faq](https://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/x.html#idp49679352)
The latest versions of nVidia cards are supported by the x11/nvidia-driver port.
Older drivers are available as x11/nvidia-driver-###
nVidia provides detailed information on which card is supported by which driver on their web site.
解决没声音
确认声卡正常
pkg install xfce4-pulseaudio-plugin xfce4-battery-plugin xfce4-datetime-plugin xfce4-whiskermenu-plugin
FreeBSD Handbook学习笔记
3. FreeBSD Basics
3.3 Users and Basic Account Management
There are three main types of accounts: system accounts, user accounts, and the superuser account.
The user running this command (su) must be in the wheel group or else the command will fail.
3.4 Permissions
In addition to file permissions, FreeBSD supports the use of “file flags”.
With file flags, even root can be prevented from removing or altering files.
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.
The real user ID is the UID who owns or starts the process. The effective UID is the user ID the process runs as.
3.5 Directory Structure
man hier
The FreeBSD directory hierarchy is fundamental to obtaining an overall understanding of the system.
This file (/etc/fstab) is a table of various file systems and mount points and is read by the system.
df -h
3.6 Disk Organisation
Each partition is identified by a letter from a through to h.
File systems are contained in partitions.
Disks in FreeBSD 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.
/dev/ada0s1a The first partition (a) on the first slice (s1) on the first SATA disk (ada0).
3.8. Processes and Daemons
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 init(8) which is always the first process to start at boot time and which always has a PID of 1.
View process: ps top
One of the most useful sets is auxww, where a displays information about all the running processes of all users, u displays the username and memory usage of the process' owner, x displays information about daemon processes, and ww causes 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.
Two signals can be used to stop a process: SIGTERM and SIGKILL. SIGTERM is the polite way to kill a process
pgrep -l ssh
/bin/kill -s HUP 824 (也可以用TERM或KILL来尝试)
3.9 Shells
FreeBSD comes with several shells, including the Bourne shell (sh(1)) and the extended C shell (tcsh(1)). Other shells are available from the FreeBSD Ports Collection, such as zsh and bash.
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.
echo $PATH
echo $SHELL
How to set an environment variable differs between shells. In tcsh(1) and csh(1), use setenv to set environment variables. In sh(1) and bash, use export to set the current environment variables.
The easiest way to permanently change the default shell is to use chsh.
The new shell must be present in /etc/shells.
Shell redirection is the action of sending the output or the input of a command into another command or into a file.
ls > directory_listing.txt
sort < directory_listing.txt
sort < directory_listing.txt > sorted.txt
Every UNIX® system has file descriptors, which include standard input (stdin), standard output (stdout), and standard error (stderr).
All three are considered I/O based file descriptors and sometimes considered streams.
Another method of redirection is the pipe operator.
Basically, a pipe allows the standard output of a command to be passed as standard input to another command, for example:
cat directory_listing.txt | sort | less
3.10 Text Editors
echo $EDITOR
Just use vi.
3.11. Devices and Device Nodes
A device is a term used mostly for hardware-related activities in a system, including disks, printers, graphics cards, and keyboards. When FreeBSD boots, the majority of the boot messages refer to devices being detected. A copy of the boot messages are saved to /var/run/dmesg.boot.
Each device has a device name and number. For example, ada0 is the first SATA hard drive, while kbd0 represents the keyboard.
Most devices in FreeBSD must be accessed through special files called device nodes, which are located in /dev.
3.12 Manual Pages
man man
man 1 chmod
man 2 chmod
man -k mail # search for keywords, Emulate apropos(1)
man -f * | more # Emulate whatis(1)
This command displays a list of commands that have the keyword “mail” in their descriptions. This is equivalent to using apropos(1) (or whatis(1)).
4. Installing Applications: Packages and Ports
FreeBSD is bundled with a rich collection of system tools as part of the base system. In addition, FreeBSD provides two complementary technologies for installing third-party software: the FreeBSD Ports Collection, for installing from source, and packages, for installing from pre-built binaries. Either method may be used to install software from local media or from the network.
A FreeBSD port is a collection of files designed to automate the process of compiling an application from source code. The files that comprise a port contain all the necessary information to automatically download, extract, patch, compile, and install the application.
A FreeBSD package contains pre-compiled copies of all the commands for an application, as well as any configuration files and documentation.
Both packages and ports understand dependencies. If a package or port is used to install an application and a dependent library is not already installed, the library will automatically be installed first.
Before installing any application, check freebsd for security issues related to the application or type pkg audit -F to check all installed applications for known vulnerabilities.
5. The X Window System
KDE5和wayland
安装xorg前df -h,只用了1.9G
pkg install xorg
pw groupmod video -m jru || pw groupmod wheel -m jru
desktop
8.2 Why Build a Custom Kernel?
Building a custom kernel is often a rite of passage for advanced BSD users. This process, while time consuming, can provide benefits to the FreeBSD system. Unlike the GENERIC kernel, which must support a wide range of hardware, a custom kernel can be stripped down to only provide support for that computer's hardware.
11.4 Managing Services in FreeBSD
FreeBSD uses the rc(8) system of startup scripts during system initialization and for managing services. The scripts listed in /etc/rc.d provide basic services which can be controlled with the start, stop, and restart options to service(8).
service sshd restart/start/stop/status
This procedure can be used to start services on a running system. Services will be started automatically at boot time as specified in rc.conf(5). (/etc/rc.conf)
Since the rc(8) system is primarily intended to start and stop services at system startup and shutdown time, the start, stop and restart options will only perform their action if the appropriate /etc/rc.conf variable is set. For instance, sshd restart will only work if sshd_enable is set to YES in /etc/rc.conf. To start, stop or restart a service regardless of the settings in /etc/rc.conf, these commands should be prefixed with “one”.
service sshd onestart
To check if a service is enabled in /etc/rc.conf, run the appropriate rc(8) script with rcvar.
service sshd rcvar
In some cases, it is also possible to reload a service. This attempts to send a signal to an individual service, forcing the service to reload its configuration files. In most cases, this means sending the service a SIGHUP signal. Support for this feature is not included for every service.
The principal location for system configuration information is /etc/rc.conf. This file contains a wide range of configuration information and it is read at system startup to configure the system. It provides the configuration information for the rc* files.
The entries in /etc/rc.conf override the default settings in /etc/defaults/rc.conf. The file containing the default settings should not be edited. Instead, all system-specific changes should be made to /etc/rc.conf. Upgrading the system will not overwrite /etc/rc.conf, so system configuration information will not be lost.
References
学FreeBSD有哪些经典资料
Miscellaneous
笔记本安装FreeBSD
=========开启节电===========
1. 内核配置中增加:
device cpufreq
默认GENERIC里面有。
- /etc/rc.conf 中增加:
powerd_enable=“YES”