技巧分享:删除并关闭MacOS自动生成的隐藏文件

使用MacOS的时候,会在你打开目录、文件的时候自动生成.DS_Store隐藏文件,这里记录一下如何查找、删除并关闭这个MLY的功能

.DS_Store是Mac操作系统自动生成的隐藏文件,其作用是存储文件夹的特殊信息和自定义设置,例如查看方式、图标大小以及这个目录的一些附属元数据。(并没有什么其他卵用)

.DS_Store隐藏文件在MacOS下默认是看不到,但当你把文件分享出去时候就会带上这些隐藏文件了,如果是需要部署的代码直接上传到生产环境,也可能导致安全问题的。例如,https://github.com/lijiejie/ds_store_exp 这是一个 .DS_Store 文件泄漏利用脚本,它解析.DS_Store文件并递归地下载文件到本地。

ds_store_exp.py http://hd.zj.qq.com/themes/galaxyw/.DS_Store

hd.zj.qq.com/
└── themes
    └── galaxyw
        ├── app
        │   └── css
        │       └── style.min.css
        ├── cityData.min.js
        ├── images
        │   └── img
        │       ├── bg-hd.png
        │       ├── bg-item-activity.png
        │       ├── bg-masker-pop.png
        │       ├── btn-bm.png
        │       ├── btn-login-qq.png
        │       ├── btn-login-wx.png
        │       ├── ico-add-pic.png
        │       ├── ico-address.png
        │       ├── ico-bm.png
        │       ├── ico-duration-time.png
        │       ├── ico-pop-close.png
        │       ├── ico-right-top-delete.png
        │       ├── page-login-hd.png
        │       ├── pic-masker.png
        │       └── ticket-selected.png
        └── member
            ├── assets
            │   ├── css
            │   │   ├── ace-reset.css
            │   │   └── antd.css
            │   └── lib
            │       ├── cityData.min.js
            │       └── ueditor
            │           ├── index.html
            │           ├── lang
            │           │   └── zh-cn
            │           │       ├── images
            │           │       │   ├── copy.png
            │           │       │   ├── localimage.png
            │           │       │   ├── music.png
            │           │       │   └── upload.png
            │           │       └── zh-cn.js
            │           ├── php
            │           │   ├── action_crawler.php
            │           │   ├── action_list.php
            │           │   ├── action_upload.php
            │           │   ├── config.json
            │           │   ├── controller.php
            │           │   └── Uploader.class.php
            │           ├── ueditor.all.js
            │           ├── ueditor.all.min.js
            │           ├── ueditor.config.js
            │           ├── ueditor.parse.js
            │           └── ueditor.parse.min.js
            └── static
                ├── css
                │   └── page.css
                ├── img
                │   ├── bg-table-title.png
                │   ├── bg-tab-say.png
                │   ├── ico-black-disabled.png
                │   ├── ico-black-enabled.png
                │   ├── ico-coorption-person.png
                │   ├── ico-miss-person.png
                │   ├── ico-mr-person.png
                │   ├── ico-white-disabled.png
                │   └── ico-white-enabled.png
                └── scripts
                    ├── js
                    └── lib
                        └── jquery.min.js

21 directories, 48 files

列出所有.DS_Store文件的linux命令

find . -name ".DS_Store" -exec ls -l {} \;

一键删除所有.DS_Store文件的linux命令

find . -name ".DS_Store" -exec rm -rf {} \;

查看Mac某个目录里的所有".DS_Store"

find . -name ".DS_Store" -depth -exec ls {} \;

批量删除Mac某个目录里的所有".DS_Store"

find . -name ".DS_Store" -depth -exec rm {} \;

要彻底禁止Mac自动产生.DS_Store,在Mac终端执行以下的命令然后重启Mac。

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

参考:https://www.zhujimi.net/238.htmlhttps://github.com/lijiejie/ds_store_exp

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值