Login shells
/etc/profile
/etc/profile.d
~/.bash_profile
~/.bashrc
/etc/bashrc
Non-login shells
~/.bashrc
/etc/bashrc
/etc/profile.d
login nologin shell的执行顺序按照上述顺序执行.
查看/etc/profile
#cat /etc/profile
有以下内容,说明了执行 /etc/profile.d/里的*.sh
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
/etc/profile.d里面有以下脚本
-rwxr-xr-x 1 root root 720 Apr 11 2006 colorls.csh
-rwxr-xr-x 1 root root 713 Apr 11 2006 colorls.sh
-rwxr-xr-x 1 root root 192 Oct 13 2004 glib2.csh
-rwxr-xr-x 1 root root 190 Oct 13 2004 glib2.sh
-rwxr-xr-x 1 root root 58 May 2 2006 gnome-ssh-askpass.csh
-rwxr-xr-x 1 root root 70 May 2 2006 gnome-ssh-askpass.sh
-rwxr-xr-x 1 root root 78 Jan 11 2006 kde.csh
-rwxr-xr-x 1 root root 74 Jan 11 2006 kde.sh
-rwxr-xr-x 1 root root 218 Feb 7 2006 krb5.csh
-rwxr-xr-x 1 root root 210 Feb 7 2006 krb5.sh
-rwxr-xr-x 1 root root 2182 Apr 21 2006 lang.csh
-rwxr-xr-x 1 root root 2470 Apr 21 2006 lang.sh
-rwxr-xr-x 1 root root 122 Jun 16 2004 less.csh
-rwxr-xr-x 1 root root 108 Jun 16 2004 less.sh
-rwxr-xr-x 1 root root 51 Nov 19 2004 mc.csh
-rwxr-xr-x 1 root root 45 Nov 19 2004 mc.sh
-rwxr-xr-x 1 root root 102 Nov 25 2004 qt.csh
-rwxr-xr-x 1 root root 99 Nov 25 2004 qt.sh
-rwxr-xr-x 1 root root 13 Aug 11 2005 vim.csh
-rwxr-xr-x 1 root root 181 Aug 11 2005 vim.sh
-rwxr-xr-x 1 root root 170 Aug 7 2004 which-2.sh
当执行完上述所有脚本之后,会执行当前帐户下的~/.bash_profile文件,该文件有其中以下内容,说明会具体执行~/.bashr的内容
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#vi ~/.bashrc
有以下内容
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
看来login shell最终会执行 /etc/bashrc 这个脚本
----------------------------------------------------------------
nologin shell
按照上面的思路可以看到 nologin的执行顺序,验证的方式可在每个文件上使用echo 来验证
---------------------------------
另外每个新建立的帐号,都会从/etc/skel 目录下,COPY隐藏登录文件到自己的家目录下
/etc/profile
/etc/profile.d
~/.bash_profile
~/.bashrc
/etc/bashrc
Non-login shells
~/.bashrc
/etc/bashrc
/etc/profile.d
login nologin shell的执行顺序按照上述顺序执行.
查看/etc/profile
#cat /etc/profile
有以下内容,说明了执行 /etc/profile.d/里的*.sh
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
/etc/profile.d里面有以下脚本
-rwxr-xr-x 1 root root 720 Apr 11 2006 colorls.csh
-rwxr-xr-x 1 root root 713 Apr 11 2006 colorls.sh
-rwxr-xr-x 1 root root 192 Oct 13 2004 glib2.csh
-rwxr-xr-x 1 root root 190 Oct 13 2004 glib2.sh
-rwxr-xr-x 1 root root 58 May 2 2006 gnome-ssh-askpass.csh
-rwxr-xr-x 1 root root 70 May 2 2006 gnome-ssh-askpass.sh
-rwxr-xr-x 1 root root 78 Jan 11 2006 kde.csh
-rwxr-xr-x 1 root root 74 Jan 11 2006 kde.sh
-rwxr-xr-x 1 root root 218 Feb 7 2006 krb5.csh
-rwxr-xr-x 1 root root 210 Feb 7 2006 krb5.sh
-rwxr-xr-x 1 root root 2182 Apr 21 2006 lang.csh
-rwxr-xr-x 1 root root 2470 Apr 21 2006 lang.sh
-rwxr-xr-x 1 root root 122 Jun 16 2004 less.csh
-rwxr-xr-x 1 root root 108 Jun 16 2004 less.sh
-rwxr-xr-x 1 root root 51 Nov 19 2004 mc.csh
-rwxr-xr-x 1 root root 45 Nov 19 2004 mc.sh
-rwxr-xr-x 1 root root 102 Nov 25 2004 qt.csh
-rwxr-xr-x 1 root root 99 Nov 25 2004 qt.sh
-rwxr-xr-x 1 root root 13 Aug 11 2005 vim.csh
-rwxr-xr-x 1 root root 181 Aug 11 2005 vim.sh
-rwxr-xr-x 1 root root 170 Aug 7 2004 which-2.sh
当执行完上述所有脚本之后,会执行当前帐户下的~/.bash_profile文件,该文件有其中以下内容,说明会具体执行~/.bashr的内容
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#vi ~/.bashrc
有以下内容
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
看来login shell最终会执行 /etc/bashrc 这个脚本
----------------------------------------------------------------
nologin shell
按照上面的思路可以看到 nologin的执行顺序,验证的方式可在每个文件上使用echo 来验证
---------------------------------
另外每个新建立的帐号,都会从/etc/skel 目录下,COPY隐藏登录文件到自己的家目录下
转载于:https://blog.51cto.com/bowen/95442