What is / bin / true

On a Linux system, what is /bin/true ?

+45
linux command
Feb 01 '10 at 8:21
source share
5 answers

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

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

/bin/false is the opposite value that returns a nonzero value (false value in the shell).

+49
Feb 01 '10 at 8:24
source share

On the man page:

 true - do nothing, successfully true returns a status 0. 
+18
Feb 01 '10 at 8:23
source share

Please note that this is not just silly or visually pleasing. This helps, for example, to exit the program without activating the final handlers, which can deteriorate when running multithreaded or branched programs. Like in perl:

 #!/usr/bin/env perl exec "/bin/true"; END { print "This wont get printed .. would have if I just 'exit' or 'die'\n"; } 
+7
Dec 06 '13 at 0:42
source share

Just say that his program returns 0. Sometimes we need to get this value so that the script is more readable.

0
Jun 13 '13 at 10:21
source share

I saw what he used to trick a system operation into believing that a command is launched when it does not. If the command is faulty, for example, a cycle, you can replace it with a symbolic link to “true” to start the main task. Only a good idea if the replaced work is not significant.

0
Sep 20 '16 at 22:25
source share



All Articles