Linux Both Case Sensitive AND Case Insensitive and Always Inconvenient?

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).

6

4 Answers

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.

2

You can enable case-insensitive file name completion in bash by adding the following line to $HOME/.inputrc:

set completion-ignore-case On

Regarding the file names: This depends on the file system. On Linux file systems, there should be no problem. On other file systems, the behavior can be controlled with options to the mount command. See the manual page mount(8) for more information on the available options to mount.

3

Is this a property of the filesystem or something else?

pa-ubuntu-11388$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.3 LTS
Release: 10.04
Codename: lucid
pa-ubuntu-11388$ ls -l
pa-ubuntu-11388$ touch filename.txt
pa-ubuntu-11388$ ls -l
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 filename.txt
pa-ubuntu-11388$ cp ./filename.txt ./FileName.txt
pa-ubuntu-11388$ ls -l
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 FileName.txt
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 filename.txt

It works fine for me.

1

Ubuntu is not partially case sensitive. It's always case sensitive. filename.txt and Filename.txt are two different files and can be placed in the same directory. So this command:

cp ./filename.txt ./FileName.txt

will work without any problem in the same directory.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like