解决linux下创建用户时出现 Creating mailbox file: 文件已存在

原来linux下添加用户后,会在系统里自动加一个邮箱(系统邮箱),路径是:/var/spool/mail/用户名.
      可以直接用命令#rm -rf /var/spool/mail/用户名
      这样就可以再次添加同一名字的用户.

解决You have new mail in /var/spool/mail/root提示

终端远程登陆后经常提示You have new mail in /var/spool/mail/root

这个提示是LINUX会定时查看LINUX各种状态做汇总,每经过一段时间会把汇总的信息发送的root的邮箱里,以供有需之时查看。

一般这种情况mail的内容就只是一些正常的系统信息或者是比较重要的错误报告。

如果你安装了mutt的话直接用这个命令就可以查看mail的内容(用root登陆先),没有装的话用cat /var/spool/mail/root查看(用root登陆先)。

查看内容:

[root@tan ~]# cat /var/spool/mail/root
From root@tan.localdomain  Wed May  1 14:59:35 2019
Return-Path: <root@tan.localdomain>
X-Original-To: root
Delivered-To: root@tan.localdomain
Received: by tan.localdomain (Postfix, from userid 0)
    id AD13C101A70C; Wed,  1 May 2019 14:59:34 +0800 (CST)
To: root@tan.localdomain
From: tan@tan.localdomain
Auto-Submitted: auto-generated
Subject: *** SECURITY information for tan ***
Message-Id: <20190501065934.AD13C101A70C@tan.localdomain>
Date: Wed,  1 May 2019 14:59:34 +0800 (CST)

tan : May  1 14:59:34 : tan : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/tan ; USER=root ; COMMAND=/sbin/useradd tan2


From root@tan.localdomain  Wed May  1 15:04:53 2019
Return-Path: <root@tan.localdomain>
X-Original-To: root
Delivered-To: root@tan.localdomain
Received: by tan.localdomain (Postfix, from userid 0)
    id F0D65101A70C; Wed,  1 May 2019 15:04:52 +0800 (CST)
To: root@tan.localdomain
From: tan@tan.localdomain
Auto-Submitted: auto-generated
Subject: *** SECURITY information for tan ***
Message-Id: <20190501070452.F0D65101A70C@tan.localdomain>
Date: Wed,  1 May 2019 15:04:52 +0800 (CST)

tan : May  1 15:04:52 : tan : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/tan ; USER=root ; COMMAND=/sbin/useradd tan2


From root@tan.localdomain  Wed May  1 15:06:08 2019
Return-Path: <root@tan.localdomain>
X-Original-To: root
Delivered-To: root@tan.localdomain
Received: by tan.localdomain (Postfix, from userid 0)
    id C3BD8101A70C; Wed,  1 May 2019 15:06:08 +0800 (CST)
To: root@tan.localdomain
From: tan@tan.localdomain
Auto-Submitted: auto-generated
Subject: *** SECURITY information for tan ***
Message-Id: <20190501070608.C3BD8101A70C@tan.localdomain>
Date: Wed,  1 May 2019 15:06:08 +0800 (CST)

tan : May  1 15:06:08 : tan : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/tan ; USER=root ; COMMAND=/sbin/useradd tan2


From root@tan.localdomain  Wed May  1 15:18:14 2019
Return-Path: <root@tan.localdomain>
X-Original-To: root
Delivered-To: root@tan.localdomain
Received: by tan.localdomain (Postfix, from userid 0)
    id 68249101A71A; Wed,  1 May 2019 15:18:14 +0800 (CST)
To: root@tan.localdomain
From: tan@tan.localdomain
Auto-Submitted: auto-generated
Subject: *** SECURITY information for tan ***
Message-Id: <20190501071814.68249101A71A@tan.localdomain>
Date: Wed,  1 May 2019 15:18:14 +0800 (CST)

tan : May  1 15:18:14 : tan : user NOT in sudoers ; TTY=pts/1 ; PWD=/etc ; USER=root ; COMMAND=/bin/cat sudoers

也可以设置把这个信息发送到管理员邮箱

日志分析工具 Logwatch能够对Linux 的日志文件进行分析,并自动发送mail给相关处理人员,可定制需求 Logwatch的mail功能是借助宿主系统自带的mail server发邮件的,系统需安装mail server , 如sendmail,postfix,Qmail等,具体配置不叙述

关闭提示:

[root@check1 ~]# echo "unset MAILCHECK">> /etc/profile
[root@check1 ~]# source /etc/profile

查看:

[root@check1 ~]# ls -lth /var/spool/mail/
total 49M
-rw------- 1 root mail 49M Jul 4 13:43 root
-rw-rw---- 1 nginx mail 0 May 21 11:46 nginx
-rw-rw---- 1 zabbix mail 0 May 16 15:48 zabbix

清空:

[root@check1 ~]# cat /dev/null > /var/spool/mail/root

关闭提示:

1
2
[root@check1 ~]# echo "unset MAILCHECK">> /etc/profile
[root@check1 ~]# source /etc/profile
原文地址:https://www.cnblogs.com/tan-y-q/p/10800205.html