LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2012, 11:44 PM   #1
BeerBuddy
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
In Linux, How To Determine Real File Name


I am a relatively new Linux user, now running Linux Mint 13, with the Mate desktop.

Having been more familiar with Windows, when I name a file, the name that I give it is the name of the file, and that's it. But I noticed that in Linux the name of a file that you actually see may or may not be the real name of the file.

In Linux I noticed that in some cases it appears that the same directory may have more than one file with the same name. For example, on my computer in the same directory there are two desktop configuration files that appear to have the same name. When I look at these two files the observed name for both files is "BootUp-Manager". That is what I see, both have the name "BootUp-Manager." The extension of the file name is not shown.

If I do a directory listing by going to the directory where both files are located and typing 'dir -1' in a terminal, the directory listing is as follows:

BootUp-Manager.desktop
BootUp-Manager2.desktop

According to the directory listing the files don't really have the same name. The files just appear in Linux to have the same name. They both have the .desktop extension.

If the name displayed in Linux is not the real name, how then can I look at a file, or several files, and determine what the real name is? Is there a way to easily do this, or is doing a 'dir' at a terminal prompt the only way?

Thanks.

BeerBuddy
 
Old 11-01-2012, 11:57 PM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,832
Blog Entries: 36

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
*.desktop files are handled by graphical environments different ways. This is one of the only files I can think of that would have this done. Some Window Managers will literally show you the file name with *.desktop and others will actually view the contents of the *.desktop file and display the Name value under [Desktop Entry].

Cat those desktop files and look at the Name entry or the Name[$lang] entry where $lang is your language code.

Code:
$ cat *.desktop
Now change the value of Name to whatever you want and you'll see the changes reflected in your Window Manager.

Last edited by sag47; 11-01-2012 at 11:59 PM.
 
Old 11-02-2012, 01:00 AM   #3
ofrazier
LQ Newbie
 
Registered: Sep 2006
Location: korea
Distribution: Fedora 10, Fedora 16, Mint 12, DSL, Puppy
Posts: 3

Rep: Reputation: 0
If you are using dir, it must be an alias for the ls command. I would review the ls man page and create an alias that is more suitable to you. The beauty of Linux is you make it do what you want it to be. (Conversely, I typically alias my MS Windows CLI with *NIX commands.)

But remember "...with great power comes great responsibility."

Last edited by ofrazier; 11-02-2012 at 01:02 AM.
 
Old 11-02-2012, 01:29 AM   #4
dudeman41465
Member
 
Registered: Jun 2005
Location: Kentucky
Distribution: Ubuntu
Posts: 794

Rep: Reputation: 56
.desktop files are shortcuts and things of that nature, and have a displayed name that is contained in the file that is what gets displayed on the screen. This is the only exception that I am aware of, all other files should have their actual file name displayed when viewing them in a graphical environment. If you ever want to see what the actual filename of a .desktop file is, just open a terminal, "cd" into the folder where the file is contained, and run the command "ls". It's the same as the "dir" command in Windows, and will display the filenames and not their display names.
 
Old 11-02-2012, 06:13 PM   #5
BeerBuddy
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
In Linux, How To Determine Real File Name

Quote:
Originally Posted by dudeman41465 View Post
.desktop files are shortcuts and things of that nature, and have a displayed name that is contained in the file that is what gets displayed on the screen. This is the only exception that I am aware of, all other files should have their actual file name displayed when viewing them in a graphical environment. If you ever want to see what the actual filename of a .desktop file is, just open a terminal, "cd" into the folder where the file is contained, and run the command "ls". It's the same as the "dir" command in Windows, and will display the filenames and not their display names.
To: dudeman41465

Thanks for the info. Now I understand. Files with the .desktop extension are not actually files but they are shortcuts to files. I am familiar Windows shortcuts. So it really does not matter what you name them. And two of these shortcut .desktop files that display the same name can be located in the same directory. Even though the displayed names are the same, in reality they have different names, which are hidden. (In Windows you can't have two shortcuts with the same name in the same directory; Windows doesn't hide the real name of the shortcut.) In Linux, you can check for the real name of the shortcut with the ls or dir commands. Thanks, I am glad that this only happens with shortcuts that have the .desktop extension. I was confused by all this but now you helped to set me straight.

Thank You!

BeerBuddy
 
Old 11-03-2012, 02:08 PM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Quote:
Originally Posted by BeerBuddy View Post
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 numbers.

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:
http://standards.freedesktop.org/des...ec-latest.html

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.


Finally dir 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.

Last edited by David the H.; 11-03-2012 at 02:28 PM. Reason: added and modified some bits
 
Old 11-04-2012, 01:30 AM   #7
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 806

Rep: Reputation: 186Reputation: 186
Quote:
According to the directory listing the files don't really have the same name. The files just appear in Linux to have the same name. They both have the .desktop extension.
Actually in linux they do have different names.
Quote:
BootUp-Manager.desktop
BootUp-Manager2.desktop
It is actually your GUI that shows them as files of type "BootUp-Manager"

You should see the individual file's properties and check it out.

OK
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine file system in linux vjsh Linux - General 9 03-15-2010 10:42 AM
How to determine the real speed of gigabit network card groxy Linux - Hardware 1 11-30-2007 03:47 PM


All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration