<<TableOfContents()>>

= FreeBSDの基礎知識 =
= 概要 =
== 歴史 ==
== なぜFreeBSD? ==
= インストール =
== VNCコンソール起動の不具合 ==
'''MacOSX Lion以上では、さくらのVNCコンソールが起動しない。'''
http://decomo.info/wiki/blog/2013/2013-05-18

JAVA7ではなく、JAVA6にダウングレードすると正常に起動する。
(さらに、今回はFireFoxを使って起動した。)

----
Java for OS X 2013-002 および最新バージョンの Oracle Java 7 をインストールした後に、Java 7 を無効にして、Apple 提供の Java SE 6 Web プラグインと Web Start 機能を再び有効にしたい場合は、以下の手順を実行します。

注意:必ず管理者としてログインする必要があります。コマンドの後に管理者パスワードを求める画面が表示される場合は、パスワードを入力して、「return」または「Enter」キーを押してください。

ターミナルを開きます (「ユーティリティ」フォルダにあります)。
次のコマンドを入力して、「return」または「Enter」キーを押します。
{{{#!highlight sh
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled 
}}}
次のコマンドを入力して、「return」または「Enter」キーを押します。
{{{#!highlight sh
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
}}}
次のコマンドを入力して、「return」または「Enter」キーを押します。
{{{#!highlight sh
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
}}}
Java SE 6 Web Start を再び有効にするには、次のコマンドを入力して、「return」または「Enter」キーを押します。
{{{#!highlight sh
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
}}}
追加情報

以下の手順では、上記のコマンドを取り消し、Java 7 を復元します。

Java SE 6 Web Start を無効にするには、以下の手順に従います。
次のコマンドを入力して、「return」または「Enter」キーを押します。
{{{#!highlight sh
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws /usr/bin/javaws
}}}
管理者パスワードを求める画面が表示される場合は、パスワードを入力して、「return」または「Enter」キーを押してください。
最新バージョンの Oracle Java 7 JRE をダウンロードし、再インストールして、Java 7 アプレットプラグインを再び有効にします。
----
== インストール方法 ==
FreeBSD RELEESE9.1のインストールは、
さくらインターネットのマニュアルとFreeBSDハンドブックを参考にすればOK。

== SSHリモートログイン ==
'''ssh接続許可なしにssh接続しようとしたら、エラー出た。'''
{{{#!highlight sh
$ ssh kyonekura@49.212.142.106
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
d5:69:6b:a3:05:b4:b6:82:9b:10:e8:72:29:66:ca:be.
Please contact your system administrator.
Add correct host key in /Users/kyonekura/.ssh/known_hosts to get rid of this message.
Offending key in /Users/kyonekura/.ssh/known_hosts:16
RSA host key for 49.212.142.106 has changed and you have requested strict checking.
Host key verification failed.
}}}

{{{#!wiki note
'''解決'''

"/Users/kyonekura/.ssh/known_hosts" を削除した。
http://studio-kitchen.biz/blog/entry/000047.html
}}}

=== sshdの設定 ===
||sshdの設定ファイルパス||'''/etc/ssh/sshd_config'''||

 * 【FreeBSD】SSHでリモートログインを許可する (sshd) - kishiro.com http://www.kishiro.com/FreeBSD/ssh.html
 * SSH サーバの設定 - Penguin's Campus note http://www14.plala.or.jp/campus-note/vine_linux/server_ssh/sshd_config.html
 * SSHD_CONFIG (5) - OpenSSH-6.1p1 日本語マニュアルページ http://www.unixuser.org/~euske/doc/openssh/jman/sshd_config.html
を参考にして、sshdの設定をする。

