| メインページ > CentOSで自宅サーバー構築 > 初期設定(CentOS6) |
CentOS 6.2インストール直後の初期設定を行う。
目次 |
[root@host2 ~]# useradd sudachi ← 一般ユーザsudachiの作成 [root@host2 ~]# passwd sudachi ← 一般ユーザsudachiのパスワード設定 ユーザー sudachi のパスワードを変更。 新しいパスワード: ← sudachiのパスワード応答 新しいパスワードを再入力してください: ← sudachiのパスワード応答(確認) passwd: 全ての認証トークンが正しく更新できました。
[root@host2 ~]# userdel -r sudachi ← 一般ユーザsudachiの削除
[sudachi@host2 ~]$ ← sudachiという名前の一般ユーザでログインしている状態 [sudachi@host2 ~]$ su - ← suコマンドでrootになる(スペースと-を忘れずに) パスワード: ← rootのパスワード応答 [root@host2 ~]# ← rootになった [root@host2 ~]# exit ← rootから一般ユーザに戻る logout [sudachi@host2 ~]$ ← sudachiに戻った
[root@host2 ~]# usermod -G wheel sudachi ← 管理者ユーザをwheelグループに追加 [root@host2 ~]# vi /etc/pam.d/su # Uncomment the following line to require a user to be in the "wheel" group. #auth required pam_wheel.so use_uid ↓ auth required pam_wheel.so use_uid ← コメント解除
管理者用一般ユーザからはrootになれて、管理者以外の一般ユーザからはrootになれないことを確認する。
システムからroot宛に重要なメールが送られてくるので、root宛メールを普段使用しているメールアドレス宛に転送するようにする。
[root@host2 ~]# yum -y install mailx ← mailコマンドをインストール [root@host2 ~]# sed -i '/^root:/d' /etc/aliases ← 旧root宛メール転送設定削除 [root@host2 ~]# echo "root: xxxxx@sudachi.jp" >> /etc/aliases ↑ root宛メールを普段使用しているメールアドレス(例:xxxxx@sudachi.jp)宛に転送する [root@host2 ~]# newaliases ← 転送設定反映 [root@host2 ~]# echo test|mail root ← テストメールをroot宛に送信する
テストメールが転送先メールアドレス宛に届いていることを確認する
[root@host2 ~]# getenforce ← SELinux状態確認 Enforcing ← SELinux有効 [root@host2 ~]# setenforce 0 ← SELinux無効化 [root@host2 ~]# getenforce ← SELinux状態確認 Disabled ← SELinux無効 [root@host2 ~]# vi /etc/sysconfig/selinux ← SELinux設定ファイル編集 SELINUX=enforcing ↓ SELINUX=disabled ← システム起動時にSELinuxを無効化
[root@host2 ~]# yum -y update ← インストール済パッケージの一括アップデート [root@host2 ~]# yum -y install yum-cron ← yum-cronインストール [root@host2 ~]# /etc/rc.d/init.d/yum-cron start ← パッケージ自動更新起動 夜間 yum 更新の有効化中: [ OK ] [root@host2 ~]# chkconfig yum-cron on ← パッケージ自動更新自動起動設定 [root@host2 ~]# yum -y groupinstall "Base" "Development tools" ← ベースパッケージ群、開発ツールパッケージ群インストール
RHEL6 (互換である Scientific Linux 6 や CentOS 6 も同様) から、デフォルトでは「cronie-anacron」というパッケージがインストールされ、ジョブの定期実行は anacron で制御されるようになっています。このため、cron のように決まりきった時間にジョブが実行されるわけではなく、設定された時間内(3時-22時)に、ランダムに設定された時間分(0分-45分)待って実行されます。これを従来通りの cron の設定に戻します。
[root@host3 ~]# yum -y install cronie-noanacron
anacron設定のパッケージを削除します。
[root@host3 ~]# yum -y remove cronie-anacron