true and false (commands)

In Unix-like operating systems, true and false are commands whose only function is to always return with a predetermined exit status.

[Note 1] The commands are usually employed in conditional statements and loops of shell scripts.

For example, the following shell script repeats the echo hello loop until interrupted: The commands can be used to ignore the success or failure of a sequence of other commands, as in the example: Setting a user's login shell to false, in /etc/passwd, effectively denies them access to an interactive shell, but their account may still be valid for other services, such as FTP.

(Although /sbin/nologin, if available, may be more fitting for this purpose, as it prints a notification before terminating the session.)

We can rewrite the upper example using : instead of true: The null command may take parameters, which are ignored.