{{{#!wiki note
'''さくらのリモートVNCでのキーマップに注意!'''

":"の入力は"Shift + q"でできる。
}}}
まだsudo環境を導入していないので、いちいちスーパーユーザー'''su'''になって、
{{{#!highlight sh
$ su
Password:
# vi /etc/ssh/sshd_config
Protocol 2
...
PermitRootLogin no
...
PasswordAuthentication yes
...
PermitEmptyPasswords no
}}}
とした。(デフォルトで付いているコメントアウト"#"を外したり、yes, noの書き換えをしたり。)
=== ssh接続をする ===

{{{#!highlight sh
$ ssh kyonekur@49.212.142.106
The authenticity of host 'www9092ue.sakura.ne.jp (49.212.142.106)' can't be established.
RSA key fingerprint is d5:69:6b:a3:05:b4:b6:82:9b:10:e8:72:29:66:ca:be.
Are you sure you want to continue connecting (yes/no)?    
}}}
ここでyesと入力してReturn。
{{{#!highlight sh
Password:
}}}
パスワードを入力してReturn。
{{{#!highlight sh
Last login: Sat Sep  7 06:57:12 2013 from uq1-221-170-28-105.tky.mesh.ad.jp
FreeBSD 9.1-RELEASE (GENERIC) #0 r243826: Tue Dec  4 06:55:39 UTC 2012

Welcome to FreeBSD!

Before seeking technical support, please use the following resources:

o  Security advisories and updated errata information for all releases are
   at http://www.FreeBSD.org/releases/ - always consult the ERRATA section
   for your release first as it's updated frequently.

o  The Handbook and FAQ documents are at http://www.FreeBSD.org/ and,
   along with the mailing lists, can be searched by going to
   http://www.FreeBSD.org/search/.  If the doc package has been installed
   (or fetched via pkg_add -r lang-freebsd-doc, where lang is the
   2-letter language code, e.g. en), they are also available formatted
   in /usr/local/share/doc/freebsd.

If you still have a question or problem, please take the output of
`uname -a', along with any relevant error messages, and email it
as a question to the questions@FreeBSD.org mailing list.  If you are
unfamiliar with FreeBSD's directory layout, please refer to the hier(7)
manual page.  If you are not familiar with manual pages, type `man man'.

Edit /etc/motd to change this login announcement.

If you write part of a filename in tcsh,
pressing TAB will show you the available choices when there
is more than one, or complete the filename if there's only one match.
kyonekura@2nd:/home/kyonekura % 
}}}

と表示されれば、サーバにログイン完了。

