6

I have seen many tutorials saying that the bin directory is used to store binary files, meaning there is only 0 and 1 in the files in that directory.

However, in many cases, I see files in bin that are not only 0 and 1.

For example, the django-admin.py under the xx/bin/ directory:

#!/usr/bin/env python
from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()
0

4 Answers 4

13

No, a bin directory is not for storing only binary files. It's for keeping executable files, primarily.

Historically, before scripts written in various scripting languages became more common, bin directories would have contained mainly binary (compiled or assembled) non-text files, as opposed to source code. The main thing about the files in bin nowadays is that they are executable.

An executable script is a text file, interpreted by an interpreter. The script in your example is a Python script. When you run it, the python interpreter (which is another executable file somewhere in your $PATH) will be used to run it.

Also, as an aside, a text file is as much a file made up of zeroes and ones as a binary file is.

12

“Binary files” is the etymology of the bin directory, but not its current meaning. Originally, it was for binary files, as in compiled programs — files containing machine code that could be loaded into memory and executed as code. But quickly it came to contain any program that could be executed, whether this program was machine code or a script that is interpreted by some other program. Conversely, files containing machine code that cannot be executed directly is not stored in /bin, but in /lib (for library).

3

From the Filesystem Hierarchy Standard:

/bin contains commands that may be used by both the system administrator and by users, but which are required when no other filesystems are mounted (e.g. in single user mode). It may also contain commands which are used indirectly by scripts.

So, in short, it contains essential program executables. Other folders containing non-essential programs can be /usr/bin, /usr/local/bin etc.

-1

Even scripts are stored as bits and bytes, try for yourself:

xxd -b /usr/bin/zcat

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .