2011年2月16日水曜日

let'snote cf-y7cw5axs の液晶分解修理

■ジャンクのcf-y7cw5axsが手に入ったので修理する。

○状況
  • 液晶パネル割れ
  • ヒンジカバー無し

webで調べても、何故かcf-y7の情報は少ない、
分解や液晶パネル等の部品の型番も見つからなかった。
 webで分解が難しいと情報があったが、実際に分解して見ると、たしかにこの製品は分解の難易度が高い、

○液晶の型番は、東芝松下のLTD141ENFP
14インチsxga+(1400*1050)
cf-y5のLTD141ENAPで問題なさそうなので、ジャンクで本体ごと購入した。

○DVDコンボドライブ UJDA769

○画面部分の構造

液晶枠のプラスチックカバーが四方から天板に覆いかぶさるように取り付けられ、天板側がメス、液晶枠がオスのツメで少々キツメにはまっている構造になっている。
天板には画面を閉じるときにロックする為のラッチが有るのみで、
液晶パネルとインバーターは、液晶枠側に両面テープで接着されている。


○画面部分の分解
液晶の交換は、本体側の分解の必要はなかった。
ヒンジ部分のネジ4本を外し、マグネシウムの天板を外せば良いが、液晶パネルに力を加えないように慎重に行う。


天板と液晶枠の隙間に間に爪楊枝などを複数滑り込ませながら少しずつ爪を外していく、この時なるべく液晶を押さないようにして、天板を持ち上げるようにする。
左右のヒンジ部分から初めて、ラッチ側を最後に外すようにすると良い

2011年1月3日月曜日

apacheのサーバー情報を表示しない

  • レスポンスヘッダと"Not Fount"ページのサーバー情報を制限する。
※CentOSの場合
"/etc/httpd/conf/httpd.conf"ファイルの"ServerTokens **"を"ServerTokens Prod"に変更する。
#apache再起動
/etc/init.d/httpd restart
  • エラーページのサーバー情報を表示しない。
※CentOSの場合
"/etc/httpd/conf/httpd.conf"ファイルの"ServerSignature **"を"ServerSignature Off"に変更する。
#apache再起動
/etc/init.d/httpd restart

2011年1月2日日曜日

さくらのVPSでredmine

初期設定



ログインする



  • login:root


  • pass:*******


#必要に応じてrootパスワードを変更する
passwd

#作業ユーザー作成 ※以後作業ユーザー名は"tarou"として進める
useradd -m tarou
passwd tarou
#追加したユーザーでsshログインできることを確認後作業する
exit

追加したユーザーでのssh接続で作業する

#管理者ユーザに切り替える
su -

#rootのssh接続を無効にする
cd /etc/ssh
mkdir /etc/ssh/00Backup
cp /etc/ssh/sshd_config /etc/ssh/00Backup/sshd_config_`date +%Y%m%d%H%M`
vi /etc/ssh/sshd_config


"sshd_config"に"PermitRootLogin no"を追加する
#sshdを再起動
/etc/init.d/sshd restart
#rootでsshログイン出来ないことを確認する

#iptables(ファイヤーウォール)設定
vi /root/iptables-init.sh

"iptables-init.sh"に以下コードを保存しiptables-init.shスクリプトファイルを作成する
#!/bin/sh

iptables -F
iptables -X

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A INPUT -s 10.0.0.0/8 -j DROP
iptables -A INPUT -s 172.16.0.0/12 -j DROP
iptables -A INPUT -s 192.168.0.0/16 -j DROP

# iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT


#スクリプト実行
sh /root/iptables-init.sh
#設定内容を表示する。
iptables -L

結果が以下の様な感じになっていればOK
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
DROP       all  --  10.0.0.0/8           anywhere
DROP       all  --  172.16.0.0/12        anywhere
DROP       all  --  192.168.0.0/16       anywhere
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

#現在の設定を保存する。
iptables-save > /etc/sysconfig/iptables
#iptableを再起動する。
/etc/rc.d/init.d/iptables restart
#iptableの起動設定を表示する。
chkconfig --list |grep iptables

結果が以下の様に2/3/4/5がonならOK
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off

違う場合は"# chkconfig --level 2345 iptables on"を実行する。

renmineインストール



cd ~
#yum管理のプログラムを更新する。
yum update
#開発系のツールをインストールする。
yum groupinstall -y "Development Tools" 
#その他のツールをインストールする。
yum install -y openssl-devel readline-devel zlib-devel

#apacheをインストールする。
yum install -y httpd httpd-devel

mysql5.1以上とphp5.3以上をインストールする為、yumのリポジトリ設定を追加する。