= パッケージ管理システム =
[[http://ja.wikipedia.org/wiki/パッケージ管理システム#FreeBSD]]
= Ports Collectionのアップデート =
5.6. Ports Collection の利用 http://www.freebsd.org/doc/ja/books/handbook/ports-using.html
 * '''5.6.1. Ports Collection の準備'''
を参考に。
{{{#!hilight sh
$ su
Password:
# portsnap extract
# portsnap fetch
# portsnap update
}}}
= portsの管理とアップデート =
公式ドキュメント<<BR>>
5.6. Ports Collection の利用 http://www.freebsd.org/doc/ja/books/handbook/ports-using.html
 * '''5.6.5. ports のアップグレード'''
を参考に。
== 方法1. portupgradeを使う方法 ==
portupgradeをインストールする。(20分ぐらい覚悟)
{{{#!highlight sh
$ su
Password:
# cd /usr/ports/ports-mgmt/portupgrade
# make install clean
}}}
途中のオプション
 * Options for portupgrade 2.4.10.2,2
 * Options for ruby 1.8.7.371,1
 * Options for perl 5.14.2_2
 * Options for m4 1.4.16_1,1
 * Options for help2man 1.40.12
は全てデフォルトで"OK"

== 方法2. portmasterを使う方法 ==
{{{#!highlight sh
$ su
Password:
# cd /usr/ports/ports-mgmt/portmaster
# make install clean
}}}
= sudoの導入 =
(15分ぐらいかかった感じ。測ってはいない)
{{{#!highlight sh
$ su
Password:
# cd /usr/ports/security/sudo
# make install clean
}}}
'''Options for sudo 1.8.6.p3_1'''というオプション選択画面が出るが、そのままで先に進む。(よくわからんし。)

さらに、
'''Options for libiconv 1.14'''が出るが、構わず"OK"

インストール完了。
== kyonekura is not in the sudoers file. ==
{{{#!highlight sh
kyonekura@2nd:/home/kyonekura % sudo cd

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password:
kyonekura is not in the sudoers file.  This incident will be reported.
kyonekura@2nd:/home/kyonekura % 
}}}
この問題に関しては後ほど。
= フォルダ構成 =
{{{#!highlight
FreeBSD
/
	/bin
	/lib
	/etc
	/usr
		/usr/bin
		/usr/lib
}}}
 * /etc/rc.conf <<FreeBSD起動時に起動するソフトウェア一覧

= ソフトウェアのインストール・アンインストール =
== パッケージという概念 ==
== パッケージ管理ソフト ==
=== ports ===
=== homebrew ===

= FreeBSDのアップグレード =
{{{#!wiki note
 * 第18章 FreeBSD のアップデートとアップグレード http://www.freebsd.org/doc/ja/books/handbook/updating-upgrading-freebsdupdate.html
 * バージョン一覧 http://ja.wikipedia.org/wiki/FreeBSD#.E3.81.93.E3.82.8C.E3.81.BE.E3.81.A7.E3.81.AE.E3.83.AA.E3.83.AA.E3.83.BC.E3.82.B9
}}}
== FreeBSD 8.1-RELEASEから FreeBSD 8.4-RELEASEへアップグレードしたい ==
=== まず、最新のパッチを当てる ===
先に、以下のコマンドを実行してセキュリティパッチをインストールする。
 * freebsd-update fetch
 * freebsd-update install

{{{
> uname -rs
FreeBSD 8.1-RELEASE
> sudo freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 5 mirrors found.
Fetching metadata signature for 8.1-RELEASE from update6.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.
Preparing to download files... done.

The following files will be added as part of updating to 8.1-RELEASE-p12:
/usr/src/lib/libc/gen/libc_dlopen.c

WARNING: FreeBSD 8.1-RELEASE HAS PASSED ITS END-OF-LIFE DATE.
Any security issues discovered after Wed Aug  1 09:00:00 JST 2012
will not have been corrected.
> sudo freebsd-update install
Installing updates...install: ///usr/src/lib/libc/gen/libc_dlopen.c: No such file or directory
 done.
> 
}}}
ここでエラーが出て終わっている。

Installing updates...install: ///usr/src/lib/libc/gen/libc_dlopen.c: No such file or directory

/usr/src/lib/libc/gen/libc_dlopen.c

を追加したいがディレクトリがないらしい。

解決策は、ディレクトリを作ってやればいいらしい。 http://b.mammadov.org/2012/02/libcdlopenc-error-freebsd-update.html

{{{
> sudo mkdir /usr/src/lib/libc/gen
}}}
すると、うまくいった。
{{{
> sudo freebsd-update install
Installing updates... done.
}}}

=== マイナーアップデート ===
8.4-RELEASEにアップデートしたい場合、次のコマンドを実行する。
{{{
# freebsd-update -r 8.4-RELEASE upgrade
}}}

{{{
> sudo freebsd-update -r 8.4-RELEASE upgrade
Password:
Looking up update.FreeBSD.org mirrors... 5 mirrors found.
Fetching metadata signature for 8.1-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base world/dict world/doc world/manpages

The following components of FreeBSD do not seem to be installed:
src/base src/bin src/cddl src/contrib src/crypto src/etc src/games
src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue
src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin
world/catpages world/games world/info world/proflibs

Does this look reasonable (y/n)? y

Fetching metadata signature for 8.4-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Fetching files from 8.1-RELEASE for merging... done.
Preparing to download files...
...
}}}