从 Linux 创建隐藏的 Windows 文件/文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2967865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create Hidden Windows file/folder from Linux
提问by what4893
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.
是否可以在安装的 SMB 共享上创建一个对 Windows 隐藏的文件?.(dot) 前缀在这种情况下不起作用,因为它只适用于 Linux。基本上我正在寻找与attrib +h
在 Windows 上使用相同的效果,但在 Linux 下。
回答by lewiguez
Try setting the executable-by-others bit in the file you want hidden. For example:
尝试在要隐藏的文件中设置其他人可执行文件位。例如:
- rwxrwxrw- <-- The file will not be hidden
- rwxrwxrwx <-- HIDDEN
- rwxrwxrw- <-- 文件不会被隐藏
- rwxrwxrwx <-- 隐藏
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.
希望这有帮助。顺便说一下,如果您希望 Windows 隐藏属性应用于您的 Linux 共享,则必须在 samb.conf 文件中设置 map hidden = yes。
回答by Kurt Pfeifle
Assuming your Samba share currently looks like this in smb.conf
:
假设您的 Samba 共享当前如下所示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.
该hide files
指令会将所有指定的文件变成不可见的文件(但它们仍然可以访问!)。DOS 的“隐藏”属性适用于任何匹配的文件或目录。
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.
在上面的示例中,第 2 行文件被明确命名(一个 .doc 和一个 .pdf)以隐藏,以及所有“点”文件和所有 .xls 文件。
Notes on using hide files
:
使用注意事项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 -
- 文件名以“/”分隔
- 文件名可能包含空格(但不能包含“/”)
- 文件名区分大小写
- 你可以使用“?” 和文件名的“*”通配符 -
回答by user2921947
you can just use setmode filename +h
你可以只使用 setmode 文件名 +h