一般来说默认远程登录的提示信息都是这样的:
Connecting to 192.168.16.191:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].
Last login: Fri Sep 7 00:13:18 2018 from 192.168.17.180
[root@localhost ~]#
一,如果要自定义一些提示信息在登录后显示出来,我们应该修改/etc/motd这个文件:
[root@localhost ~]# ll /etc/motd
-rw-r--r--. 1 root root 0 Jun 7 2013 /etc/motd
[root@localhost ~]# vim /etc/motd
#注意:文件中所有的文本和字符都不会被转义的,会直接打印出来的
#编辑motd文件添加下面一句话然后保存退出:
禁止非法登录!允许正常登录!
我们重新打开一个连接就可以看到登陆后,会有刚加的自定义信息显示出来:
Connecting to 192.168.16.191:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].
Last login: Thu Sep 13 23:28:40 2018 from 192.168.17.180
禁止非法登录!欢迎正常登录!
[root@localhost ~]#
二,如果要自定义一些执行命令的结果显示,我们应该修改/etc/bashrc这个文件:
[root@localhost ~]# ll /etc/bashrc
-rw-r--r--. 1 root root 2853 Nov 5 2016 /etc/bashrc
#编辑文件最下方添加我们要执行的命令即可
[root@localhost ~]# vim /etc/bashrc
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
# and console windows
# If you want to do so, just add e.g.
# if [ "$PS1" ]; then
# PS1="[\u@\h:\l \W]\\$ "
# fi
# to your custom modification shell script in /etc/profile.d/ directory
fi
if ! shopt -q login_shell ; then # We're not a login shell
# Need to redefine pathmunge, it get's undefined at the end of /etc/profile
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
# By default, we want umask to get set. This sets it for non-login shell.
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
SHELL=/bin/bash
# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
fi
# vim:ts=4:sw=4
#此处为我们自定义的命令
df -h
我们再重新打开一个连接可以看到登陆后,刚加的磁盘使用信息显示出来:
Connecting to 192.168.16.191:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].
Last login: Thu Sep 13 23:39:04 2018 from 192.168.17.180
#注释
禁止非法登录!欢迎正常登录!
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 14G 3.4G 11G 26% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 191M 1.7G 11% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
tmpfs 380M 0 380M 0% /run/user/0
[root@localhost ~]#
本文最后记录时间 2024-03-31
文章链接地址:https://me.jinchuang.org/archives/261.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处
文章链接地址:https://me.jinchuang.org/archives/261.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处