cd /etc/yum.repos.d
#remiリポジトリ設定ファイルをダウンロードする。
wget http://rpms.famillecollet.com/remi-enterprise.repo
#epelリポジトリ設定をインストールする。※こちらは、入れなくてもOK
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

#mysqlをインストール"mysql-devel"と指定すると"i386"の古いバージョンがインストールされてしまうので"mysql-devel.x86_64"と指定する。
yum install mysql-server mysql-devel.x86_64
#リポジトリremiを指定してmysqlをアップデートする。
yum --enablerepo=remi update mysql-server mysql-devel.x86_64
#バージョン確認5.1.54以上なら成功。

インストール済みのmysqlでエラーが出る場合は、以下をコメント外して実行し、完全にアニンストールする。
# yum remove mysql mysql-server mysql-devel
# rm -Rf /usr/share/mysql
# rm -Rf /var/lib/mysql

#不要なリポジトリを無効にしてインストールする場合の例。※他のリポジトリが原因でインストールが上手くいかない場合
#yum --disablerepo=* --enablerepo=remi install mysql mysql-server


バージョンは都度変更する
cd /root
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar xzvf ./ruby-enterprise-1.8.7-2010.02.tar.gz
./ruby-enterprise-1.8.7-2010.02/installer --no-dev-docs
#"readline-devel"が無いと言われたら"yum install readline-devel"でreadlineインストール後に再試行する。

#途中"[/opt/ruby-enterprise-1.8.7-2010.01] :"このような入力プロンプトが出たら"/usr/local"を入力する。


#sqliteやPostgreSQLがインストールされていないと、以下のような警告が出る、使用しない場合は無視してOK
* sqlite3-ruby
 * pg


gem install passenger
yum install -y curl-devel
passenger-install-apache2-module

apache設定



パフォーマンス(高速化・メモリ節約など)の為、ApacheのMPMを"prefork"(※デフォルト)から"worker"に変更する。※PHPでは"prefork MPM"を推奨しているらしい



cd /etc/sysconfig/
mkdir /etc/sysconfig/00Backup
cp /etc/sysconfig/httpd /etc/sysconfig/00Backup/httpd_`date +%Y%m%d%H%M`
vi /etc/sysconfig/httpd

#httpdファイルに"HTTPD=/usr/sbin/httpd.worker"を追加又は有効化する
#passenger用にapache設定ファイルを作成する
vi /etc/httpd/conf.d/passenger.conf

設定ファイル"passenger.conf"を以下の内容で保存する。
3-5行は"# passenger-install-apache2-module"で表示された内容に置き換える
# Passenger preferences.
# Passenger-install-apache2-module to use the content that appears during installation.
#
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2
PassengerRuby /usr/local/bin/ruby

# Passenger will be added to remove the HTTP header setting.
#
Header always unset "X-Powered-By" 
Header always unset "X-Rack-Cache" 
Header always unset "X-Content-Digest" 
Header always unset "X-Runtime" 

# Passenger necessary to add the settings for tuning.
#
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 3600
PassengerUseGlobalQueue on
PassengerHighPerformance on
PassengerStatThrottleRate 10
RailsSpawnMethod smart
RailsAppSpawnerIdleTime 86400
RailsFrameworkSpawnerIdleTime 0

apacheの動作確認と自動起動設定



/etc/init.d/httpd start
/sbin/chkconfig httpd on

mysql設定



mysqlの文字コードをutf8に変更する



cd /etc
mkdir /etc/00Backup
cp /etc/my.cnf /etc/00Backup/my.cnf_`date +%Y%m%d%H%M`
vi /etc/my.cnf

設定ファイル"my.cnf"に"default-character-set=utf8"を3箇所追加して以下の様に変更する。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
default-character-set=utf8

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/Mysqld.pid
default-character-set=utf8

[mysql]
default-character-set=utf8


mysql起動と自動起動設定
/etc/init.d/mysqld start
/sbin/chkconfig mysqld on


rootパスワード変更と匿名ユーザ削除



mysql -uroot

mysqlプロンプトで以下を入力
mysql> use mysql;
mysql> update user set password=password('dbpasuwaado') where user = 'root';
mysql> delete from user where user = '';
mysql> flush privileges;
mysql> exit;

redmine用ユーザ作成



mysql -uroot -p

mysqlプロンプトで以下を入力
mysql> create database db_redmine default character set utf8;
mysql> grant all on db_redmine.* to user_redmine identified by 'dbpasuwaado';
mysql> flush privileges;
mysql> exit;

Redmine作業



Redmineダウンロードと設置



cd ~
wget http://rubyforge.org/frs/download.php/73457/redmine-1.0.4.tar.gz
tar zxvf redmine-1.0.4.tar.gz
mv ./redmine-1.0.4 /var/lib/redmine
cd /var/lib/redmine

#データベース設定ファイル記述
cd config/
mkdir /var/lib/redmine/config/00Backup
cp /var/lib/redmine/config/database.yml.example /var/lib/redmine/config/database.yml
vi /var/lib/redmine/config/database.yml
#"database.yml"に以下を記述する。

# MySQL (default setup).

production:
  adapter: mysql
  database: db_redmine
  host: localhost
  username: user_redmine
  password: dbpasuwaado
  encoding: utf8

development:
  adapter: mysql
  database: redmine_development
  host: localhost
  username: root
  password:
  encoding: utf8

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: redmine_test
  host: localhost
  username: root
  password:
  encoding: utf8

test_pgsql:
  adapter: postgresql
  database: redmine_test
  host: localhost
  username: postgres
  password: "postgres" 

test_sqlite3:
  adapter: sqlite3
  database: db/test.db

メール設定ファイル記述



cp email.yml.example email.yml
vi email.yml
#"email.yml"に以下を記述する。

production:
  delivery_method: :smtp
  smtp_settings:
    tls: true
    address: smtp.gmail.com
    port: 587
    domain: pj.example.jp
    authentication: :plain
    user_name: pj@example.jp
    password: mailpasuwaado

development:
  delivery_method: :smtp
  smtp_settings:
    tls: true
    address: smtp.gmail.com
    port: 587
    domain: example.jp
    authentication: :plain
    user_name: pj+dev@example.jp
    password: mailpasuwaado

#gmailのsmtpサーバはtlsを使うが、ruby1.8はtls未対応なので以下の設定を行う。
cd /var/lib/redmine/
gem install tlsmail
cd config/
cp environment.rb 00Backup/environment.rb_201101022218
vi environment.rb
#以下の2行を"environment.rb"ファイルの最後に追加する。
##require "tlsmail" 
##Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
/etc/init.d/httpd restart

初期データベース構築



cd /var/lib/redmine/
rake config/initializers/session_store.rb
rake db:migrate RAILS_ENV=production

"rack"のバージョンエラーが出るのでバージョンダウンして再試行
gem uninstall rack
gem install rack -v 1.0.1
rake db:migrate RAILS_ENV=production

Apache-Passenger-Redmine 連携設定



ディレクトリのパーミッション変更



chown -R apache:apache /var/lib/redmine

apache用virtualhosts設定ファイル記述



vi /etc/httpd/conf.d/virtualhost.conf

"/etc/httpd/conf.d/virtualhost.conf"を以下の内容で作成する。


NameVirtualHost *:80
#バーチャルドメインを設定する場合は、最初の設定がデフォルト設定となりIP接続時などには、この設定が有効になる。

    ServerName example.jp
    DocumentRoot /etc/httpd



    ServerName pj.example.jp
    DocumentRoot /var/lib/redmine/public


サーバー再起動
/etc/init.d/httpd restart


PHPインストール



#phpのインストール
yum --enablerepo=remi install php php-mysql php-devel php-mcrypt php-mbstring php-zts

#phpのバージョン確認
php -v

phpMyAdminインストール



DNSレコードにphpmyadmin.example.jpの設定をする。


cd ~
wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.8.1/phpMyAdmin-3.3.8.1-all-languages.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1291797693&use_mirror=jaist
tar -zxvf phpMyAdmin-3.3.8.1-all-languages.tar.gz
mv ./phpMyAdmin-3.3.8.1-all-languages /var/lib/phpMyAdmin
cd /var/lib/phpMyAdmin/
cp /var/lib/phpMyAdmin/config.sample.inc.php /var/lib/phpMyAdmin/config.inc.php
vi /var/lib/phpMyAdmin/config.inc.php

"config.inc.php"のCOOKIE AUTHに適当なキーを入力する
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use setup/
 *
 * All directives are explained in Documentation.html and on phpMyAdmin
 * wiki .
 *
 * @version $Id$
 * @package phpMyAdmin
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'kb7imefu24d386kj3'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

/* rajk - for blobstreaming */
$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';

/* User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>


ディレクトリのパーミッションを変更する。
cd /var/lib/phpMyAdmin/
chown -R root.apache /var/lib/phpMyAdmin


vi /etc/httpd/conf.d/virtualhost.conf

"virtualhost.conf"に以下を追記する。

    ServerName phpmyadmin.example.jp
    DocumentRoot /var/lib/phpMyAdmin



vi /etc/sysconfig/httpd
#httpdの"HTTPD=/usr/sbin/httpd.worker"をコメントアウトする

mysql -uroot -p < /var/lib/phpMyAdmin/scripts/create_tables.sql
/etc/init.d/httpd restart

redmineレプリケーション方法

mysqlのDBダンプ
#移行元のサーバーでダンプファイルを作成する。
/usr/bin/mysqldump -u user_redmine -ppaswaado redmine | gzip >  /root/redmine_AWS_`date +%Y%m%d%H%M`.gz
#ダンプファイルの解凍
#移行先のサーバーに移したダンプファイルを解凍する。
gzip -d /home/tarou/redmine_AWS_201101010919.gz

#空のDB"db_redmine"をあらかじめ用意する。
mysql -uroot -p
mysql> create database db_redmine default character set utf8;
#DBを復元する。
mysql -p -u user_redmine db_redmine < /home/tarou/redmine_AWS_201101010919

#バージョンが違う場合は、以下でデータベース構造を変更する。
cd /var/lib/redmine/
rake db:migrate RAILS_ENV="production" 
rake db:migrate:upgrade_plugin_migrations RAILS_ENV=production
rake db:migrate_plugins RAILS_ENV=production

#redmine1.0.4のチケットで"{{author}} が{{age}}前に追加"などと出る場合は、以下を実行する。
gem install i18n -v=0.4.2
gem uninstall i18n -v=0.5.0
/etc/init.d/httpd restart
#保存ファイルの移動
cp /home/tarou/files/* /var/lib/redmine/files/
cd /var/lib/redmine/files/
chown apache.apache /var/lib/redmine/files/*

linux-パフォーマンス調査

vmstat
#1秒間隔で10回表示する。
vmstat 1 10
#表示結果
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 実 ス  ス     空      バ     キ    ス   ス                                    
 行 リ  ワ     メ      ッ     ャ    ワ   ワ                                   
 待 ー  ッ     モ      フ     ッ    ッ   ッ                                    
 プ プ  プ     リ      ァ     シ    プ   プ                                    
 ロ プ  メ             メ     ュ    戻   メ                                    
 セ ロ  モ             モ     メ    り   モ                                    
 ス セ  リ             リ     モ    メ   リ                                    
    ス                        リ    モ                                       
                                    リ                                       
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0     84  92884  24224 132876    0    0     1     4   30    7  0  0 100  0  0

2011年1月1日土曜日

さくらのVPSでredmine-CentOS基本設定

さくらのVPSのデフォルトOSはCentOSです、
無難なOSで使い慣れているOSなので、そのまま使用するのですが、最低限のセキュリティの設定を行う。

前回で使用準備完了して、コンソールコマンドが打てる状況です。

  • デフォルトだとSSHでroot(管理者権限)ログイン出来るが、悪い人がパスワード総当たり攻撃する時に、まず狙うユーザー名がrootなので、rootでログイン出来ない様にします。

#SSHでログインするユーザー"henohenomoheji"を作る。
useradd -m henohenomoheji
#作ったユーザーのバスワードを設定する。
passwd henohenomoheji


#設定ファイルのバックアップフォルダ作成
mkdir /etc/ssh/00Backup
#変更前の設定ファイルをコピー
cp /etc/ssh/sshd_config /etc/ssh/00Backup/sshd_config_`date +%Y%m%d%H%M`

#"/etc/ssh/sshd_config"ファイルを編集viの使い方はこちら
vi /etc/ssh/sshd_config
#"sshd_config"ファイルで"#PermitRootLogin yes"を探し、その下にでも"PermitRootLogin no"を挿入する。



#sshデーモンを再起動
/etc/init.d/sshd restart


#以上で次のログインからは、rootでログイン出来ないはずなので、実際にログインを試みて確認する。
  • ボットからの攻撃をさける為に、SSHのポート番号を変える。※今回の例では5022に変更する。
#変更前の設定ファイルをコピー
cp /etc/ssh/sshd_config /etc/ssh/00Backup/sshd_config_`date +%Y%m%d%H%M`
#"/etc/ssh/sshd_config"ファイルを編集
vi /etc/ssh/sshd_config
#"sshd_config"ファイルで"#Port 22"を探し、その下にでも"Port 5022"を挿入する。


#sshデーモンを再起動
/etc/init.d/sshd restart


#以上で設定完了※ポート番号が変わるので新しいポート番号で接続する。

  • 必要なポート以外を閉じる
#iptablesの設定スクリプトを作る。
vi ~/iptables-init.sh
#以下の内容で"~/iptables-init.sh"を保存する。

#!/bin/sh

iptables -F
iptables -X

iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A INPUT -s 10.0.0.0/8 -j DROP
iptables -A INPUT -s 172.16.0.0/12 -j DROP
iptables -A INPUT -s 192.168.0.0/16 -j DROP

# iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#スクリプト実行
sh /root/iptables-init.sh
#設定結果表示
iptables -L
#結果が以下の内容なら成功

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
DROP       all  --  10.0.0.0/8           anywhere
DROP       all  --  172.16.0.0/12        anywhere
DROP       all  --  192.168.0.0/16       anywhere
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

#設定結果を保存
iptables-save > /etc/sysconfig/iptables
#iptablesを再起動
/etc/rc.d/init.d/iptables restart
#iptablesの起動設定を確認
chkconfig --list |grep iptables
#結果が以下の様に2/3/4/5がonならOK
#iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
#違っていたら以下を実行
# chkconfig --level 2345 iptables on

lessで日本語表示


  • デフォルトだとおそらく日本語表示出来ないので以下の設定をする。
    • "export LESSCHARSET=utf-8"を実行してからlessを実行するとログイン中は日本語表示ができる。
    • 上記設定は一時的な設定なので、恒久的に設定するには以下を実行して"~/.bash_profile"ファイルに"export LESSCHARSET=utf-8"を追記する。
      • echo "export LESSCHARSET=utf-8" >> ~/.bash_profile
  • viで日本語表示



  • デフォルトだとおそらく日本語表示出来ないので以下の設定をする。

    • viのコマンドモードで":set encoding=utf-8"を実行する。
    • 上記設定は一時的な設定なので、恒久的に設定するには以下を実行して"~/.vimrc"ファイルに"set encoding=utf-8"を記述する。
      • echo "set encoding=utf-8" >> ~/.vimrc

    viの操作の仕方

    viはCUI(※GUIもあるらしい)で使用できるテキストエディターで、主にunix系linux系のコンソールで、ファイルを編集する時に使用します。

    古くからあるテキストエディターで、慣れるまでは非常に使いにくいのですが、unix系linux系のOSで、殆どの場合インストール済みで使えるので、最低限の操作方法は覚えておいた方が良い。

    #とりあえず自分のホームディレクトリに移動する。
    cd ~
    #viを実行する。以下は例で"~/test.txt"ファイルを編集
    vi test.txt
    • 最初はコマンドモードになっていて、"iIaAoO"のいずれかのキーを打つと入力モードに変わる。それぞれのキーに違いがあるが、以下を覚えれば良い。
      • "i"はカーソルにある文字の左側に挿入出来る状態で入力モードになる。
      • "a"はカーソルにある文字の右側に挿入出来る状態で入力モードになる。
      • "I"はカーソルにある行の先頭に挿入出来る状態で入力モードになる。
      • "A"はカーソルにある行の末尾に挿入出来る状態で入力モードになる。
    •  入力モードになると、画面左下に"-- INSERT --"が表示されキーを打てばそのまま文字列を挿入できる。
    • 入力モードからコマンドモードに移るには[ESC]キーを打つ、コマンドモードになると画面右下の"-- INSERT --"が消える。
    • コマンドモードでは、キーを打つことで様々な機能が使用できる。主な機能は以下のとおり
      • カーソル移動
        • [Ctrl]+"g"カーソル位置の情報等を画面下に表示する。
        • [Ctrl]+"f"1ページ画面を下に移動する。
        • [Ctrl]+"b"1ページ画面を上に移動する。
        • ※例"13G"13行へ移動する。
        • "G"最終行へ移動する。
      • 編集
        • "x"カーソル位置の文字列を削除
        • "dd"カーソルのある行を削除
        • "u"変更を元に戻す
        • "yy"カーソルのある行をコピーする。
        • "P"コピーした内容をカーソル行の上に挿入する。 
      • 検索
        • ※例"/mojiretsu" 文字列"mojiretsu"をカーソル位置から順方向に検索する。
        • "n"検索した内容を順方向に検索する。
        •  "N"検索した内容を逆方向に検索する。
      • 終了
        • ":w"上書き保存する。
        • ":w test.txt"名前を付けて保存する。
        • ":q"変更を保存せずに終了する。
        • ":q!"変更を保存せずに強制的に終了する。
        • ":q!"変更を保存せずに強制的に終了する。
        • ":wq"上書き保存して終了する。

    •  使っていると、現在のモードか判らなくなる事も多いので、その時は[ESC]キーを打っておけば良い。
    • とりあえず上記コマンドが使えれば十分、その他のコマンドは、リファレンスを参照してください。
    • viはクセのあるエディタですが、慣れてくると意外と使いやすいです。