LoginSignup
0
0

[Linux 初期設定] mailコマンドインストール

Posted at

Linux 初期設定シリーズ

変更内容:mailコマンドインストール
確認OS:Red Hat Enterprise Linux release 9.2 (Plow)
対象ファイル:/etc/aliases
反映:newaliases コマンドを実行する

0.Postfixインストール

test.sh
sudo dnf -y install postfix
sudo systemctl start postfix
sudo systemctl enable postfix
sudo systemctl status postfix

1.mailコマンドインストール
※注意、OSのバージョンによってツールが違う

・AlmaLinux 8

test.sh
sudo dnf install mailx

・AlmaLinux 9

test.sh
sudo dnf install s-nail

・CentOS 7

test.sh
sudo dnf install sendmail

2.設定のバックアップ

test.sh
sudo cp -an /etc/aliases{,.$(date +%Y%m%d)}
sudo ls -alF /etc/aliases*

3.root宛メールを転送する設定
名称:<名前←正式名称を調べて修正する>
転送先:<メールアドレス>

test.sh
sudo sed -i -e 's/#root:\t\tmarc/root:\t\t<名前←正式名称を調べて修正する>/g' /etc/aliases
sudo sed -i -e '$ a <名前←正式名称を調べて修正する>:\t<メールアドレス>' /etc/aliases

4.設定の確認

test.sh
sudo diff /etc/aliases{,.$(date +%Y%m%d)}

5.転送設定反映

test.sh
sudo newaliases

6.テストメールを root 宛に送信する

test.sh
echo test from `hostname -s` | mail root
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0