Hidden files and folders - Why the . character in file / folder name instead of using a flag?

More of a general Linux question, but since openSUSE is my distribution I’m asking here. Like I said I’m moving from Windows 7 to SUSE, and inevitably comparing many things on the way. Something I’m slightly confused about is the way Linux chooses to mark hidden files / folders compared to Win. While in Windows you right-click them and mark them as ‘hidden’, in Linux they are marked this way by putting a dot in the file / folder name (eg: “.something” instead of “something”).

I’m slightly confused as to why the name is being used to mark things as hidden. One feature in Linux compared to Windows (positive I’d say) is being able to use mime types instead of extensions, making them optional. Yet for hidden files it’s the other way around… you need to rename instead of being able to use a different kind of mark. At a first look, it doesn’t seem optimal for one thing… since the name is being used to toggle a feature / setting instead of just being that file or folder’s name.

The real issue I’m imagining is that if you’re using a file or folder as part of a full path, then want to mark it as hidden later on (say you don’t want to see it all the time in Dolphin) its path would change. So if you have the location /foo/bar (where bar is a file and foo a folder) and you wanna make foo a hidden folder, the path would then become /.foo/bar and would need to be updated in any script or application relating to it. Not sure if the Linux path system can automatically translate this (ignore the . and use the old path, or the other way around) which would offer an advantage. Also, would this allow items with the same name to exist in the same folder (filename and .filename)?

What are the benefits of hiding things this way, and are there alternative ways to mark files and folders as hidden? Note that I’m not trying to “make Linux be like Windows” nor mind how it works. Others know better why it was done this way, but I’m trying to learn why this option was chosen and is still used in Linux at this day.

ok, so the first thing you need to get a grip on is that linux is a
multi-user system.

now that is not like a laptop that you share with your
room-mate/whoever…no, its like back in the old days (say in an
insurance company or bank) there was ONE computer (probably made by IBM)
stuck in a “computer room” in the back office and all the folks out
front who needed “a computer” were given a terminal

and, each terminal was connected to “the computer”…

to keep Clara the Clerk from reading that she was gonna be fired by Bob
the Boss next week (and other reasons) each users data was kept in each
person’s personal home space…Clara couldn’t read in Bob’s /home and
vice versa

