CentOS release 6.2 (Final)
Kernel \r on an \m
用户telnet登陆时候显示的欢迎信息
[root@fwq ~]# cat /etc/issue.net
CentOS release 6.2 (Final)
Kernel \r on an \m
[root@fwq ~]#
eg
login as: root
root@10.2.22.3's password:
Last login: Thu Oct 30 08:44:08 2014 from 10.6.7.44
=====================================================
login 与no-login shell
定义:
(1)login shell:取得bash 时需要完整的登入流程,就称为login shell。举例来说,同tty1~tty6登入时,
(2)non-login shell:取得bash介面的方法不需要重复登入的动作。
(3)/etc/profile:系统环境变量,对所有用户都起作用,使用env命令显示所有的环境变量。在命令提示符下键入env就行了。set命令显示所有本地定义的Shell变量。
PATH:决定了shell将到哪些目录中寻找命令或程序
HOME:当前用户主目录
MAIL:是指当前用户的邮件存放目录。
SHELL:是指当前用户用的是哪种Shell。
HISTSIZE:是指保存历史命令记录的条数。
LOGNAME:是指当前用户的登录名。
HOSTNAME:是指主机的名称,许多应用程序如果要用到主机名的话,通常是从这个环境变量中来取得的。
LANG/LANGUGE:是和语言相关的环境变量,使用多种语言的用户可以修改此环境变量。
PS1:是基本提示符,对于root用户是#,对于普通用户是$。
PS2:是附属提示符,默认是“>”。可以通过修改此环境变量来修改当前的命令符,比如下列命令会将提示符修改成字符串“Hello,My NewPrompt :) ”。
# PS1=“ Hello,My NewPrompt :) ”
(5)~/.bash_profile($HOME/.bash_profile):用户环境配置文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。
(6)~/.bashrc:(在用户的根目录下)进行环境变量的编辑,只对当前用户有用。使用修改 /etc/profile文件进行环境变量的编辑,是对所有用户有用。大家一定要注意区别。该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.(每个用户都有一个.bashrc文件,在用户目录下)
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 来验证