如何在 Bash 中创建隐藏文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17361792/
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
How to create a hidden file in Bash
提问by sharon Hwk
What is the bash command to create a hidden file. I want to name it .httName.
创建隐藏文件的bash命令是什么。我想命名它.httName。
I have tried googling for this, but none of the forums suggest any work around for this. I am simply looking for the command to solve my issue. If anyone happen to know the answer please help me out.
我曾尝试为此使用谷歌搜索,但没有一个论坛建议对此进行任何解决。我只是在寻找解决我问题的命令。如果有人碰巧知道答案,请帮助我。
回答by kamjagin
Files starting with a dot are by default hidden. You can create it simply by
以点开头的文件默认是隐藏的。你可以简单地创建它
touch .httName
anyone will still be able to see it using
任何人仍然可以使用它看到它
ls -a
If you want files to be properly hidden, you will have to change folder permissions using chmod. For example
如果要正确隐藏文件,则必须使用 chmod 更改文件夹权限。例如
chmod 770 folder_name
will prevent users (except the owner and people in the group) from listing the whole directory "folder_name".
将阻止用户(所有者和组中的人除外)列出整个目录“folder_name”。
回答by Muhammad Rehan Qadri
Any file starting with . in file name is "hidden".
任何以 . 在文件名中是“隐藏的”。
If you've a file and you want to hide it use:
如果您有一个文件并且想隐藏它,请使用:
mv filename.txt .filename.txt
回答by Deva
the file which start with .(dot)filename is always hidden and its used for setting configuration of the application.
In Linux dot files are used for same purpose.Even you are working in current directory lscommand should not display hidden file use lato shoe hideen directories.
以 .(dot)filename 开头的文件总是隐藏的,用于设置应用程序的配置。在 Linux 中点文件用于相同的目的。即使你在当前目录ls下工作,命令也不应该显示隐藏文件用于隐藏la目录。
回答by deviantlamb
Just to go further on the hidden point.
As covered after the creation of a hidden type file .hiddenchanges to the permissions of the file and its parent are advised, especially within a multiuser box.
只是为了在隐藏点上走得更远。在创建隐藏类型文件后,建议.hidden更改文件及其父级的权限,尤其是在多用户框中。
after you : touch .hiddensecure the item with: chmod 600 .hiddenand secure the parent directory: chmod go-w ~/parent/
在您之后:使用以下方法touch .hidden保护项目:chmod 600 .hidden并保护父目录:chmod go-w ~/parent/

