初期設定
一般ユーザ作成
[root@localhost ~]# useradd hiro
[root@localhost ~]# passwd hiro
Changing password for user hiro.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
selinuxの停止
SELinuxの有効、無効を切り替えるにはシステムの再起動が必要。
動作モード確認
getenforce
動作モード
| モード |
説明 |
番号 |
| Enforcing |
SELinux機能は有効でアクセス制御も有効 |
1 |
| permissive |
SElinuxはwarningを出すが、アクセス制限は行われない。ログのみ出力 |
0 |
| disabled |
SElinux機能・アクセス制御ともに無効 |
- |
動作モード変更
setenforce 0
※注意
[root@localhost ~]# cat /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
SELINUX変数がdisabledの場合、setenforceを実行するとメッセージが表示される
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
selinuxenabledコマンド
シェルスクリプトなどで条件判定に使いやすいよう、結果を数値で返してくれます。有効であれば0、無効であれば1を返します。
[root@localhost ~]# selinuxenabled
[root@localhost ~]# echo $?
1
その他
今回はselinux使用しないのでスルー。
[root@localhost ~]# ls -Z
-rw------- root root system_u:object_r:user_home_t:s0 anaconda-ks.cfg
/var/log/audit/audit.log
[root@localhost ~]# cd /etc/audit/
[root@localhost audit]# ls -l
-rw-r----- 1 root root 373 9月 4 2009 audit.rules
-rw-r----- 1 root root 680 4月 11 04:37 auditd.conf
トラブルシュート
/etc/selinux/configを書き間違えてブートに失敗する。
Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.
Kernel panic - not syncing : Attempted to kill init!
- ブート・ローダー(GNU GRUB)が起動時に「e」キーを押してから、selinux=0 を以下のように追加
root (hd0,1)
kernel /vmlinuz-2.6.5-1.358 ro root=LABEL=/1 rhgb quiet selinux=0
必要ポート開放
80と443を開放しておく。
[root@localhost ~]# vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
再起動
[root@localhost ~]# /etc/init.d/iptables restart
ファイアウォールルールを適用中: [ OK ]
チェインポリシーを ACCEPT に設定中filter [ OK ]
iptables モジュールを取り外し中 [ OK ]
iptables ファイアウォールルールを適用中: [ OK ]
iptables モジュールを読み込み中ip_conntrack_netbios_ns [ OK ]
ssh経由でrootでログインさせない
[root@localhost ~]# vi /etc/ssh/sshd_config
PermitRootLogin no
必要パッケージインストール
最も近い場所のyumパッケージを自動的に検索
[root@localhost ~]# yum install yum-fastestmirror -y
Linuxの状態を管理する
[root@localhost ~]# yum install sysstat -y
システムコールを表示させながら実行させることが出来る
[root@localhost ~]# yum install strace ltrace -y
リビジョン管理システム
[root@localhost ~]# yum install rcs -y
[root@localhost ~]# yum install gcc gcc-c++ -y
log
Aug 15 11:09:52 Installed: sysstat-7.0.2-3.el5_5.1.i386
Aug 15 11:10:32 Installed: ltrace-0.5-13.45svn.el5.i386
Aug 15 11:10:32 Installed: strace-4.5.18-5.el5_5.5.i386
Aug 15 11:10:56 Installed: rcs-5.7-30.1.i386
Aug 15 11:14:43 Installed: ntp-4.2.2p1-9.el5.centos.2.1.i386
Aug 15 11:41:19 Updated: glibc-common-2.5-49.el5_5.4.i386
Aug 15 11:41:25 Installed: libstdc++-devel-4.1.2-48.el5.i386
Aug 15 11:41:29 Installed: kernel-headers-2.6.18-194.11.1.el5.i386
Aug 15 11:41:38 Updated: glibc-2.5-49.el5_5.4.i686
Aug 15 11:41:40 Installed: cpp-4.1.2-48.el5.i386
Aug 15 11:41:40 Installed: libgomp-4.4.0-6.el5.i386
Aug 15 11:41:41 Updated: nscd-2.5-49.el5_5.4.i386
Aug 15 11:41:44 Installed: glibc-headers-2.5-49.el5_5.4.i386
Aug 15 11:41:45 Installed: glibc-devel-2.5-49.el5_5.4.i386
Aug 15 11:41:47 Installed: gcc-4.1.2-48.el5.i386
Aug 15 11:41:48 Installed: gcc-c++-4.1.2-48.el5.i386
最終更新:2010年08月15日 11:43