and, by the way the guy who worked in the back office and knew
everything because he could read in everyone’s home, and erase their
files, and cause all sorts of bad (or good) things (like change
passwords, add new users, delete users, make backups, and fidddle with
The Computer [rather than just the terminal] and etc was named The
System Administrator, or root.

now since Clara and Bob were able to see into their own home, sometimes
(because they were just ‘regular’ people–not nerds) they might happen
up on a file that they didn’t remember writing!! and being mere mortals
they were sometimes known to erase them! [this actually happened, if you
can believe it] but, those files in their home that they didn’t write
were needed to be there! the system used them for stuff…so, root
devised an EASY way to hide files from mortals so they couldn’t so
easily gum up the works!! [just build the system so regular users
couldn’t see a file name beginning with a dot, simple, quick, easy,
foolproof and root could easily change every file in the entire
insurance company named (say) wordstar_configure from being seen to
being unseen by mortals with just ONE small command]

ok?

by the way, since all of this was going on (including files were
‘hidden’ behind a dot) while Bill Gates (and Steve Jobs) were in grammar
school (or earlier), you really should (instead of asking here why we
don’t do it the MS way) why not ask him why he didn’t do the *nix way.

http://www.linfo.org/hidden_file.html


dd

On 2012-09-30 12:06, MirceaKitsune wrote:
>
> More of a general Linux question, but since openSUSE is my distribution
> I’m asking here. Like I said I’m moving from Windows 7 to SUSE, and
> inevitably comparing many things on the way. Something I’m slightly
> confused about is the way Linux chooses to mark hidden files / folders
> compared to Win. While in Windows you right-click them and mark them as
> ‘hidden’, in Linux they are marked this way by putting a dot in the file
> / folder name (eg: “.something” instead of “something”).

Well, I don’t know. I’m also curious as to why, I just stored the fact as something that is
different. And executables are marked with a flag instead of an extension. I guess that they
found out the need to hide files after the flags were designed.

For example, there are also extended attributes, on xfs filesystems: the normal set of
attributes is too limited (man attr). And there are acl, access control lists, another set of
permissions to add to a file. Additions. Instead of modifying the initial set, they added
different sets in different manners.

Remember that unix pre-dates MSDos, thus some features were experimented here earlier.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Am 30.09.2012 14:08, schrieb Carlos E. R.:
> Remember that unix pre-dates MSDos, thus some features were experimented here earlier.
I am almost sure if UNIX where designed today instead of decades ago
“hidden” would be an attribute (and we would have much more attributes
and acls by default). The prefix dot notation is just backwards
compatibility and was obviously good enough not to change it to
something else.


PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.2 x86_64 | i3@2.30GHz | 8GB | KDE 4.9.1 | HD 3000
eCAFE 800: oS 12.2 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10

The explanations above are all true and partly explain this in a colourfull way.

In the beginning there was Unix. And there weren’t many bytes on a disk. And disks were expensive (per byte). Thus the file system(s) that were designed for Unix tried to use as few bytes as possible. Thus the number of bytes spend on file administration inside a directory was kept low. And thus not much onformation can be stored there. We suffer from this until this very day: no “hidden” attribute, no “file type” information and more. When a hidden attribute was needed (as painted above) “they” ((the early Unix developers) decided for the . as start character. And then adapted the tools accordingly (the first one to think of is of course ls). It is not something of the system (the Kernel hasn;'t the concept), but it is a convention. And the designers of file managers like Dolphin keep to the convention.

For the file type information also a bad solution was found: the magic number (See Magic number (programming) - Wikipedia, the free encyclopedia
MS-DOS tried to do a little bit better here, having a “hidden” atribute and having a sepeartee field calld “extension” of three characters for file type information. But the latter isn’t realy functioning because there is no central authority to define them.

But “extenstions” seem to have spread to the Unix/Linux world, where they have no real meaning. Technicaly they are only the last few characters of a file name. People may use them to help themselves in deciding what a file may contain (there are even people making an ending of .sh to files that contain shell scripts of some sort, lest they forget.). And there are applications that either are hardcoded, or can be configured, to do special things on file names that end with a special character combination. Often never checking if the contents is of that type (by e.g. reading the magic number).

MIME-types are not realy Unix/Linux either. There is no MIME type stored with your files to tell what they are. MIME-types are an Internet thing. They are send in protocols to tell what sort of file is following.

An operating system that realy tried to have a lot of information about a file in it’s file systems is VAX-VMS.

Thanks for all the info, it makes more sense now. I think the . operator should always stay there for backward compatibility of course, but wouldn’t mind seeing a new form of hiding stuff as well (like a parameter). Still finding out what mime types are… I thought they’re information / flags embedded into the file as an alternative to having an extension.

I’d say that is not entirely accurate. From the beginning, “file.c” was source code, “file.o” was compile but not linked object code.

The operating system itself does not assign a meaning. That is left to users and applications. But that kind of use of extensions didn’t spread to the unix world - it was there from the beginning.

I admit that some of those “endings” (of one character only) where used from the beginning and that applications (like compilers) used them. But they weren’t called “extensions”.

On 2012-09-30 21:26, MirceaKitsune wrote:
>
> Still finding out what mime types are… I thought they’re
> information / flags embedded into the file as an alternative to having
> an extension.

No, they are strings sent from webservers and other internet services.

Lookup the command “file”, find out how it works.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

On 2012-09-30 22:36, hcvv wrote:
>
> nrickert;2492152 Wrote:
>> I’d say that is not entirely accurate. From the beginning, “file.c” was
>> source code, “file.o” was compile but not linked object code.
>>
>> The operating system itself does not assign a meaning. That is left to
>> users and applications. But that kind of use of extensions didn’t
>> spread to the unix world - it was there from the beginning.
> I admit that some of those “endings” (of one character only) where used
> from the beginning and that applications (like compilers) used them. But
> they weren’t called “extensions”.

There are file browsers that look at the extensions for file types, not at the actual contents.
For example, midnight commander. And konqueror or nautilus, I think.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Ouch… I hope that doesn’t mean I need an internet connection all the time for Linux to recognize mime types. eg: For Dolphin to know that a file without an extension is an image, or a video, or what it is. That would be really annoying on laptops at least.

On 09/30/12 08:08, Carlos E. R. pecked at the keyboard and wrote:
> On 2012-09-30 12:06, MirceaKitsune wrote:
>> More of a general Linux question, but since openSUSE is my distribution
>> I’m asking here. Like I said I’m moving from Windows 7 to SUSE, and
>> inevitably comparing many things on the way. Something I’m slightly
>> confused about is the way Linux chooses to mark hidden files / folders
>> compared to Win. While in Windows you right-click them and mark them as
>> ‘hidden’, in Linux they are marked this way by putting a dot in the file
>> / folder name (eg: “.something” instead of “something”).
> Well, I don’t know. I’m also curious as to why, I just stored the fact as something that is
> different. And executables are marked with a flag instead of an extension. I guess that they
> found out the need to hide files after the flags were designed

Very basic reason is that the normal command “ls” that is used to
display files/folders will not display files/folders that begin with a
“.” therefore making those files “hidden”. Of course the easy work
around was to use the the “-a” argument to override that feature.

HTH

Ken

On 2012-10-01 00:46, MirceaKitsune wrote:

> Ouch… I hope that doesn’t mean I need an internet connection all the
> time for Linux to recognize mime types. eg: For Dolphin to know that a
> file without an extension is an image, or a video, or what it is. That
> would be really annoying on laptops and in some cases.

No, it works with magic - and the word has a special meaning in this context.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

As with:


man magic

Maybe Dolphin learnd a bit since the version I have (4.6.0 on openSUSE 11.4).

drwxr-xr-x  2 henk wij   4096  1 okt 10:50 ./
drwxr-xr-x 33 henk wij   4096  1 okt 10:50 ../
-rw-r--r--  1 henk wij 206310  1 okt 10:50 if.jpeg
henk@boven:~/Documents/test> cp if.jpeg if.gif
henk@boven:~/Documents/test> l
totaal 416
drwxr-xr-x  2 henk wij   4096  1 okt 10:50 ./
drwxr-xr-x 33 henk wij   4096  1 okt 10:50 ../
-rw-r--r--  1 henk wij 206310  1 okt 10:50 if.gif
-rw-r--r--  1 henk wij 206310  1 okt 10:50 if.jpeg
henk@boven:~/Documents/test> file *
if.gif:  JPEG image data, JFIF standard 1.01
if.jpeg: JPEG image data, JFIF standard 1.01
henk@boven:~/Documents/test> 

As you see the file tool sees it correct (because it reads in the file and finds the magic numbers).

Using Dolphin and hovering over the two, it tells me that if.gif is GIF image >:)

You completly misunderstand this. As I said, Linux does NOT use MIME-types. MIME types are strings telling what category/subtype a file contains when that file is send over the internet. That is e.g. when mail is send, or when a browser gets a file from a webserver. It is extra information addding to a file when the file is send. It has nothing to do with a file sitting on your Linux system. Only thing you could do (but that is you, not the system) is adding a second file somewhere corresponding to every file you have, contaning it’s MIME type. Some apllications might do that internaly (I do not know).

Thus when you ask an URL from a webserver, inside the HTTP protocol. the server will tell the browser that it is on the brink of sending a file and that the file is of MIME-type text/html. Thus the browser now knows how to interprete the file that is going to arrive (rendering it according to the HTML standards on the screen).

Same for e-mail. When the mail server sends a multi-part mail to a mail client, it will e.g. say: the following is an image/jpeg. Now your mail program knows what to do with it (e.g. presenting an icon on the screen for you so you can open that image by clicking on that icon, and when you click, the mail program will start some JPEG interpreter to show you the image).

Am 01.10.2012 11:06, schrieb hcvv:
>
> Maybe Dolphin learnd a bit since the version I have (4.6.0 on
> openSUSE 11.4).
No, it learned nothing, I did a similar test yesterday with KDE 4.9.1
and dolphin does not look at the magic number only the extension, it
also uses the wrong application then to open the file on click.


PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.2 x86_64 | i3@2.30GHz | 8GB | KDE 4.9.1 | HD 3000
eCAFE 800: oS 12.2 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10

Am 01.10.2012 11:16, schrieb hcvv:
> Only thing you
> could do (but that is you, not the system) is adding a second file
> somewhere corresponding to every file you have, contaning it’s MIME
> type.
That would not be the case (the need to add the info in extra files), if
our applications would just make use of the extended attributes
available on every linux file system.


setfattr -n user.mime_type -v "application/xml" test.xml
getfattr -d test.xml
# file: test.xml
user.mime_type="application/xml"

http://www.freedesktop.org/wiki/CommonExtendedAttributes
defines a basic set of such extended attributes, which no application I
know in linuxland seems to use, what a waste of time and effort, instead
every application developer reinvents a way to store metadata in extra
files or databases.
The only exception I know is SELinux which seems to use some extended
attributes in the security namespace.


PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.2 x86_64 | i3@2.30GHz | 8GB | KDE 4.9.1 | HD 3000
eCAFE 800: oS 12.2 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10

Basicaly very admirable. I am afraid that this is not enough standardised to be available in the same way on all types of file systems. Even when we limit ourselves to most mordern ones. In other words, we need a standard body that propagates at least a minimal implementataion, like POSIX did.

Am 01.10.2012 12:36, schrieb hcvv:
> Basicaly very admirable. I am afraid that this is not enough
> standardised to be available in the same way on all types of file
> systems. Even when we limit ourselves to most mordern ones. In other
> words, we need a standard body that propagates at least a minimal
> implementataion, like POSIX did.
>
Well that feature (xattr) exists now for about a decade in linux and is
widely ignored, though even a file system as old as ext2 supports them.
I have not much hope that we see it widely used and standardized soon.
They are available in linux (in a consistent way, least common
denominator is the restriction of 4kB per attribute which is extended in
xfs and reiser to unlimited size) in at least ext2, ext3, ext4, JFS,
ReiserFS, XFS, Btrfs.


PC: oS 12.2 x86_64 | i7-2600@3.40GHz | 16GB | KDE 4.8.4 | GeForce GT 420
ThinkPad E320: oS 12.2 x86_64 | i3@2.30GHz | 8GB | KDE 4.9.1 | HD 3000
eCAFE 800: oS 12.2 i586 | AMD Geode LX 800@500MHz | 512MB | KDE 3.5.10