Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
Samba version 2:3.4.0-3ubuntu5.5 on Ubuntu 9.10 – Matti Mar 20 '10 at 22:55
1  
Adding "mangled names = no" to smb.conf solved this (thanks, Dennis Williamson). – Matti Mar 23 '10 at 0:25

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:

testparm -vs | less

To narrow that down a bit:

testparm -vs|grep "case\|mangl"

See this page for more information. Also, see about half way down this page (the same information as the previous link).

share|improve this answer

from samba documentation you can use these:

dos charset = ISO8859-1
unix charset = ISO8859-1
display charset = ISO8859-1
share|improve this answer
3  
This and adding mangled names= no to [global] fixed my on nas4free – Christopher Chase Jun 6 '15 at 0:51

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 filename cannot contain any of the following characters:
\ / : * ? " < > |

A bit further down, they wrote:

Characters that are valid for naming files, folders, or shortcuts include any combination of letters (A-Z) and numbers (0-9), plus the following special characters:

^   Accent circumflex (caret)
&   Ampersand
'   Apostrophe (single quotation mark)
@   At sign
{   Brace left
}   Brace right
[   Bracket opening
]   Bracket closing
,   Comma
$   Dollar sign
=   Equal sign
!   Exclamation point
-   Hyphen
#   Number sign
(   Parenthesis opening
)   Parenthesis closing
%   Percent
.   Period
+   Plus
~   Tilde
_   Underscore

But I, personally, took the listing of not-allowed characters as a reference for briefing some customers here ;)

share|improve this answer
  • 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 14.04 "Trusty Tahr" 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, I'm assuming that the Samba server running on OS X is already properly configured...

...but things aren't working the other way around: if I use the Finder app on OS X to access my Linux Samba shares, all files and folders having at least one of those special characters are not shown (they remain invisible to me). And the long names of files and folders are converted in weird short names. Thus, there's 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 the smb.conf file on my Linux machine:

mangled names = no
dos charset = CP850
unix charset = UTF-8

Notes:

  1. In GNU/Linux systems, the standard location of the smb.conf file is /etc/samba/smb.conf
  2. In Samba 3+, the display charset parameter is deprecated.
  3. The dos charset parameter does not support the UTF-8 argument, thus it must be used the default argument CP850.

After that, I restarted the Linux Samba server:

sudo service smbd restart

...and then 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 names were also "unmangled".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.