linux如何修改telnet密码,如何修改用户SSH\telnet登陆linux时候显示的欢迎信息

root@fwq ~]# cat /etc/issue

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登入时,需要输入用户名和密码,此时取得的bash就称为login shell

(2)non-login shell:取得bash介面的方法不需要重复登入的动作。

举两个例子(1)以X window登入linux后,再以X的图形化介面启动终端机,此时那个终端机并不需要再次的输入用户名和密码,那个bash的环境就称为non-login shell

(2)在原本的bash环境中再次下达bash这个指令,同样没有要求输入用户名和密码,那个第二个bash也是non-login shell

non-login shell是不是就是现在我在自己的主机上,远程的登录到测试机呢?login shell就是直接对服务器进行操作?

(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 :) ”

(4)/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.(还有写成bash.bashrc的,在测试机验证,只有bashrc,会不会其他系统是这样的!是的,在ubuntu上!)

(5)~/.bash_profile($HOME/.bash_profile):用户环境配置文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。

(6)~/.bashrc:(在用户的根目录下)进行环境变量的编辑,只对当前用户有用。使用修改 /etc/profile文件进行环境变量的编辑,是对所有用户有用。大家一定要注意区别。该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.(每个用户都有一个.bashrc文件,在用户目录下)

/etc/profile和.bashrc的区别:/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。在个人用户下,~/.bashrc和/etc/profile有相同的环境变量时,~/.bashrc会覆盖/etc/profile中的变量!

.bash_profile和.bashrc区别:其中.bash_profile是最重要的一个配置文件,它在用户每次登录系统时被读取,里面的所有命令都会被bash执行。.profile(由Bourne Shell和Korn Shell使用)和.bash_login(由C Shell使用)两个文件是.bash_profile的同义词,目的是为了兼容其它Shell。在Debian中使用.profile文件代替.bash_profile文件。(.bash_profile=.profile=.bash_login)

.bashrc文件会在bash shell调用另一个bash shell时读取,也就是在shell中再键入bash命令启动一个新shell时就会去读该文件。这样可有效分离登录和子shell所需的环境。但一般来说都会在.bash_profile里调用.bashrc脚本以便统一配置用户环境。

(~/.bash_profile 是交互式、login方式进入 bash 运行的,~/.bashrc 是交互式 non-login 方式进入 bash运行的,通常二者设置大致相同,所以通常前者会调用后者。这句话是什么意思?)

在/etc目录的bashrc和profile是系统级(全局)的配置文件,当在用户主目录下找不到.bash_profile和.bashrc时,就会读取这两个文件。.bash_history是bash shell的历史记录文件,里面记录了你在bash shell中输入的所有命令。可通过HISSIZE环境变量设置在历史记录文件里保存记录的条数。alias l = 'ls-l'是设置别名的语句,把它放在这些配置文档中就可使我们能用简单的'l'命令,代替'ls -l'命令。

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 来验证

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值