Results 1 to 10 of 10

Thread: File extentions, yes or no?

  1. #1
    Join Date
    Feb 2010
    Location
    Tennessee,USA
    Beans
    166

    File extentions, yes or no?

    I've read in the Ubuntu book, and some other places, that Ubuntu doesn't use file extensions.

    However looking around my files, I see lots of different extensions.
    I'm confused.

  2. #2
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: File extentions, yes or no?

    It doesn't need file extensions... an unextended file can easily be opened by whatever opens it, but the program that then opens it *might* want you to add an extension... plus it beats running a file command every time you want to find out what a file is for
    Comitas. Brevitas. Nulla ambitio.

  3. #3
    Join Date
    Feb 2010
    Location
    Tennessee,USA
    Beans
    166

    Re: File extentions, yes or no?

    Thanks JV, I think I understand.
    It doesn't need it, but it helps.

    OK, so lets say I want to install a program, how does Ubuntu know, that it is an executable file, if there is no extension?

  4. #4
    Join Date
    Jun 2009
    Beans
    1,618
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: File extentions, yes or no?

    Well standard executables have the "Executable" permission checked, but most linux apps are contained in files that are unpacked with executables already on the system (You can't run a deb rpm or tar.gz, but you can use dpkg, untar, etc to "Install" them)
    Comitas. Brevitas. Nulla ambitio.

  5. #5
    Join Date
    Feb 2010
    Location
    Tennessee,USA
    Beans
    166

    Re: File extentions, yes or no?

    I appreciate your time answering my question.
    Thank You.

  6. #6
    Join Date
    Jun 2008
    Location
    Tennessee
    Beans
    3,421

    Re: File extentions, yes or no?

    Actually this is a bit of a misconception.

    Desktop environments like GNOME or KDE actually do use file extensions to identify what program to open a file with, what default icon to give it, etc. If you take a .txt file and change its extension to png, you'll find that its icon will change and double-clicking it will open your image viewer.

    If you want to execute a text file as a script by clicking on it from a file manager or on the desktop, you have to give it a file extension such as ".sh" which your DE will recognize as executable.

    At the command line level it's a different story. File extensions at that level are just part of the name and have no bearing on what happens when you try to execute them.

  7. #7
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: File extentions, yes or no?

    Most files in Linux contain information identifying the file type. For example, the first line of a bash shell script contains #!/bin/bash. I don't know a lot about this topic but for more information see:

    http://en.wikipedia.org/wiki/File_format
    Last edited by kaibob; March 16th, 2010 at 05:55 PM. Reason: Clarified by deleting quote and reference to magic number in link.

  8. #8
    Join Date
    Jun 2008
    Location
    Tennessee
    Beans
    3,421

    Re: File extentions, yes or no?

    Quote Originally Posted by kaibob View Post
    Most files in Linux contain information identifying the file type. For example, the first line of a bash shell script contains #!/bin/bash. I don't know a lot about this topic but for more information see:

    http://en.wikipedia.org/wiki/File_format#Magic_number
    Magic numbers can be used to identify files at the command-line level, but that's different from the #!/bin/bash thing.

    Basically, if you execute a file with execute permissions at the command line, it will do one of two things:

    - if it's an ELF executable (standard binary executable format, analogous to .exe files on windows), it will execute it.
    - if it's anything else (including binary files like images), it will try to interpret it as a script. By default it interprets it as a bash script, but if you include a "#!" line it will use the interpreter you specify in that line (e.g., "#!/usr/bin/python").

    But like I said, this is at the command-line level. At the desktop environment level it's quite similar to how Windows behaves, utilizing the file extension to figure out what to do with the file.

  9. #9
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: File extentions, yes or no?

    Quote Originally Posted by lykwydchykyn View Post
    Magic numbers can be used to identify files at the command-line level, but that's different from the #!/bin/bash thing.
    You clearly know more about this than I do, and I guess this is just a matter of semantics, but the Wikipedia article states:

    So-called shebang lines in script files are a special case of magic numbers. Here, the magic number is human-readable text that identifies a specific command interpreter and options to be passed to the command interpreter.

  10. #10
    Join Date
    Jun 2008
    Location
    Tennessee
    Beans
    3,421

    Re: File extentions, yes or no?

    Quote Originally Posted by kaibob View Post
    You clearly know more about this than I do, and I guess this is just a matter of semantics, but the Wikipedia article states:
    I clearly didn't know that

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •