Originally Posted by BeerBuddy
In Linux I noticed that in some cases it appears that the same directory may have more than one file with the same name.
This is not true. There can always only be a single file with a given name and path. I guarantee you that the filenames you are looking at differ in some way.
To start with, do remember that *nix filenames are case-sensitive. There are also characters that look very similar under certain fonts. And as you've discovered, certain programs can certainly display
the names in different ways. As for extensions, there is no requirement for them in system terms. They are only generally added as a human-interface assist.
To explain it in more detail, at the lowest level a "file" is really just a segment of bits and bytes sitting on a file system, usually a hard disk. *nix-based file systems, and the OS itself, actually track and operate on them by their inode
The file system also provides a way to associate those inodes with human-readable names, organized into a directory "tree". These names are known as hardlinks
. Any given inode can have multiple hardlinks, but each hardlink must point to a unique path location. To put it another way, a file can actually have multiple "names", but each name must be different, and they can't cross over file system boundaries.
So don't be confused by the "link" designation, each hardlink is in fact a direct reference to the file itself. When you "rm
" a filename, you are actually disassociating the hardlink from the inode it refers to. When the last hardlink is removed, the inode is removed as well and the file is "deleted". This is also why we use mv
for renaming files. Moving and renaming files both simply require modifying the hardlinks pointing to them (at least while staying on the same file system).
There are also symlinks
, by the way, which are different from hardlinks in that they are separate, specialized files that reference a hardlink. When the system accesses a symlink, it gets redirected to the actual (hardlink) location that it points to. symlinks can thus pass over file system boundaries, and the target doesn't even have to exist. These are the most similar to Windows shortcuts, but are more flexible and reliable in action.
As for .desktop
files, they are not
links, and they are really no different from any other file. They are just text files that contain specialized configuration options for telling the desktop what to do; e.g. how to display the icon and its associated text, and what commands to execute when that icon is accessed.
Try opening up one in a text editor to see what it contains. The syntax for them can be found here:
It's most likely that your two desktop files both contain configurations that tell the viewing program to display the same name. But of course this only works with viewers that understand .desktop files.
is indeed a synonym for ls
, but it's actually included as a system command (/bin/dir), not as a shell alias. You should probably get in the habit of using the traditional *nix command name though, as most Linux users are not aware of this.