I want, when a linux user exits from a shell script, that it also logs out from the bash shell. Is this possible?
Depending on what you are trying to accomplish, you could use the script name instead of the shell in /etc/passwd.
The last entry in /etc/passwd (everything after the last colon) is the shell that is run when the user logs on. By changing this to the name of your script, when the script ends, then by definition, so does the shell.
** Be very careful editing /etc/passwd however, as you could lock yourself out of your machine. Apparently you can do this with
usermod --shell <script name> <user name>
which would be the safer way to make this change.
Another approach may be to
source the script instead of calling it directly, an
exit statement in the script will then close the user shell:
$ cat exit_me.sh #!/bin/bash exit
$ source exit_me.sh # or $ . exit_me.sh
More info about