FreeBSD系统使用方法

说明:

1. Freebsd下文本编辑工具ee,vi;
2. Freebsd安装软件有一个类似于yum apt-get的组件——ports,要安装某软件只需要进入ports下该目录内执行make install即可进行安装,如cd /usr/ports/ftp/wget &&make install,这种安装wget的方式我们称之为使用ports安装wget;
3. 使用ports安装的软件都会在/usr/ports/distfiles/(该目录在系统初始状态下是没有的,需要执行过ports安装后才会生成)目录下面下载目标软件的源码包,如果使用ports无法自动下载到某软件包,可以手动下载相应版本的软件包放到该目录下然后继续执行make install自动编译安装;
4.
一、 基本服务配置方法
1.网络配置


使用ee编辑器进入rc.config文件,并在文件中修改或者添加入下框中所示各项配置:
#ee /etc/default/rc.config
# — sysinstall generated deltas — # Sat Jan 9 00:57:21 2016
# Created: Sat Jan 9 00:57:21 2016
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
linux_enable=”YES”
moused_enable=”YES”
moused_port=”/dev/psmo”
defaultrouter=”10.8.3.1″
gateway_enable=”YES”
hostname=”CE-TEST.skysoft”
keymap=”us.iso”
ifconfig_re0=”inet 10.8.3.15 netmask 255.255.255.128″
inetd_enable=”YES”
sshd_enable=”YES”
ipv6_enable=”YES”
ipv6_gateway_enable=”YES”
ifconfig_re1=”up”
ifconfig_re2=”up”
ipv6_network_interfaces=”re1 re2″
ipv6_default_interface=”re1″
ipv6_prefix_re1=”3ffe:501:ffff:100″
ipv6_prefix_re2=”3ffe:501:ffff:101″
rtadvd_enable=”NO”
devd_enable=”NO”
samba_enable=”YES”
其中:ifconfig_re0配置的值为网卡0的IP地址及子网掩码地址,其他项顾名思义。

网络配置方法参考详细步骤:
配置文件实例:

2.sshd服务配置:
前言:最近下载了FreeBSD,在虚拟机上安装,第一步先要开启SSH服务,用终端putty软件可以实现在windows系统进行远程管理,

ee /etc/inetd.conf
ssh stream top nowait root /usr/sbin/sshd
ssh stream tcp6 nowait root /usr/sbiin/sshd
去掉ssh前的#,保存退出
2、让root能够远程登录,系统默认禁止root远程登录
ee /etc/ssh/sshd_config (注意是sshd_config,而不是ssh_config,否则会出现:sing keyboard-interactive authentication
Using keyboard-interactive authentication错误)
在文末添加以下几条:
PermitRootLogin yes
PasswordAuthentication yes
PermitEmptyPasswords no
3、重起sshd
#/etc/rc.d/sshd/restart
三个步骤完毕就OK,在win下开启putty软件,通过服务器IP连接吧

其他设置:配置sshd让root不能登录,但其他用户可以登录
1、不允计root远程登录,用普通帐户登录后SU切换得到root
2、改变配置文件
查找:
#vi /etc/ssh/sshd_config
将:
#PasswordAuthentication no
#PermitEmptyPasswords no
修改成:
PermitEmptyPassord no #不允许空密码登录
PasswordAuthentication yes #这个开启密码认证模式
3.安装wget
#cd /usr/ports/ftp/wget
#make install
之后就可以使用wget 来下载源码包进行安装了,本文档主要是解决源码安装samba的问题,因为如果samba本身就已经ok了的话,可以下载源码包通过samba来上传并安装,或者通过scp远程拷贝源码进行安装。

4.安装samba
4.1.组件安装
#cd /usr/ports/distfiles
# wget https://download.samba.org/pub/samba/stable/samba-3.6.13.tar.gz –no-check-certificate
#cd /usr/ports/net/samba36/
#make install

Ok
之后会下载tbd-1.2.11.tar.gz,下载不下来
所以执行下面的步骤安装:
#cd /usr/ports/distfiles
# wget https://download.samba.org/pub/tdb/tdb-1.2.11.tar.gz –no-check-certificate
然后在返回:
#cd –
#make install

然后:
#cd /usr/ports/distfiles
# wget https://download.samba.org/pub/talloc/talloc-2.0.8.tar.gz –no-check-certificate
#cd –
#make install

然后:这次下载成功!继续。
之后:
#cd –
# wget http://ftp.nsysu.edu.tw/FreeBSD/ports/local-distfiles/itetcu/libexecinfo-1.1.tar.bz2 –no-check-certificate
#cd –
#make install

最后终于安装完成,提示如下:

This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/samba

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type ‘make deinstall’
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.samba.org/
可见:samba的启动脚本为/usr/local/etc/rc.d/samba,和ubuntu centos fedora都有所不同哟。

以上安装步骤很奇葩,主要是想把整个安装过程再现一下,整个安装过程就是遇到问题解决问题的过程,接下来就可以进行samba服务配置了哟!
4.2.服务配置
4.2.1.添加samba账户
#smbpasswd –a nick
4.2.2.修改配置文件
#vi /usr/local/etc/smb.conf
修改内容很少!只需要将下示代码中的browseable的值从no改为yes即可。
[homes]
comment = Home Directories
browseable = yes
writable = yes
4.2.3.修改网络配置文件
在/etc/rc.conf文件末尾添加上以下文字,开启samba。
samba_enable=”YES”
4.3启动samba服务
#/usr/local/etc/rc.d/samba start|restart

4.4.测试
在windows端输入服务器IP测试 \\10.8.3.15 正常的话就可以进入/nick 账户的家目录进行访问了。
5.安装vim
FreeBSD默认的编辑工具vi 和 ee,这个vi和ubuntu下的差别有点大,使用起来非常不爽,于是想安装个vim来试试。
#cd /usr/ports/editors/vim
#make install
执行到此vim 仅仅是安装上了,但是使用效果和原生的vi没有两样,无法再编辑的过程中执行退格删除,无法“正常使用”,执行以下内容稍微适配就行了!
设置vimrc 文件
cp /usr/local/share/vim/vim72/vimrc_example.vim /usr/local/share/vimrc
或者到个人的环境中
保存为 ~/.vimrc
Ok,到此vim就成功的安装适配完成了,还有些更牛逼的配置请参考vim的配置方法,我的目的达到了。

二、 其他相关问题及解决方法
1.无法使用键盘上的home,end键
使用功能secureCRT登录FreeBSD时,无法使用键盘上行“home”和“end”键。
解决方法:将终端的secsion options—>emulation—>terminal设置成LINUX即可使用键盘的“home”和“end”键了。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注