Linux Both Case Sensitive AND Case Insensitive and Always Inconvenient

linuxUbuntuunix

I'm using Ubuntu 10 and I'm quickly finding out that it's case sensitive when it's inconvenient for it to be so (like when autocompleting file paths with tab in terminal) but also case INsensitive when using the MV and CP commands (also inconvenient when trying to duplicate a filename with a different case).

In essence, I need this command to work but it doesn't.

cp ./filename.txt ./FileName.txt

I just end up with filename.txt:

enter image description here

How can I get the same file with a different case but same name in the same directory?

EDIT: Maerics' comment below helped me remember that I'm actually developing on a Windows shared drive running NTFS which is case INsensitive. This is why even though CP and MV don't generate an error, the file isn't copied (or more likely IS copied, but Windows replaces the already existing one).

Best Answer

NTFS1 and VFAT are not case-sensitive, they are just case-preserving. That means if you create a file named FileName.txt, the file system will preserve the mixed case name, but you can access the file with whatever case combination of the same letters, like FILENAME.TXT, filename.txt or fileNAME.txt. This explains you cannot have two files with the same spelling with only a variation of upper/lower case in the same directory.

SMB exported file system have to implement this behavior not to confuse Windows clients.

ZFS can be configured to behave that way with the casesensitivity=mixed property.

1 Technically, NTFS is case sensitive but the OSes mounting file systems of this type are almost always configured to hide this underlying feature and only preserve the case. Windows can however enable case sensitivity with modifying this register key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\dword:ObCaseInsensitive and Linux can mount these file systems with various behaviors depending on the ignore_case and windows_names mount options.

Related Question