7

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!

1 Answers1

10

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

grawity
  • 501,077