Create Hidden Windows file/folder from Linux

女生的网名这么多〃 提交于 2020-01-01 12:37:26

问题


Is it possible to create a file on a mounted SMB share that is hidden from Windows? The .(dot) prefix doesn't work in this case because that only works on Linux. Basically I'm looking for the same affect as using attrib +h on Windows, but under Linux.


回答1:


Try setting the executable-by-others bit in the file you want hidden. For example:

  • rwxrwxrw- <-- The file will not be hidden
  • rwxrwxrwx <-- HIDDEN

Hopefully that helps. If you want the Windows hidden attribute to apply to your Linux share, by the way, you'll have to set map hidden = yes in your samb.conf file.




回答2:


Assuming your Samba share currently looks like this in smb.conf:

[share-with-hidden-files]
  comment = this share shows all files when browsing it (doesn't work as expected)
  path = /some/where/on/the/linux/file/system
  browseable = yes
  [...more settings...] 

Add one more line to it:

[share-with-hidden-files]
  comment = this share includes some hidden files
  path = /some/where/on/the/linux/file/system
  browseable = yes
  [...more settings...] 
  hide files = /firstfile.doc/secondfile.pdf/.*/*.xls/

The hide files instruction will turn all denoted files into invisible ones (but they are still accessible!). The DOS 'hidden' attribute is applied to any files or directories which match.

In above example line 2 files are explicitely named (a .doc and a .pdf) to be hidden, as well as all 'dot'-files and all .xls files.

Notes on using hide files:

  • file names are separated by '/'
  • file names may contain spaces (but no '/')
  • file names are case sensitive
  • you may use '?' and '*' wildcards for filenames -



回答3:


you can just use setmode filename +h



来源:https://stackoverflow.com/questions/2967865/create-hidden-windows-file-folder-from-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!