Centos禁止You have new mail in /var/spool/mail/root提示信息

风信网(ithov.com)原创文章:Centos安装好之后,我们在输入命令执行完结果之后,下面总是会提供一行信息:

You have new mail in /var/spool/mail/root

看着确认让人很不舒服呀!我们来把该信息禁止掉吧!只需要修改/etc/profile文件即可

[root@localhost mysql]# echo "unset MAILCHECK" >> /etc/profile

执行完成之后,完整的profile示例如下:

[root@localhost mysql]# vi /etc/profile

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good ">idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}

if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done

unset i
unset -f pathmunge
unset MAILCHECK

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi

HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done

unset i
unset -f pathmunge
unset MAILCHECK

再运行命令,You have new mail in /var/spool/mail/root提示信息已经没有啦!

时间: 2024-10-29 20:42:50

Centos禁止You have new mail in /var/spool/mail/root提示信息的相关文章

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

昨天搬到阿里云了. 装的系统是Centos 6.3的加固版 今天查看内存的时候 出现一天奇怪的提示 You have new mail in /var/spool/mail/root 有的时候每敲一下回车,就出来You have new mail in /var/spool/mail/root的提示,究竟是为什么呢? Linux 系统经常会自动发出一些邮件来提醒用户系统中出了哪些问题(收件箱位置:/var/mail/).可是这些邮件都是发送给 root 用户的.出于系统安全考虑,通常不建议大家直

删除sendmail 在var/spool/clientmqueue/目录下产生的大量文件

如何删除sendmail 在var/spool/clientmqueue/目录下产生的大量文件 故障现象: 今天早上一过来,运维同学就告诉我,TW_LDJ项目机器的/var分区已经使用超过85% 原因分析: 为什么这个目录会这么大呢?这要从/var/spool/clientmqueue/这个目录的作用谈起.当你使用简单的sendmail发邮件的时候, 或者系统默认要发一些邮件(比如cron发的邮件)的时候,首先会把邮件拷贝到这个目录里,然后等待MTA(mail transfer agent) 来

Linux下/var/spool/clientmqueue空间不足的解决

今天收到一封报警邮件,内容如下: ------------------------------------ 报警内容: Free disk space is less than 15% on volume /var ------------------------------------报警级别: PROBLEM ------------------------------------监控项目: Free disk space on /var (percentage):10 % --------

linux下禁止非管理组普通用户登录超级用户root

一般人都知道,linux的最高权限是root账号,因此防范root登录是一个非常必要的事情. 1:禁止普通用户通过su -切换到超级用户root [root@localhost ~]# su - test [test@localhost ~]$ su -    #正常情况下,可以切换到root环境 Password: [root@localhost ~]# [root@localhost ~]# grep "pam_wheel.so" /etc/pam.d/su #auth      

centos禁止与开启ping设置

  禁止ping:  代码如下   echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all 允许ping:  代码如下   echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all 防火墙/etc/sysconfig/iptables添加 -A INPUT -p icmp -m icmp --icmp-type echo-request -m state --state NEW -j ACCEPT /etc/in

centos禁止root直接登录

通过su - root切换到root 可以通过修改/etc/ssh/sshd_config文件,将其中的PermitRootLogin改成no,然后重新启动ssh服务就 可以了. /etc/rc.d/sshd restart service sshd restart

Linux学习之CentOS(二十二)--进入单用户模式下修改Root用户的密码_Linux

在上一篇随笔里面详细讲解了Linux系统的启动过程.,我们知道Linux系统的启动级别一共有6种级别,通过 /etc/inittab 这个文件我们就能看到: [root@xiaoluo ~]# cat /etc/inittab # inittab is only used by upstart for the default runlevel. # # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM. # #

CentOS 6.7上全编译安装GitLab 7-14中文版

1.关闭SELinux #下面的命令实现永久关闭SELinux [root@vps197119 ~]# sed -i 's/^SELINUX=.*/#&/;s/^SELINUXTYPE=.*/#&/;/SELINUX=.*/a SELINUX=disabled' /etc/sysconfig/selinux #下面的命令实现临时关闭SELinux [root@vps197119 ~]# /usr/sbin/setenforce 0 /usr/sbin/setenforce: SELinux

linux mail命令用法

在Linux系统下mail命令的测试 1. 最简单的一个例子:  mail -s test admin@aispider.com 这条命令的结果是发一封标题为test的空信给后面的邮箱,如果你有mta并且后面的邮箱不会挡这种可能莫名奇妙的信的时候,就能收到这封信了.如果你不想被这种乱七八糟的事情干扰,后面的邮箱请使用本地帐户.  2. 第二个例子:  三种常用格式发信 mail -s test admin@aispider.com #第一种方法,你可以把当前shell当成编辑器来用,编辑完内容后