When serving files containing special characters such as "()?:" in the filename through Samba, the names get transformed into an unrecognizable format. For example, a file
my_file:_(important).txt
is displayed as
M43J1E~0.TXT
Is there a way to avoid this behavior (without renaming the files, obviously)? I'm assuming that character encoding is not to blame because several UTF-8 characters seem to work fine.
I own an Apple Macbook Pro laptop with 64-bit OS X 10.11 "El Capitan" running Samba 3 that I installed through Macports.
I also own a Dell Inspiron laptop with 64-bit GNU/Linux XUbuntu 16.04 "Xenial Xerus" running Samba 3 that I installed through APT.
Both machines have network-shared folders and use Samba in order to communicate on my WLAN (wireless LAN).
Both my systems are in Brazilian Portuguese. Thus, I use special characters such as ç, á, ã, â, ô, é, ó et cetera.
When I use my Linux laptop to access my OS X Samba shares, all strings are shown correctly: words like maçã, ônus and bênção are shown correctly. Files and folders with long names are also shown, and their names are shown correctly. Thus, the Samba server running on OS X is already properly configured...
...but things weren't working the other way around: if I used the Finder app on OS X to access my Linux Samba shares, all files and folders having at least one of those special characters were not shown (they remained invisible to me), and the long names of files and folders were converted to weird short names. Thus, there was something wrong with the Samba server running on my Linux machine.
=> In my case, what solved this issue was adding the following lines to the
[global]
section inside thesmb.conf
file on my Linux machine:After that, I opened a shell terminal window and restarted the Linux Samba server with this command:
...which can be replaced by this other command (in case the command above doesn't work on your Linux distribution):
After I restarted the Linux Samba server, the Finder app on OS X finally showed correctly all the files and folders that were previously hidden because of their names having one or more special characters. The mangled ("shortened") names were also "unmangled".
Footnotes:
smb.conf
file is/etc/samba/smb.conf
smb.conf
file stored at the standard location/etc/samba/
: there are several different ways to edit thesmb.conf
file. For instance, if you're not using a Desktop Environment (e.g. your system has only a shell terminal, no windows) you can install the Nano text editor, by issuing a command such assudo apt-get install nano -y
orsudo dnf -b -y install nano
or something else (depending on which Linux distro you are using), and then runsudo nano /etc/samba/smb.conf
. In case you're using a Desktop Environment, you can install a graphical text editor such as GNOME Edit, by issuing a command such assudo apt-get install gedit -y
orsudo dnf -b -y install gedit
or something else (depending on which Linux distro you are using), and then runsudo gedit /etc/samba/smb.conf
.display charset
parameter is deprecated.dos charset
parameter does not support theUTF-8
argument. Thus, it must use the default argumentCP850
.mangled names = no
instructs the Samba server not to shorten long names of files and folders. Hence, because the Samba client just replicates to the user what the Samba server has provided to the client, once the server is properly configured the client will no longer show the user any shortened name.Windows does not allow some characters in filenames that Unix does allow. Samba "mangles" the filenames to make them comply with Windows restrictions. You can check the file
/etc/smb.conf
or/etc/samba/smb.conf
to see what settings are in place. To show those settings plus the defaults, use this command:To narrow that down a bit:
See this page for more information. Also, see about half way down this page (the same information as the previous link).
I use a shared folder on OS-X and Windows. Some files have the same issue, because they fall into the following: They use characters in the file-name, not supported by Windows.
See: http://support.microsoft.com/kb/177506
It lists the characters, not supported by Windows in files or directories. I guess, that Samba uses the same list of characters when listing files and directories.
A bit further down, they wrote:
But I, personally, took the listing of not-allowed characters as a reference for briefing some customers here ;)
from samba documentation you can use these:
Yes, it's the char encoding to blame.
Pass
iocharset=iso8859-1
as an option to mount.cifs or select aniso8859-1 locale
, instead of anutf-8
.You could also try to prepend
LANG=C.ISO8859-1
orLC_ALL=C.ISO8859-1
to your commands, etc.