I am working on Linux Ubuntu 16.04.
In this challenge I want to remove some commands from the Linux shell.
Specifically, I want to remove the exit command.
I want that if a user will try to exit the shell with this command, it won't be possible or maybe even send some message instead.
Any idea how can I do it ?
I searched for a file named exit:
find / -name exit
But it found only directories:
/usr/src/linux-headers-4.13.0-41-generic/include/config/have/exit
/usr/src/linux-headers-4.13.0-41-generic/include/config/have/irq/exit
/usr/src/linux-headers-4.13.0-43-generic/include/config/have/exit
/usr/src/linux-headers-4.13.0-43-generic/include/config/have/irq/exit
/usr/src/linux-headers-4.13.0-36-generic/include/config/have/exit
/usr/src/linux-headers-4.13.0-36-generic/include/config/have/irq/exit
/usr/src/linux-headers-4.15.0-43-generic/include/config/have/exit
/usr/src/linux-headers-4.15.0-43-generic/include/config/have/irq/exit
EDIT:
I read here about using trap like this trap "ENTER-COMMAND-HERE" EXIT and I tried trap "sh" EXIT but it still existing the shell.
exitis a builtin (part of the shell itself, not an external application). You'd probably have to modify the source code for the shell in question. Why would you want to do such a thing as preventing a user exiting a shell session, though? (perhaps it would be better to not haveexitbe an alias forlogoutin interactive sessions, rather than remove theexitfunctionality.)exitcommand, considering that one could send^Dsignal, either via keyboard or viaprintf, or kill the shell process. A challenge though IMHO without a satisfactory solutionexitwould serve.^D(VEOF) doesn't send a signal, like^C(VINTR). It's causing the data already written to the tty to be immediately made available at the other end; if there's no such data, a read at the other end with return 0 (EOF). Also, could you please explain how you could send a^Dto the shell from within the shell withprintf?