アットウィキロゴ

 Linux関連メモ


■awkコマンドについて

▼ファイルのサイズとファイル名をサイズの少ない順で表示する。
$ ls -Slhr| awk '{print $6,$10}'

▼ファイルのサイズとファイル名をサイズの少ない順で表示する。(コロンを追加する)
$ ls -Slhr| awk '{print($6," ",":",$10)}'

※綺麗に「:」をそろえることができないか。
Linuxユーザパスワードが変更できない理由

□system-authの設定
以下の設定がデフォルトで3回になっていた。
3回以上は失敗したと考えられる。見直す必要があるかも。
retry=N     N回まで失敗が許されます。
retry=3
passwdコマンドをいったん終了して再実行すれば問題なかったと思う。

□opasswdの削除
以下の2つのファイルをいらないと判断して消しました。
→/etc/pam.d/common-passwordは、RedHat系のLinuxには存在しないため。
→/etc/security/opasswd


確か、デフォルトでは作成されていなかったので手動で作成した。
ただパスワード履歴のDBとして必要と考えられる。DebianLinuxだけと思っていた。

以下のサイトに作成しないとだめとある
http://www.ilovex.co.jp/Division/ITD/archives/2006/05/linux_windows.html

http://memorandom-ayum.blogspot.jp/2008/04/blog-post.html

抜粋----------------------------------------------------------------------
touch /etc/security/opasswd
chomod 600 /etc/security/opasswd
てな感じで 事前にファイルを作っておかねばなりません。
opasswd ファイルを作っていないと、ユーザーがパスワード変更時にコケます。
---------------------------------------------------------------------------

※過去のパスワード履歴を初期化したい場合は、
/etc/security/opasswd に /dev/null を書き込んで空にすれば良い。

 # cat /dev/null > /etc/security/opasswd

□passwdとshadowの整合性がある
passwdとshadowの整合性が取れていないためログインできなかった。

まずは、pwckコマンドで整合性がただしいかを確認する
整合性がおかしければそのあとにpwconvを実行する


□20120307kernel_bug_fixメモ

kernel bug fix
RHBA-2012:0361-1
2012-03-07

kernel-2.6.18-308.1.1.el5.i686.rpm     MD5: 571511b1829455250480417b57a5c059
SHA-256: b8367f33e671645cab54c657166df6d8c94effa056ef491aa3e602f4542cd5a7
kernel-PAE-2.6.18-308.1.1.el5.i686.rpm     MD5: 7fc7776e4f0c923e4123bf9d3f7ca179
SHA-256: ac92e519cf462f4e6efc57e223b3c11b33294908f53a978ad5dc89f86f0c8025
kernel-PAE-devel-2.6.18-308.1.1.el5.i686.rpm     MD5: 4302812eac9b64b37d7885b325e7d23d
SHA-256: 9b25d9c8f437c304bddccb700c201a180f4f3f5dedfe3ecc0b75c40ecd0702e1
kernel-debug-2.6.18-308.1.1.el5.i686.rpm     MD5: 745faa2fca6f192f2a51db5576a84d27
SHA-256: 697d0f9b408fbfb0cb3b82983b40d99c0cd79eb9c9f10c35f509917b7ccc3b3c
kernel-debug-devel-2.6.18-308.1.1.el5.i686.rpm     MD5: 16e3d466ad92dee5bc48ead1dc4d4001
SHA-256: ef9a3e03b9ed7bbab85e5a40d7e19b45bd2b9cd0a4244f9fce6762fed2ba109f
kernel-devel-2.6.18-308.1.1.el5.i686.rpm     MD5: 81f3c6c4ed5673a37f0661c629633f6a
SHA-256: ed47013197200b5d5d42253f6cc1c2f4f1831d2344a2bc33bf8ec16ab41bd4fa
kernel-doc-2.6.18-308.1.1.el5.noarch.rpm     MD5: c42a076660ae8dcb7a16d03e66f415ff
SHA-256: 00b7d28dabc6c49e02c89f0b720e48208abefeeb4536e0507f2d626e45394138
kernel-headers-2.6.18-308.1.1.el5.i386.rpm     MD5: e60dd963bd7418661f6dab14a0332554
SHA-256: 9a16083c13cb1fd0cd4fc2fdf4e0a0e4b13b45a549ddb7d2fd4dde8f382162c9
kernel-xen-2.6.18-308.1.1.el5.i686.rpm     MD5: ed332c2503d1c3f044e1b8aa408df9f3
SHA-256: f337aeaea15a2d8b9263634f9772a90a5ea129ecf61a03b55994fc90b16447e0
kernel-xen-devel-2.6.18-308.1.1.el5.i686.rpm     MD5: cd035a306565ad0f2c1405c84e3a7b35
SHA-256: eb7f45e0290fe4f70532dce0e1d13298789b54fa9483910b892c6a65f1b0897c

 


Updated kernel packages that fix multiple bugs are now available for Red Hat
Enterprise Linux 5.


The kernel packages contain the Linux kernel, the core of any Linux operating
system.

Bug fixes:

* The root user without the CAP_SYS_ADMIN capability was able to reset the
contents of the "/proc/sys/kernel/dmesg_restrict" configuration file to 0.
Consequently, the unprivileged root user could bypass the protection of the
"dmesg_restrict" file and read the kernel ring buffer. This update ensures that
only the root user with the CAP_SYS_ADMIN capability is allowed to write to the
dmesg_restrict file. Any unauthorized attempt on writing to this file now fails
with an EPERM error. (BZ#749246)

* An Ethernet physical transceiver (a PHY chip) was always powered up when a
network interface card (NIC) using the igb driver was brought down. Recent
changes had modified the kernel so that the PHY chip was powered down in such a
scenario. With this PHY power saving feature, the PHY chip could unexpectedly
lose its settings on rare occasions. Consequently, the PHY chip did not recover
after the NIC had been re-attached and the NIC could not be brought up. The igb
driver has been modified so that the PHY chip is now reset when the NIC is
re-attached to the network. NICs using the igb driver are brought up as
expected. (BZ#786168)

* The way how the kernel processes dentries in the dcache when unmounting file
systems allowed the concurrent activity on the list of dentries. If the list was
large enough, the kernel could, under certain circumstances, panic due to NMI
watchdog timeout triggered by the waiting concurrent process. This update
modifies underlying functions to use a private dcache list for certain
operations on the dcache so that concurrent activities are no longer affected in
this scenario. (BZ#789369)

* The Abstract Control Model (ACM) driver uses spinlocks to protect the lists of
USB Request Blocks (URBs) and read buffers maintained by the driver. Previously,
when a USB device used the ACM interface, a race condition between scheduled ACM
tasklets could occur. Consequently, the system could enter a deadlock situation
because tasklets could take spinlocks without disabling interrupt requests
(IRQs). This situation resulted in various types of soft lockups ending up with
a kernel panic. This update fixes the problem so that IRQs are disabled when a
spinlock is taken. Deadlocks no longer occur and the kernel no longer crashes in
this scenario. (BZ#790778)

* A recent change in the QLogic qla2xxx driver introduced a bug which could,
under rare circumstances, cause the system to become unresponsive. This problem
occurred during I/O error recovery on systems using SAN configurations with
QLogic Fibre Channel Hot Bus Adapters (HBAs). This update corrects the qla2xxx
driver so the system no longer hangs in this scenario. (BZ#790907)

* Due to recent changes in the tg3 driver, the driver attempted to use an
already freed pointer to a socket buffer (SKB) when the NIC was recovering from
unsuccessful memory mapping. Consequently, the NIC went offline and the kernel
panicked. With this update, the SKB pointer is newly allocated in this scenario.
The NIC recovers as expected and a kernel panic does not occur. Also, the tg3
driver could, under certain circumstances, attempt to unmap a memory fragment
that had not been mapped. Consequently, the kernel panicked. This update fixes
the bug by correcting the "last" parameter supplied. (BZ#790910)

* When a network interface card (NIC) with a fan experiences a fan failure, the
PHY chip is usually powered down by its firmware. Previously, the bnx2x driver
did not handle fan failures correctly, which could trigger a non-maskable
interrupt (NMI). Consequently, the kernel could crash or panic. This update
modifies the bnx2x driver to handle fan failures properly, the NIC is now shut
down as expected and the kernel does not crash in this scenario. (BZ#790912)

All users are advised to upgrade to these updated packages, which fix these
bugs. The system must be rebooted for this update to take effect.


Updated kernel packages that fix multiple bugs are now available for Red Hat
Enterprise Linux 5.


The kernel packages contain the Linux kernel, the core of any Linux operating
system.

Bug fixes:

* The root user without the CAP_SYS_ADMIN capability was able to reset the
contents of the "/proc/sys/kernel/dmesg_restrict" configuration file to 0.
Consequently, the unprivileged root user could bypass the protection of the
"dmesg_restrict" file and read the kernel ring buffer. This update ensures that
only the root user with the CAP_SYS_ADMIN capability is allowed to write to the
dmesg_restrict file. Any unauthorized attempt on writing to this file now fails
with an EPERM error. (BZ#749246)

* An Ethernet physical transceiver (a PHY chip) was always powered up when a
network interface card (NIC) using the igb driver was brought down. Recent
changes had modified the kernel so that the PHY chip was powered down in such a
scenario. With this PHY power saving feature, the PHY chip could unexpectedly
lose its settings on rare occasions. Consequently, the PHY chip did not recover
after the NIC had been re-attached and the NIC could not be brought up. The igb
driver has been modified so that the PHY chip is now reset when the NIC is
re-attached to the network. NICs using the igb driver are brought up as
expected. (BZ#786168)

* The way how the kernel processes dentries in the dcache when unmounting file
systems allowed the concurrent activity on the list of dentries. If the list was
large enough, the kernel could, under certain circumstances, panic due to NMI
watchdog timeout triggered by the waiting concurrent process. This update
modifies underlying functions to use a private dcache list for certain
operations on the dcache so that concurrent activities are no longer affected in
this scenario. (BZ#789369)

* The Abstract Control Model (ACM) driver uses spinlocks to protect the lists of
USB Request Blocks (URBs) and read buffers maintained by the driver. Previously,
when a USB device used the ACM interface, a race condition between scheduled ACM
tasklets could occur. Consequently, the system could enter a deadlock situation
because tasklets could take spinlocks without disabling interrupt requests
(IRQs). This situation resulted in various types of soft lockups ending up with
a kernel panic. This update fixes the problem so that IRQs are disabled when a
spinlock is taken. Deadlocks no longer occur and the kernel no longer crashes in
this scenario. (BZ#790778)

* A recent change in the QLogic qla2xxx driver introduced a bug which could,
under rare circumstances, cause the system to become unresponsive. This problem
occurred during I/O error recovery on systems using SAN configurations with
QLogic Fibre Channel Hot Bus Adapters (HBAs). This update corrects the qla2xxx
driver so the system no longer hangs in this scenario. (BZ#790907)

* Due to recent changes in the tg3 driver, the driver attempted to use an
already freed pointer to a socket buffer (SKB) when the NIC was recovering from
unsuccessful memory mapping. Consequently, the NIC went offline and the kernel
panicked. With this update, the SKB pointer is newly allocated in this scenario.
The NIC recovers as expected and a kernel panic does not occur. Also, the tg3
driver could, under certain circumstances, attempt to unmap a memory fragment
that had not been mapped. Consequently, the kernel panicked. This update fixes
the bug by correcting the "last" parameter supplied. (BZ#790910)

* When a network interface card (NIC) with a fan experiences a fan failure, the
PHY chip is usually powered down by its firmware. Previously, the bnx2x driver
did not handle fan failures correctly, which could trigger a non-maskable
interrupt (NMI). Consequently, the kernel could crash or panic. This update
modifies the bnx2x driver to handle fan failures properly, the NIC is now shut
down as expected and the kernel does not crash in this scenario. (BZ#790912)

All users are advised to upgrade to these updated packages, which fix these
bugs. The system must be rebooted for this update to take effect.

 

複数のバグを修正したカーネルのアップデートパッケージがRed Hatのために利用可能になりました
Enterprise Linux 5に。


カーネルパッケージは、Linuxカーネルは、あらゆるLinuxオペレーティングシステムのコアが含まれてい
システム。

バグ修正:

* CAP_SYS_ADMIN機能を持たないrootユーザーはリセットすることができました
の内容 "を/ proc / sys /カーネル/ dmesg_restrict 0"に設定ファイルを指定します。
その結果、特権のないrootユーザーが保護をバイパスすることができ
ファイルを "dmesg_restrict"とカーネルのリングバッファを読んでください。この更新プログラムは、確実に
CAP_SYS_ADMIN機能を持つrootユーザーだけがへの書き込みを許可されている
ファイルをdmesg_restrict。このファイルへの書き込み上の任意の不正な試みが今失敗した
EPERMエラーが発生した。 (BZ#749246)

時*イーサネット物理トランシーバ(PHYチップ)は、常に電源が投入されました
igbドライバを使用して、ネットワークインターフェイスカード(NIC)が倒された。最近の
変更は、PHYチップなどでパワーダウンされたようにカーネルを修正した
シナリオ。このPHY省電力機能を使用すると、PHYチップは、予期しない可能性
まれにその設定が失われます。その結果、PHYチップは回復しなかった
NICが再接続されていたとNICが育つことができませんでした後。 IGB
ドライバは、NICがある場合のPHYチップがリセットされるようになりましたように変更されました
ネットワークに再接続されている。 igbドライバを使用してNICを次のように育ってい
期待される。 (BZ#786168)

ファイルをアンマウント時にカーネルがdcacheのでdentryを処理する方法*方法
システムは、ディレクトリ?エントリのリストの同時活動を可能にした。リストがあった場合
十分な大きさで、カーネルは、特定の状況下で、NMIによるパニックが
ウォッチドッグのタイムアウトが待っている並行プロセスによって引き起こされる。この更新
特定のプライベートdcacheのリストを使用する基本的な機能を変更する
同時活動が影響を受けれなくなったように、dcacheの上の操作
このシナリオでは。 (BZ#789369)

*概要制御モデル(ACM)ドライバのリストを保護するためにスピンロックを使用しています
USBリクエストブロック(URBs)とドライバによって維持されるバッファを読み取ります。以前は、
USBデバイスは、ACMインターフェース、スケジュールされたACMの間に競合状態を使用したとき
タスクレットが発生する可能性があります。したがって、システムはデッドロックの状況を入力することができます
タスクレットは、割り込み要求を無効にせずにスピンロックを取ることができるので、
(IRQ)を。このような状況はで終わるソフトロックアップの様々な種類の結果
カーネルパニック。このアップデートは、IRQが無効になっているように問題を修正
スピンロックが取得されます。デッドロックが発生しなくなりましたとでカーネルがクラッシュしなく??なりました
このシナリオでは。 (BZ#790778)

のQLogic qla2xxxドライバで*最近の変更は、可能性のあるバグを導入しました
まれな状況下で、システムが応答しなくなる原因となります。この問題
とSAN構成を使用しているシステム上のI / Oエラーリカバリ中に発生した
QLogicファイバチャネルホットバスアダプタ(HBA)。このアップデートではqla2xxxのを修正
システム、ドライバは、もはやこのシナリオでは、ハングアップしません。 (BZ#790907)

tg3ドライバで最近の変化に*があるため、ドライバが使用しようとしました
NICから回復したときに既にソケットバッファ(SKB)へのポインタを解放した
失敗したメモリマッピング。したがって、NICがオフラインになったし、カーネル
パニックが発生しました。このアップデートにより、SKBのポインタは、新しくこのシナリオでは、割り当てられています。
NICは期待どおりに回復し、カーネルパニックが発生しません。また、TG3
ドライバは、特定の状況下で、メモリのフラグメントのマッピングを解除しようとする可能性があり
それがマッピングされていませんでした。その結果、カーネルはパニックが発生しました。この更新プログラムで修正される
付属の "最後"のパラメータを修正することにより、バグを修正しました。 (BZ#790910)

*ファンを持つネットワークインターフェイスカード(NIC)がファンの障害が発生した場合、
PHYチップは、通常、そのファームウェアによってパワーダウンします。以前に、bnx2xドライバ
ノンマスカブルを引き起こす可能性がこれ、正しくファンの障害を処理しませんでした
割り込み(NMI)。したがって、カーネルがクラッシュしたり、パニックになる可能性があります。この更新
適切にファンの障害を処理するためのbnx2xドライバを変更して、NICが現在シャットダウンされ
ダウンが期待どおり、カーネルはこのシナリオではクラッシュしません。 (BZ#790912)

すべてのユーザは、これらの問題を解決する上記アップデートパッケージにアップグレードしてください
バグ。システムを有効にするには、このアップデートを再起動する必要があります。

●PAMについて

【基本】
 
   /etc/pam.d/*        : アプリ用の定義ファイルが有るディレクトリ(サービス名のファイル)
   /etc/security/*     : 各PAMの設定ファイル(PAM名.conf)
   /lib/security/*     : ライブラリファイルの有る場所

【PAMの動作】
  ・第一フィールド(ライブラリモジュールのタイプ)
   auth : 認証
   account : 許可、アカウント管理
   password : クレデンシャルの更新
   session : ユーザ環境の変更

  ・第二フィールド(挙動の指定)
   required : 成功が必要、失敗時は他モジュールを呼び出すが結果は決まっている
   requisite : 失敗時は認証を即終了
   sufficient : 成功時は即アクセス許可(他モジュールはバイパス)
   optional : 結果を無視

  ・第三フィールド(モジュール)
   /lib/security/$ISA/pam_unix.so      : UNIX認証(古いパスワードは/etc/security/opasswdに保持、履歴管理)
   /lib/security/$ISA/pam_env.so       : 環境変数の初期設定
   /lib/security/$ISA/pam_securetty.so : 危険なターミナルからのrootログイン制限
   /lib/security/$ISA/pam_stack.so     : 他のPAMを呼び出す
   /lib/security/$ISA/pam_nologin.so   : /etc/nologin(中味は空でも)があればroot以外ログイン拒否
   /lib/security/$ISA/pam_deny.so      : 常に失敗
   /lib/security/$ISA/pam_console.so   : コンソールユーザへの特権
   /lib/security/$ISA/pam_access.so    : 場所ベースのアクセス管理
   /lib/security/$ISA/pam_listfile.so  : ファイルベースのアクセス管理
   /lib/security/$ISA/pam_cracklib.so  : パスワードの辞書チェック
   /lib/security/$ISA/pam_tally.so     : 失敗ログイン履歴を/var/log/faillogに保存。ロックも可能
   /lib/security/$ISA/pam_cracklib.so  : パスワード基準の指定                                                                                                 
【共通の設定】
  ・下記ファイルで共通設定
   /etc/pam.d/system-auth


【使用例】
  ・パスワードの制限
   1:/etc/pam.d/system-authのpam_crackilb.soとpam_unix.soを編集

     password   required   pam_cracklib.so     \     : 通常は1行で、"\"は改行しても続くよって意味
                           minlength=20        \     : パスワードの最低長
                           ocredit=5           \     : 特殊文字5つ以上いれろ
                           dcredit=5           \     : 数字
                           ucredit=5           \     : 大文字
                           lcredit=5                 : 小文字

     password   required   pam_unix.so         \    
                           nullok md5 authtok  \     : ノンパスOK、暗号化
                           remember=5                : 5つまでパスワードを憶える

 ■ルートユーザのログイン拒否(su時のみ可能)

   1:loginの制限(先頭行に追加)
   #vi /etc/pam.d/login
   auth   required   pam_listfile.so item=user sense=deny file=/etc/security/listfile onerr=succeed

   2:gdmの制限(グラフィカルログイン)
   #vi /etc/pam.d/gdm
   auth   required   pam_listfile.so item=user sense=deny file=/etc/security/listfile onerr=succeed

   3:制限ファイルの作成(拒否ユーザの列挙)
   #vi /etc/security/listfile
   root


 ■testグループユーザのサービスアクセスを1つの仮想コンソールに限定

   1:下記ファイルの最後に記述。testグループはtty1を除く全てを拒否
   #vi /etc/security/access.conf
 -:test:ALL EXCEPT tty1

   2:全てのサービスに適用(authではじまる行の次に追加)
   #vi /etc/pam.d/system-auth
 account required /lib/security/$ISA/pam_access.so

 ■コンソールユーザの端末停止、再起動を禁止する

   1:以下のファイルのpam_console.soをコメントアウトする
   /etc/pam.d/halt
   /etc/pam.d/reboot
   /etc/pam.d/poweroff
   #auth       required    pam_console.so

 
□colinux - CentOS イメージの作り方
 
2008.07.07 Monday | category:Other
↓のページを参考にさせて頂きやってみました。
http://d.hatena.ne.jp/masahi6/20071013/1192219358
 
まずは qemu-0.9.0-windows.zip と Kqemu-1.3.0pre11インストーラ が必要なので、
それをインストール。
http://www.h7.dion.ne.jp/~qemu-win/index-ja.html
 
イメージになる空ファイルを作成する。
fsutil file createnew C:\Program Files\cent5\qemu_cent5_5gb 5368709120
fsutil file createnew C:\Program Files:\cent5\qemu_swap_512mb 536903168
 
C:\Program Files>fsutil file createnew cent5\qemu_cent5_5gb 53687
ファイル C:\Program Files\cent5\qemu_cent5_5gb が作成されました
 
C:\Program Files>fsutil file createnew cent5\qemu_swap_512mb 536903168
 
qemu で CentOS をインストール。
とりあえず必要最低限のものだけでいいので CD-ROM の1枚目だけで。
なぜかよく分からんが自分の環境では \ を \ でエスケープしないとダメみたい。
 
以下からCentOS5.8をダウンロードする。
http://mirror.fairway.ne.jp/centos/5.8/isos/i386/
 
cd "c:\Program Files\qemu-0.13.0-windows
qemu.exe -hda "C:\\Program Files\\cent5\\qemu_cent5_5gb" -hdb "C:\\Program Files\\cent5\\qemu_swap_512mb" -cdrom "C:\\Program Files\\cent5\\CentOS-5.8-i386-bin-1of7.iso" -m 256 -boot d -L .
 
(qemu) eject  ide1-cd0   
(qemu) change ide1-cd0
 
 
CDイメージを交換する
(qemu)change ide1-cd0 c:\CentOS-4.3-i386-bin2of4.iso
 
 
※インストールに時間がかかりすぎるのでtextインストールを行ったほうがよい。
 
 
▼フロッピーとCD-ROMなどのデバイスの状態の確認
(qemu) info block
 
 
インストールは「boot: linux text」のテキストインストールでね。
HDDの構成には注意が必要みたい。/ に hda をまるごと。swap に hdb まるごと。
で、インストールが終わったら、qemu をいったん終了。
 
再度、qemu で起動してインストールを完了。
qemu.exe -hda "C:\\Program Files\\cent5\\qemu_cent5_5gb" -hdb "C:\\Program Files\\cent5\\qemu_swap_512mb" -m 256 -L .
 
で、こいつを colinux で利用できるように、cobdの作成。
cd /dev
for i in `seq 1 10`; do mknod cobd$i b 117 $i; done
 
そのあとlinux終了して、cygwin の dd で colinux 用のイメージを作成。
dd if=/cygdrive/d/cent5/qemu_cent5_5gb of=/cygdrive/d/cent5/root.ext3 bs=512 skip=63
dd if=/dev/zero of=/cygdrive/d/cent5/swapfile bs=1024 count=524288
 
ここまでで、イメージ作成は終わり。
で、↓が colinux の設定ファイル。 
--- colinux.conf ---
kernel=vmlinux
cobd0="C:\\Program Files\cent5\root.ext3"
cobd1="C:\\Program Files\cent5\swapfile"
root=/dev/cobd0
rw
initrd=initrd.gz
mem=512
eth0=tuntap,"colinux"
#ttys0=COM1,"BAUD=115200 PARITY=n DATA=8 STOP=1 dtr=on rts=on"
#exec0=C:\Programs\Xming\Xming.exe,":0 -clipboard -multiwindow -ac"
--------------------
 
あとは、colinux の起動方法やらなにやら。
cd C:\Program Files\coLinux
colinux 起動。
colinux-daemon @colinux.conf
colinux をサービス登録。
colinux-daemon @colinux.conf --install-service 
サービスの起動。
net start "Cooperative Linux"
サービスの停止。
net stop "Cooperative Linux"
 
# んーなんか、colinux で起動すると、
# WARNING!!! Running e2fsck on a mounted filesystem may cause
# SEVERE filesystem damage.
# といわれる。なんでだ?
 
 
□groupaddコマンド
 
groupadd [-g gid] group_name
 
 
□Linuxコマンド
 
▼圧縮コマンド
tar zcvf `date +%Y%m%d%H%M`_nvjob.tar.gz nvjob/
 
▼解凍コマンド
 
ファイルを解凍したいディレクトリに移動する
cd /ap/infra/nvjob
 
tarファイルがあるパスとファイルを指定して実行する
tar zxvf /usr/local/work/infra/nvjob.tar.gz
 
 
▼ディレクトリに含まれるデータの総容量を知りたい
 du -sch ./*
 
カレントディレクトリの各(ファイル、)ディレクトリ毎の総データ量取得。
 
 ./*
 
がなかったらカレントディレクトリの総合計だけになってしまう。
 
 
▼プロセス状態のツリーで確認できる
ps afx | less
 
 
▼よく使うrpmコマンド
rpm -qa --queryformat "%{name}-%{version}-%{release}.%{arch}\n" | sort > "`uname -n`_package.log"
 
 
 
■nkfコマンド
 
▼文字コードと改行コードを知る
$ nkf --guess test4.pl
Shift_JIS (CRLF)
 
▼現在の文字コードを確認
$ nkf -g test.pl
Shift_JIS
 
▼ディレクトリ内部のHTMLファイルをすべて文字コード変換する。
 
文字コード・改行を変換 →UTF-8/unix形式(LF)に変換
 
文字コードと改行をコードを合わせて変換できる。
 
$ nkf -w -Lu --overwrite *.html # *.htmlでまとめて変換
 
※よくある間違い
$ nkf -w readme.txt > readme.txt 
上書きできません。入力ファイルと出力ファイルが同じなので、うまくいきません。中身が空っぽになるので上記の方法を用いるか、出力ファイルには入力ファイルと違うものを指定するようにした方がよい。
 
※オプション関連
-j     JISコードを出力する。
-e     EUCコードを出力する。
-s     シフトJISコードを出力する。
-w -w8[0] -w16[BL][0]  Unicode を出力する。
-w -w80     UTF8コードを出力する。(BOM無し)
-w8    UTF8コードを出力する。
-w16 -w16B0  UTF16コードを出力する。(Big Endian / BOM無し)
-w16B  UTF16コードを出力する。(Big Endian / BOM有り)
-w16L  UTF16コードを出力す る。 (Little  Endian / BOM有り)
-w16L0 UTF16コードを出力する。(Little Endian / BOM無し)
 
※改行コード関連
 
-Lu : unix改行形式(LF)に変換 
-Lw : windows改行形式(CRLF)に変換 
-Lm : macintosh改行形式(CR)に変換
 
 
□NTPについて
 
指定したサーバだけ通信ができるか?
⇒指定したサーバのみ通信する。
 
□passwdコマンド
 
▼新規ユーザパスワード作成または、パスワードを変更する。
sudo passwd <ユーザ名>
 
▼rootのパスワードを変更する
u_rb_admにログインする
sudo passwd
 
または、suにログインする
passwd
 
 
▼rpmパッケージをまとめてアップデート
 
rpm -Fvh *.rpm [Enter]
 
と実行することで、
「アップデート可能なものだけをアップデートし、
カレントディレクトリに新規にインストール可能なパッケージが
混ざっていてもインストールしない。」
 
 
SELinux無効確認手順
 
▼現在動作しているモードの確認
$ getenforce
Enforcing
⇒Disabledでなかったら以下を行う。
 
▼SELinuxの完全無効化
 
vi /etc/sysconfig/selinux
SELINUX=enforcing
   ↓
SELINUX=disabled
 
※注意
「SELINUXTYPE」を間違えて変えない。間違えると再起動したとき
起動しなくなるため。
 
 
▼動作状態の確認
 
cat /etc/sysconfig/selinux | grep "SELINUX="
⇒disabledであること
 
$ getenforce
 
※selinuxの設定ミスして起動しなくなったときGrubの画面で"F3"⇒"e"を押して以下を実行する
 
kernel /boot/~ ro root=~ 
 
kernel /boot/~ ro root=~ enforcing=0
 
※上記だけでなくrootのバスワードを忘れたとき
 
kernel /boot/~ ro root=~ enforcing=0 single
passwdコマンドでrootのパスワードを変更する
 
 
□useraddコマンド
 
ユーザIDが101がかぶっていないことを確認する。
 
awk -F ":" '{print $3}' /etc/passwd | grep 101
 
useradd -u <UID> -g <グループ名/GID> <ユーザ名>
 
パスワードを指定する
※英数字、記号を組み合わせて指定する
passwd <ユーザ名>
 
ログインできることを確認する
 
telnet <ユーザ名>
 
 
□userdelコマンド
 
▼ユーザを削除する
userdel -r <ユーザ名>
 
ユーザ名が表示されないことを確認する
awk -F ":" '{print $1}' /etc/passwd | grep <ユーザ名>
 
ディレクトリが存在しないことを確認する
ls /home/ | grep <ユーザ名>
 
 
□usermodコマンド
 
既存のユーザーの情報を変更するには usermod コマンドを使用します。
ユーザー名を変更するには、以下のようにします。
usermod -l 新ユーザー名 旧ユーザー名
 
所属グループを変更するには、以下のようにします。
usermod -G 新グループ名 ユーザー名
 
ホームディレクトリを変更するには、以下のようにします。
usermod -d 新しいホームディレクトリ -m ユーザー名
 
( -m オプションをつけると、これまでのホームディレクトリの内容が新しいディレクトリへ移動される )
 
▼ユーザのシェルの変更
 
usermod -s <shellのパス> <ユーザ名>
 
※test02ユーザのシェルをcshに変更する場合
usermod -s /bin/csh test02
 
□パスワードポリシーの変更方法
 
☆パスワードポリシーの変更には、system-authの修正を行う
 
条件:RedHat系のOSであること
 
▼RedHat5.5のインストール直後のデフォルトのsystem-authは、以下
/etc/pam.d/system-auth
-----------------------------------------------------------------------------------------------
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so
 
account     required      pam_unix.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so
 
password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so
 
session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
-----------------------------------------------------------------------------------------------
 
▼修正後のsystem-auth
/etc/pam.d/system-auth
-----------------------------------------------------------------------------------------------
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        required      pam_deny.so
 
account     required      pam_unix.so
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     required      pam_permit.so
 
password    requisite     pam_cracklib.so try_first_pass retry=3 type= minlen=8 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1 difok=1
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok remember=2
password    required      pam_deny.so
 
session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
-----------------------------------------------------------------------------------------------
 
▼パラメータの意味
retry=N     N回まで失敗が許されます。
type=XXX    プロンプトに使われる文字列。
difok=N     現在のパスワードと N文字以上異なれば許可。
minlen=N    パスワードが N文字以上だと許可。
dcredit=-N  数字が N文字以上含まれていれば許可。
ucredit=-N  大文字が N文字以上含まれていれば許可。
lcredit=-N  小文字が N文字以上含まれていれば許可。
ocredit=-N  その他の文字が N文字以上含まれていれば許可。
 
▼試してわかったこと
system-authを修正後、OS再起動をかけないでもすぐに反映される。
 
▼使用されている文字コードを調べる
nkf -g file
 
最終更新:2012年08月13日 22:05