"logout" command works in a login shell, not in a interactive shell

2019年06月13日

*
证明:On CentOS, the "logout" command works in a login shell, it does not work in a interactive shell.
证:
[centos@localhost ~]$ su
Password:
This is an interactive shell.
[root@localhost centos]# logout
bash: logout: not login shell: use `exit'

[centos@localhost ~]$ su -
Password:
Last login: Thu Jun 13 10:23:27 CST 2019 on pts/0
This is an interactive shell.
This is a login shell.
[root@localhost ~]# logout
解毕!
Reference: Nohup and the difference between logout and exit on a remote shell
*
证明:The .bash_logout works in login shell, not in interactive shell.
证:

[root@localhost ~]# su - rob
Last login: Thu Jun 13 10:39:11 CST 2019 on pts/0
This is rob.
[rob@localhost ~]$ vim .bash_logout

# ~/.bash_logout
echo "Byebye, Rob."
[rob@localhost ~]$ exit
logout
Byebye, Rob.

[root@localhost ~]# su rob
[rob@localhost root]$ exit
exit
解毕!
*

Category: Linux Tags: public