2

I connect to a Samba drive in terminal (Linux) via smbclient. When I list the directory via command ls, I get for every entry (file or folder) some letters: such as D, H, R, S, A in different combinations DHR, DHS, DR, and so on.

As example

  smb:> ls

  Start Menu                        DHS        0  Mon Oct  5 16:08:57 2020
  Saved Games                        DR        0  Mon Oct  5 16:55:45 2020
  Sti_Trace.log                       A        0  Thu Oct 31 11:08:40 2019
  Materials                           D        0  Fri Mar 15 12:15:58 2019
  Mydoc.docx                          A    15047  Fri Jan 13 12:42:42 2017
  ntuser.ini                         HS       20  Mon Oct  5 16:55:37 2020

I have realized that A is for files and D for directories, but the other meanings I cannot guess. Could you give me a reference to the meaning of such letters? I've been some time searching with no result and when I enter help ls I get a quite succinct answer :-\

smb: \> help ls
HELP ls:
    <mask> list the contents of the current directory

Thanks in advance!

5

This column directly corresponds to standard Windows file attributes (aka DOS attributes or FAT attributes), as seen in the Windows and MS-DOS ATTRIB commands. Most of those are also visible in Windows "File properties" dialogs.

The primary attributes are "Archive", "Directory", "Read-only", "Hidden", "System":

  • A (Archive) is only used by backup programs (including xcopy/robocopy). Such tools clear it when making a copy, and the OS automatically sets it again whenever the file changes, which avoids the need to compare modification times.

  • D (Directory) is not changeable and just indicates that the entry is a directory.

  • R (Read-only) makes the file read-only.

    For directories, it doesn't do anything at OS-level, but indicates to Windows Explorer that the directory might have a custom icon or other settings (i.e. indicates that Explorer should read the desktop.ini file).

  • H (Hidden) hides the file from regular listings; Windows uses this attribute instead of "dot" files. Apparently smbclient does not care.

  • S (System) hides the file slightly more, and causes Windows Explorer to warn before doing anything with the file. Apparently it also used to indicate to Windows 9x and MS-DOS that the file should not be moved physically. (For directories, it's similar to +R.)

(Files on NTFS can have quite a few more attributes, but most of those are not exposed via SMB file sharing anyway – they're only accessible through local use of the ATTRIB command or corresponding APIs.)

| improve this answer | |
  • R set on a directory may (depending on Windows version and whether inheritance is set) cause files to default to being read-only. – Jeff Zeitlin Oct 26 at 11:45
  • Generally inheritance applies only to ACLs, not to file attributes. You can have an inheritable NTFS ACL which makes files read-only through denying write permission, but it still shouldn't cause the +R attribute to be set. (MS docs just outright say it's not honored on directories, with no mention of it being inherited, and I strongly doubt that it would have been allowed to happen when Windows already uses +R on directories for a different purpose – it'd result in a lot of accidental read-only files...) – user1686 Oct 26 at 11:47
  • @user1686 you cannot even set +r on folders in windows. It really is ignored. Attrib will not change it, and indeed there's no inheritence. setting ACL does not alter the attributes of files and folders. – LPChip Oct 26 at 12:02
  • @LPChip: You can certainly set it on directories. (Strangely, it does prevent 'rmdir' despite other docs saying it's ignored, though I haven't looked into whether it's a real error that comes from the OS or whether it's just made up by CMD.) Windows Explorer also sets it whenever you customize the folder icon or something else that involves the desktop.ini file, so it's not like the OS will refuse that. – user1686 Oct 26 at 12:18
  • 1
    It doesn't when you try to use the checkbox. It does when you customize the folder. – user1686 Oct 26 at 12:43

Your Answer

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

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