Find the answer to your Linux question:
Results 1 to 7 of 7
Hey, I've been learning Linux, primarily through the book "The Unix Programming Environment". I know that there's a difference between Linux and Unix, but most of the stuff (pipes, grep, ...
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3

    Directories in Linux

    Hey,
    I've been learning Linux, primarily through the book "The Unix Programming Environment". I know that there's a difference between Linux and Unix, but most of the stuff (pipes, grep, etc.) seems to translate really well. Anyway, in the book, it says that everything is a file, even directories, and even goes so far as to read the bytes in a directory file using od. But when I tried this with my linux computer, I go the following error: read error: Is a directory
    00000000

    So, my question is: how are directories handled in Linux? Are they files? Or what?

  2. #2
    Super Moderator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,144
    Hello and Welcome.
    They are Directories. Here is an in depth explanation for file system hierarchy.
    Filesystem Hierarchy Standard
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

  3. #3
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3
    After a bit more googling, I found this:
    tldp.org/LDP/intro-linux/html/sect_03_01.html

    which states that "A Linux system, just like UNIX, makes no difference between a file and a directory, since a directory is just a file containing names of other files."

    So why can't I od a directory?

  4. #4
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    Well, I found this explanation.
    Senior Advisor - http://www.unix.com

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    Basically, Linux does not allow this, normal read operations on directories. Personally, it seems silly to me, as they are, as you surmise, just files, but there it is...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3
    Thanks for the explanations!

  7. #7
    Linux Newbie theKbStockpiler's Avatar
    Join Date
    Sep 2010
    Location
    Upstate NY
    Posts
    195

    A crazy thing called Meta-Data.

    Any section of your hard drive (storage) that is dedicated to a specific purpose is a file just like old fashioned paper files. It's like segregation for data. A filing system is meant to organize your data. A directory is a file in that it is on your hard drive for a specific purpose and this is to hold information on another file. This is another form of mata data. Mata data is Very important to learn if you want to go past a casual user in computing. So a directory which is a file that holds data about a file in which the latters purpose is only to hold data like a saved letter or so on. In a way a directory or file that you see in nautilus and dolphin are mearly short cuts represented by an icon of information on the data you need like the sample letter. Nautilus and Dolphin do not actually hold the data of the sample letter but the information on how to find it in storage. It's like a virtual file system so the user can naviagate through files themselves. The kernel uses the info in the directories to access the files. Nautilus and Dolphin for example do not store the images for icons in the file that represents them. If you view the files contents there is no jpg extenstion. The images for these icons is actually in another file.

    Sorry for being confusing and this is not a current topic of mine but it will help you get a grasp on Meta-Data.

Posting Permissions

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