memo.xight.org

Linux

2010-01-05 Tue

tmux - terminal multiplexer

- Summary
GNU screen はもう古いらしいので、tmuxに乗り換え。

クリックして拡大クリックして拡大クリックして拡大

- 操作 ( それ、Gentooだとどうなる? - 2009-07-09 より)

操作 screen tmux
ウィンドウを作成 C-a c または C-a C-c C-b c
ウィンドウ名を変更 C-a A C-b ,
ウィンドウ一覧表示 / 移動 C-b " C-b w
次のウィンドウへ移動 C-a n または C-a C-n C-b n
前のウィンドウへ移動 C-a p または C-a C-p C-b p
最後に操作したウィンドウへ移動 C-a C-a C-b l
ウィンドウを強制終了 C-a k C-b &
ペイン分割 C-a S C-b "
ペイン分割解除 C-a Q C-b !
ペインを強制終了 C-a k C-b x
ペイン間移動 C-a Tab C-b o または C-b Up または C-b Down
ペインを狭める / 広げる C-a - または C-a + C-b C-Up または C-b M-Up または C-b C-Down または C-b M-Down
ペイン配置パターンの変更 なし C-b Space または C-b {1,2,9}
中断 C-a d または C-a C-d C-b d
再開 screen -x tmux attach
ウィンドウ配置の変更 なし C-b Space
コピーモードでのコピー始点選択 Space または Enter C-Space (viモードならSpace)
コピーモードでのコピー終点選択 Space または Enter M-w (viモードならEnter)
現時刻表示 C-a t または C-a C-t C-b t

- Reference
tmux
http://tmux.sourceforge.net/

それ、Gentooだとどうなる? - 2009-07-09 - 時代はGNU screenからtmuxへ
http://d.hatena.ne.jp/tmatsuu/20090709/1247150771

それ、Gentooだとどうなる? - 2009-07-10 - tmuxをGNU screen風キーバインドに変更する
http://d.hatena.ne.jp/tmatsuu/20090710/1247179550

2008-03-18 Tue

monit - プロセスの監視を行うデーモン

- Summary
monitはプロセスの監視を行うデーモン.
条件とそれに伴うアクションを指定することができる.

- 条件例
プロセスが起動していなかったら
特定のプロセスのメモリの使用量が あるサイズを超えたら
特定のプロセスのCPUの使用率が 50%を超えている状態が 10分続いたら
特定のポートに接続できなくなったら

- アクション例
起動,再起動する
アラートメールを送信する
ユーザスクリプトを実行する

- インストール

# aptitude install monit

Starting daemon monitor: monit won't be started/stopped
        unless it it's configured
        please configure monit and then edit /etc/default/monit
        and set the "startup" variable to 1 in order to allow
        monit to start


- /etc/defalut/monit でstartできるように設定

#startup=0
startup=1



- /etc/monit/monitrc でインクルードファイルを指定

