DebianでlocateのDBを更新する

ファイルを探すときに便利なlocateですが、通常は定期的にDBが更新され、検索したファイルが表示されます。

こんな感じ。

# locate php.ini
/etc/php5/apache2/php.ini
/etc/php5/apache2/php.ini.ucf-dist
/etc/php5/cli/php.ini
/usr/share/doc/php5-common/examples/php.ini-dist
/usr/share/doc/php5-common/examples/php.ini-paranoid
/usr/share/doc/php5-common/examples/php.ini-recommended
/usr/share/php5/php.ini-dist
/usr/share/php5/php.ini-dist.cli

もし、locateが入ってなかったら以下のコマンドでインストール。

# aptitude install locate

でも、パッケージをインストールした際など、すぐにlocateでファイルを見つけたくなるときが多々あります。
そんな時はDBを手動で更新!

# /usr/bin/updatedb

便利だー

26
3月
2010

Debianにaptitudeをインストール

apt-getの便利バージョンのaptitudeを入れてみます。
aptitudeはapt-getのinstallとupdateを一気にやってくれて、依存関係の解消も少し向上しているそうですね。

インストールはapt-getで出来ました。

# apt-get install aptitude
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
以下の特別パッケージがインストールされます:
  libsigc++-2.0-0c2a
提案パッケージ:
  tasksel debtags
推奨パッケージ:
  aptitude-doc-en aptitude-doc libparse-debianchangelog-perl
以下のパッケージが新たにインストールされます:
  aptitude libsigc++-2.0-0c2a
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 58 個。
2906kB のアーカイブを取得する必要があります。
展開後に追加で 8659kB のディスク容量が消費されます。
続行しますか [Y/n]? Y
取得:1 http://ftp.debian.org etch/main libsigc++-2.0-0c2a 2.0.17-2 [33.3kB]
取得:2 http://ftp.debian.org etch/main aptitude 0.4.4-4 [2873kB]
2906kB を 9s で取得しました (318kB/s)
未選択パッケージ libsigc++-2.0-0c2a を選択しています。
(データベースを読み込んでいます ... 現在 14654 個のファイルとディレクトリがインストールされています。)
(.../libsigc++-2.0-0c2a_2.0.17-2_i386.deb から) libsigc++-2.0-0c2a を展開しています...
未選択パッケージ aptitude を選択しています。
(.../aptitude_0.4.4-4_i386.deb から) aptitude を展開しています...
libsigc++-2.0-0c2a (2.0.17-2) を設定しています ...

aptitude (0.4.4-4) を設定しています ...

#

via: apt-getとaptitudeの違い

25
3月
2010

Debianのバージョンを確認する

Debian の場合、OSのバージョンはファイルに記述してあるだけなので、
lessなどで確認する事が出来るようです。

# less /etc/debian_version
4.0

4.0ということはetchですね~

25
3月
2010

CPANでGD::Barcode::NW7をインストール

NW7でバーコード生成をする為に、CPANのモジュールを入れる。

さっそくインストール

# cpan
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan> install GD::Barcode::NW7

すると、Warningが出た。

System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz"  > /root/.cpan/sources/authors/01mailrc.txt"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz] doesn't exist
No external ftp command available

どうやら、ダウンロード先URLが ftp://ftp.perl.org/pub/CPAN になっていて、そこにダウンロード対象のモジュールが無いみたい。

CPANの設定を確認してみる

cpan> o conf
CPAN::Config options from /etc/perl/CPAN/Config.pm:
    commit             Commit changes to disk
    defaults           Reload defaults from disk
    init               Interactive setting of all options

    build_cache        10
    build_dir          /root/.cpan/build
    cache_metadata     1
    cpan_home          /root/.cpan
    cpan_version_check 1
    dontload_hash
    ftp                /usr/bin/ftp
    ftp_proxy
    getcwd             cwd
    gpg                /usr/bin/gpg
    gzip               /bin/gzip
    histfile           /root/.cpan/histfile
    histsize           100
    http_proxy
    inactivity_timeout 0
    index_expire       1
    inhibit_startup_message 0
    keep_source_where  /root/.cpan/sources
    lynx
    make               /usr/bin/make
    make_arg
    make_install_arg
    makepl_arg         INSTALLDIRS=site
    ncftp
    ncftpget
    no_proxy
    pager              /usr/bin/less
    prerequisites_policy ask
    scan_cache         atstart
    shell              /bin/bash
    tar                /bin/tar
    term_is_latin      1
    unzip              /usr/bin/unzip
    urllist
    wget               /usr/bin/wget

