centos7中的etc/profile代码发我
时间: 2024-06-08 07:07:43 浏览: 130
以下是 CentOS 7 中 `/etc/profile` 文件的默认代码:
```bash
# /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 () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
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
fi
pathmunge /usr/local/bin
pathmunge /usr/bin
pathmunge /usr/local/go/bin
pathmunge /usr/local/nodejs/bin
pathmunge /usr/local/mysql/bin
pathmunge /usr/local/php/bin
pathmunge /usr/local/python3/bin
pathmunge /usr/local/nginx/sbin
pathmunge /root/bin after
HOSTNAME=$(hostname)
export HOSTNAME
# Set the initial umask. Only users can change this setting.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi
# Are we an interactive shell?
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
# Try to keep environment pollution down, EPA loves us.
unset ENV RCFILE REPLY_HISTORY_FILE INPUTRC GLOBIGNORE
unset -f pathmunge
```
注意,这是默认代码,如果您对其进行了修改,可能会与此不同。建议在修改之前备份此文件。
阅读全文