include /etc/monit/monit.d/*.conf



- /etc/monit/monit.d/atd.conf
check process postfix with pidfile /var/run/atd.pid
start program = "/etc/init.d/atd start"
stop program = "/etc/init.d/atd stop"

- Reference
monit
http://www.tildeslash.com/monit/

- via
ウノウラボ Unoh Labs: プロセスの監視を行う デーモン monit
http://labs.unoh.net/2008/03/_monit.html

2008-01-23 Wed

壊れたHDDからデータを取出す方法

- 準備
umount して作業する.
起動しない,または umount できなければ,別PCに接続して作業する.

- ddコマンドの実行
/dev/hdb3 を hdb3.imgにイメージファイルとして保存する.

# dd if=/dev/hdb3 of=hdb3.img bs=512 conv=noerror,sync


- イメージファイルにfsck

$ fsck hdb3.img


- エラー修復後のイメージファイルをマウントする

# mount -o


- Reference
ぴょぴょぴょ? - 壊れたHDDからデータを取出す方法
http://d.hatena.ne.jp/pyopyopyo/20061118/p1

2008-01-23 Wed

Linuxでネットワークスループットを改善する

- /etc/sysctl.conf

net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216



- sysctlのすべての項目と値を表示

# sysctl -a


- sysctlの項目を指定して表示

# sysctl -q net.ipv4.tcp_window_scaling


- rebootしないで有効化

# sysctl -p /etc/sysctl.conf


- 項目を指定して有効化 (rebootで元に戻る)

# sysctl -w net.ipv4.tcp_window_scaling=1


- Reference
builder by ZDNet Japan - Linuxのネットワークスループット改善法教えます
http://builder.japan.zdnet.com/news/story/0,3800079086,20365515,00.htm

2007-11-06 Tue

vsftpd で接続ユーザ制限

- /etc/vsftpd/vsftpd.conf

# /etc/vsftpd.user_listを使用しない
# /etc/vsftpd.ftpusersで指定したユーザを拒否する
userlist_enable=NO

# /etc/vsftpd.user_listで指定したユーザのみログインを許可する
# /etc/vsftpd.ftpusers で指定したユーザは,認証でエラーとなる
userlist_enable=YES
userlist_deny=NO

# /etc/vsftpd.user_listで指定したユーザのみログインを拒否する.
# /etc/vsftpd.user_listで指定されていないユーザはログインを許可する.
# /etc/vsftpd.ftpusers で指定した場合,パスワードの入力は求められるが,接続は拒否する
userlist_enable=YES
userlist_deny=YES



- Reference
vsftpd(RedHat9)
http://www.aritia.org/hizumi/dsl/page_23.htm

2006-09-08 Fri

FreeNX - リモートデスクトップ

- apt-line
/etc/apt/sources.list

deb http://kanotix.com/files/debian unstable main



- Install

# apt-get install freenx


- Setup

# nxsetup --install


- Reference
FreeNX - the free NX
http://freenx.berlios.de/

NoMachine NX - Download the NX Terminal Server and Remote Access Software
http://www.nomachine.com/download.php

FreeNX - PukiWiki
http://tidus.ultimania.org/wiki/index.php?FreeNX

@IT - FreeNXでLinuxをリモート操作するには
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/926usefreenx.html

Ubuntu Japanese Team - 2005-07-29 - NoMachine NX ClientとFreeNXを利用したシンクライアントシステム
http://www.ubuntulinux.jp/News/News20050729/

- via
GIGAZINE - 2006-09-08 - VNCよりも高速で遠隔操作できる「FreeNX」
http://gigazine.net/index.php?/news/comments/20060908_freenx/

2006-06-23 Fri

lm-sensors でハードウェアモニタリング

- Summary
lm-sensors でCPU,M/B,電圧,FANの回転数などの情報が取得可能.

- Install

# aptitude install lm-sensors


- Setting

# /usr/sbin/sensors-detect

This program will help you determine which I2C/SMBus modules you need to
load to use lm_sensors most effectively. You need to have i2c and
lm_sensors installed before running this program.
Also, you need to be `root', or at least have access to the /dev/i2c-*
files, for most things.
If you have patched your kernel and have some drivers built in, you can
safely answer NO if asked to load some modules. In this case, things may
seem a bit confusing, but they will still work.

It is generally safe and recommended to accept the default answers to all
questions, unless you know what you're doing.

 We can start with probing for (PCI) I2C or SMBus adapters.
 You do not need any special privileges for this.
 Do you want to probe now? (YES/no): yes


長々とメッセージが出ただけだった.

Probing for PCI bus adapters...
Use driver `i2c-viapro' for device 00:11.0: VIA Technologies VT8237 South Bridge
Probe succesfully concluded.

As you are not root, we can't load adapter modules. We will only scan
already loaded adapters.
If you have undetectable or unsupported adapters, you can have them
scanned by manually loading the modules before running this script.

 To continue, we need module `i2c-dev' to be loaded.
 If it is built-in into your kernel, you can safely skip this.
 i2c-dev is not loaded. As you are not root, we will just hope you edited
 `/etc/modules.conf' for automatic loading of
 this module. If not, you won't be able to open any /dev/i2c-* file.

 We are now going to do the adapter probings. Some adapters may hang halfway
 through; we can't really help that. Also, some chips will be double detected;
 we choose the one with the highest confidence value in that case.
 If you found that the adapter hung after probing a certain address, you can
 specify that address to remain unprobed. That often
 includes address 0x69 (clock chip).

Some chips are also accessible through the ISA bus. ISA probes are
typically a bit more dangerous, as we have to write to I/O ports to do
this. This is usually safe though.

As you are not root, we shall skip this step.

Some Super I/O chips may also contain sensors. Super I/O probes are
typically a bit more dangerous, as we have to write to I/O ports to do
this. This is usually safe though.

As you are not root, we shall skip this step.

 Sorry, no chips were detected.
 Either your sensors are not supported, or they are
 connected to an I2C bus adapter that we do not support.
 See doc/FAQ, doc/lm_sensors-FAQ.html, or
 http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/lm_sensors-FAQ.html
 (FAQ #4.24.3) for further information.
 If you find out what chips are on your board, see
 http://secure.netroedge.com/~lm78/newdrivers.html for driver status.


- 実行してみる

$ sensors
Can't access procfs/sysfs file
Unable to find i2c bus information;
For 2.6 kernels, make sure you have mounted sysfs and done
'modprobe i2c_sensor'!
For older kernels, make sure you have done 'modprobe i2c-proc'!

- 再チャレンジ

# modprobe i2c-viapro
# sensors
No sensors found!


... センサーが見つかりませんでした.

- Reference
ずんWiki - lm-sensorsでハードウェアモニタリング
http://www.kawaz.jp/pukiwiki/?lm-sensors%A4%C7%A5%CF%A1%BC%A5%C9%A5%A6%A5%A7%A5%A2%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0

2006-06-23 Fri

Temperature above threshold

- Summary
突然,ターミナルに以下のメッセージが表示された.

Message from syslogd@hostname at Fri Jun 23 21:54:41 2006 ...
hostname kernel: CPU0: Temperature above threshold

Message from syslogd@hostname at Fri Jun 23 21:54:41 2006 ...
hostname kernel: CPU0: Running in modulated clock mode

Message from syslogd@hostname at Fri Jun 23 21:54:47 2006 ...
hostname kernel: CPU0: Temperature above threshold

Message from syslogd@hostname at Fri Jun 23 21:54:47 2006 ...
hostname kernel: CPU0: Running in modulated clock mode


原因はCPU温度が高すぎたため.
CPU温度は64度だった.

- Reference
Fedora JP 掲示板 - GNOMEターミナルおかしいです...
http://bbs.fedora.jp/read.php?FID=3&TID=1241