user1302
user1302

Reputation: 27

Special file being both a symlink and another type of file

I apologize if the question is lame. I am curious to know if there exists some special files that may be both a symbolic link as well as some other type of file? I tried creating a hidden symbolic file and it is possible. So, the file is a symlink as well as hidden (but I am afraid that's not a file type). Now, can I create a file being both a symbolic and some other file type? I'm sorry if I did not frame my question well.

Also, I am unsure if this question is supposed to be posted here. Please move it if necessary. :)

Upvotes: 0

Views: 42

Answers (1)

Wyzard
Wyzard

Reputation: 34563

"Hidden" isn't a file type. In Unix/Linux, the filesystem has no concept of a "hidden" file at all. (By convention, many programs don't show files whose names begin with a dot, but that's just a naming convention implemented at the application layer. As far as the OS is concerned, there's nothing special about a dot at the beginning of a filename.)

File types are things like:

  • Regular file
  • Symbolic link
  • Directory
  • Device file (block or character)
  • Pipe
  • Socket

Each entry in the filesystem can be only one of these types; it wouldn't make sense for something to be more than one. The type determines what happens when you interact with the file (i.e. open it); if you had, say, a symbolic link that was also a directory, what would happen if you tried to read its contents? Would you get the files in the directory, or the contents of whatever the symbolic link pointed to?

Upvotes: 1

Related Questions