2

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()
5

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

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.

5

“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).

2

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.

0

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

xxd -b /usr/bin/zcat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.