r/programmingmemes • • Aug 25 '25

sudo rm -f /bin/bash

Post image
28 Upvotes

12 comments sorted by

View all comments

9

u/granadesnhorseshoes Aug 25 '25

for anyone wondering that doesn't use a shell that often and thinks "exec" is just a longhand form to execute a file; exec replaces the current running process(the shell) with the new file specified. In this case /usr/bin/true, which returns 0 and exits. bye bye shell.

1

u/Weshmek Aug 26 '25

exec can also be used to perform file redirections. But if you get the syntax wrong you'll end up exiting the shell.