What is /bin/true? What is /bin/true? linux linux

What is /bin/true?


/bin/true is a command that returns 0 (a truth value in the shell).

Its purpose is to use in places in a shell script where you would normally use a literal such as "true" in a programming language, but where the shell will only take a command to run.

/bin/false is the opposite that returns non-zero (a false value in the shell).


From the man page:

true - do nothing, successfullytrue returns a status 0.


Note, it's not just silly or visually nice. It helps for example to exit a program without activating the end handlers which might mess up when doing multi threading or forked programs. Like in perl:

#!/usr/bin/env perlexec "/bin/true";END {  print "This wont get printed .. would have if I just 'exit' or 'die'\n";}