urllist が空でした。
urllist が空の場合は、ダウンロード先URLは ftp://ftp.perl.org/pub/CPAN になるようです。

ダウンロード先URLを追加

以下のサイトから国内のダウンロード先URLを選んで追加する。
http://www.cpan.org/SITES.html

cpan> o conf urllist push ftp://ftp.nara.wide.ad.jp/pub/CPAN/
cpan> o conf commit
commit: wrote /etc/perl/CPAN/Config.pm

再度、NW7をインストール

cpan> install GD::Barcode::NW7

サンプルを動かしてみる。

nw7.pl というファイル名でサンプルを作成してバーコードを生成してみる。

# vi nw7.pl

中身はコレ。

#!/use/bin/perl

use GD::Barcode::NW7;
$data = '1234567890123';
binmode STDOUT;
print GD::Barcode::NW7->new($data)->plot->png;
# perl nw7.pl
Can't locate object method "Small" via package "GD::Font" (perhaps you forgot to load "GD::Font"?) at /usr/local/share/perl/5.8.8/GD/Barcode/NW7.pm line 83.

GD::Font が入ってないみたいですね。

libgd-gd2-perl をインストール

Debianなのでapt-getで。

# apt-get install libgd-gd2-perl
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
以下のパッケージが新たにインストールされます:
  libgd-gd2-perl
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 58 個。
218kB のアーカイブを取得する必要があります。
展開後に追加で 586kB のディスク容量が消費されます。
取得:1 http://ftp.debian.org etch/main libgd-gd2-perl 1:2.34-1 [218kB]
218kB を 2s で取得しました (93.3kB/s)
未選択パッケージ libgd-gd2-perl を選択しています。
(データベースを読み込んでいます ... 現在 14610 個のファイルとディレクトリがインストールされています。)
(.../libgd-gd2-perl_1%3a2.34-1_i386.deb から) libgd-gd2-perl を展開しています...
libgd-gd2-perl (2.34-1) を設定しています ...
#

再度、サンプルを実行

# perl nw7.pl

今度はうまくいったので、画像に出力してみる。

# perl nw7.pl > nw7.png

無事、PerlでNW7のバーコードを生成できました~

24
3月
2010

CPANの初期設定

仕事でPerl使う事があり、開発環境のDebianでCPANの設定をしてみる。

cpan は既に入っているようなので、 cpan コマンドを実行。

# cpan

cpanコマンドが使えない場合は、

# perl -MCPAN -e shell

「マニュアル設定しますか?」という質問に「no」と回答すると初期設定は完了。

# cpan

/etc/perl/CPAN/Config.pm initialized.

CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all around the globe.
Many countries have at least one CPAN site already. The resources
found on CPAN are easily accessible with the CPAN.pm module. If you
want to use CPAN.pm, you have to configure it properly.

If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)

Are you ready for manual configuration? [yes] no

設定が失敗したら

以下のように設定ファイルを削除して、再度cpanを実行すれば、最初から設定が出来る。

# rm /etc/perl/CPAN/Config.pm
24
3月
2010

MySQLの時刻修正

Debianで時刻あわせの続きです。

サーバの時刻を修正したのにMySQLの時刻が直らない。
そんなときは再起動です。

debian:~# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld.
debian:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.32-Debian_7etch10-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2010-02-01 16:32:17 |
+---------------------+
1 row in set (0.00 sec)

mysql>

なおったー

01
2月
2010

DebianにGitをインストール

ちょっと必要になったので、GitをDebianにインストールしてみます。

apt-get install git-core

簡単ですね~

GitはCVSやSVNのようなバージョン管理システムで、Linuxカーネルのソース管理を目的として作られました。SVNと同じように、TracでもGitが使えるそうですね。

またいろいろ試してみようと思います。

thumbnailGit – Fast Version Controll System

Gitの公式サイトです。

thumbnailGit入門

チュートリアルやマニュアルの日本語訳があり、マニュアルはzipでダウンロードできるようになっています。

thumbnailgitコマンド簡易一覧 for svnユーザ

SVNが使い慣れているという方には、このサイトがいいかもしれませんね。

30
10月
2009