修改Linux登录欢迎提⽰信息
之前登陆某服务器,见到了花式的欢迎信息,然后,就很想试试~
服务器⼀般可以配置两种类型的提⽰信息:①⽤户登录前显⽰的提⽰信息;②⽤户成功登
录后显⽰的提⽰信息。需注意的是,不同的linux发⾏版本修改的⽅法不太⼀样。
⼤致过程如下:
(1) 查看服务器的基本信息
uname -a #查看服务器的基本信息
可以看到,是熟悉的Ubuntu~
(2) 修改登录欢迎信息
在⼀般的linux发⾏版中(如centos),/etc/issue⾥存放了⽤户成功登录前显⽰的信息;/etc/motd存放了⽤户成功登录后显⽰的信息;但在Ubuntu中,相关的是/etc/update-motd.d/⽂件夹下的⼏个脚本:
cd /etc/update-motd.d/ls -alF
通过ssh登录主机/服务器时,会输出/var/run/motd.dynamic 中的信息。⽽/var/run/motd.dynamic 中的信息就是⽤户登录时系统已root⾝份执⾏上述/etc/update-motd.d/ 下⾯的⼏个脚本所⽣成的。所以想要DIY欢迎信息,就需要修改这⼏个脚本⽂件。
cat /var/run/motd.dynamic #查看当前的登录提⽰语
修改前的提⽰语,嗯,还蛮⽼⼲部的,为了留个纪念,我决定给备个份,毕竟之后就看不到了。值得注意的是,修改系统配置⽂件要谨慎。
sudo cp /var/run/motd.dynamic{,.bak} #⽣成备份⽂件motd.dynamic.bak
结合脚本⽂件的名字和提⽰语的各部分内容,可以⼤致推断出需作出的修改。其中,00-header主要是显⽰⼀些欢迎信息的头部;10-help-text中主要是⼀些提供帮助查询⽹站的信息。其它还有⼀些软件包更新、系统更新等信息,本⽂主要以前两个脚本⽂件为例。
查看00-header脚本⽂件:
cat /etc/update-motd.d/00-header#!/bin/sh## 00-header - create the header of the MOTD# Copyright (C) 2009-2010 Canonical Ltd.## Authors: Dustin Kirkland <kirkland@canonical>## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU Gener
al Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License along# with this program; if not, write to the Free Software Foundation, Inc.,# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.[ -r /etc/lsb-release ] && . /etc/lsb-releaseif [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then # Fall back to using the very slow lsb_release utility DISTRIB_DESCRIPTION=$(lsb_release -s -d)fiprintf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"查看10-help-text⽂件:
cat /etc/update-motd.d/10-help-text#!/bin/sh## 10-help-text - print the help text associated with the distro# Copyright (C) 2009-2010 Canonical Ltd.## Authors: Dustin Kirkland <kirkland@canonical>,# Brian Murray <brian@canonical>## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WA
RRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License along# with this program; if not, write to the Free Software Foundation, Inc.,# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.printf "\n"printf " * Documentation: help.ubuntu\n"printf " * Management: landscape.canonical\n"printf " * Support: ubuntu/advantage\n"
⼤致了解脚本⽂件长什么样⼦了,就可以开始修改了。其实,主要修改00-header脚本⽂件就可以啦,帮助⽂件10-help-text的4⾏内容直接注释掉就好了,没必要展⽰。
#为防⽌改崩了或者改丑了,先给这些系统⽂件创建备份sudo cp /etc/update-motd.d/00-header{,.bak}sudo cp /etc/update-motd.d/10-help-text{,.bak}sudo vim /etc/update-motd.d/10-help-text #修改10-help-text脚本⽂件sudo vim /etc/update-motd.d/00-header #修改00-header脚本⽂件#!/bin/sh## 00-header - create the header of the MOTD# Copyright (C) 2009-2010 Canonical Ltd.## Authors: Dustin Kirkland
<kirkland@canonical>## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation;
either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License along# with this program; if not, write to the Free Software Foundation, Inc.,# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.[ -r /etc/lsb-release ] && . /etc/lsb-releaseif [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then # Fall back to using the very slow lsb_release utility
DISTRIB_DESCRIPTION=$(lsb_release -s -d)fiprintf "Welcome to %s (%s %s %s)\n"
"$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"printf "\n"printf
linux系统安装步骤csdn">>>>># Softwares installed >>>>>####"printf "\n# `ls /home/hucy/.soft | sort | paste -s -d / `\n"printf
">>>>>>>>>>>>>>>#"
本例仅简单增加了4⾏,⽬的是在登录成功后,显⽰已安装的软件。注:/home/hucy/.soft⽬录下,是给所有安装成功的软件创建的软链接。
修改后,登录成功后的界⾯如下:
修改后的界⾯⽐较丑,但是基本达到了⽬的。总归是别⼈家的服务器,就改到这⾥吧~
参考阅读:
1. CentOS查看系统信息命令和⽅法 wwwblogs/kluan/p/4457889.html
2. 教你如何修改Linux远程登录欢迎提⽰信息 www.jb51/article/136267.htm
3. Ubuntu修改ssh登录欢迎信息 blog.csdn/plm199513100/article/details/81270377
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
Linux+Qt+OpenGL配置方案
« 上一篇
Linux运行UI自动化脚本
下一篇 »
发表评论