-
Yaml Merge Multiple Maps
--- - &CENTER { x: 1, y: 2 } - &LEFT { x: 0, y: 2 } - &BIG { r: 10 } - &SMALL { r: 1 } # All the following maps are equal: - # Explicit keys x: 1 y: 2 r: 10 label: center/big - # Merge one map << : *CENTER r: 10 label: center/big - # Merge multiple maps << : [ *CENTER, *BIG ] label: center/big - # Override << : [ *BIG, *LEFT, *SMALL ] x: 1 label: center/big
https://yaml.org/type/merge.html
related issues
-
新观念
看到一个新观念,会觉得很有意思。
像“未来简史“里面说,普通人知道自己难免一死,所以愿意冒险做一些危险的尝试,但长生的人会更怕冒险,万一出了意外,代价会特别大。
这个观点,可以安慰自己这种普通人。。
-
梦
昨天梦到电子书的屏被压碎了。想到是7天无理由退货(其实压碎也不能退了,谁让是梦里呢)的最后几分钟了。赶紧拿出手机想退货。
可是APP改版了,我怎么也找不到订单在哪里,那种梦里面着急的感觉啊,你能体会到吗?
然后醒了,想到刚刚的梦,想到电子书还好好的。一下子开心轻松了。
-
Smartctl Output Analyze
输出如下:
# smartctl -aj /dev/bus/0 -d megaraid,10 { "json_format_version": [ 1, 0 ], "smartctl": { "version": [ 7, 2 ], "svn_revision": "5155", "platform_info": "x86_64-linux-5.14.0-162.23.1.el9_1.x86_64", "build_info": "(local build)", "argv": [ "smartctl", "-aj", "/dev/bus/0", "-d", "megaraid,10" ], "messages": [ { "string": "Warning: This result is based on an Attribute check.", "severity": "warning" } ], "exit_status": 68 }, "device": { "name": "/dev/bus/0", "info_name": "/dev/bus/0 [megaraid_disk_10] [SAT]", "type": "sat+megaraid,10", "protocol": "ATA" }, "model_name": "HUH721010ALE600", "serial_number": "JEJPJDPN", "wwn": { "naa": 5, "oui": 3274, "id": 10333059174 }, "firmware_version": "T3C0", "user_capacity": { "blocks": 19532873728, "bytes": 10000831348736 }, "logical_block_size": 512, "physical_block_size": 4096, "rotation_rate": 7200, "form_factor": { "ata_value": 2, "name": "3.5 inches" }, "trim": { "supported": false }, "in_smartctl_database": false, "ata_version": { "string": "ACS-2, ATA8-ACS T13/1699-D revision 4", "major_value": 1020, "minor_value": 41 }, "sata_version": { "string": "SATA 3.2", "value": 255 }, "interface_speed": { "max": { "sata_value": 14, "string": "6.0 Gb/s", "units_per_second": 60, "bits_per_unit": 100000000 }, "current": { "sata_value": 3, "string": "6.0 Gb/s", "units_per_second": 60, "bits_per_unit": 100000000 } }, "local_time": { "time_t": 1750070060, "asctime": "Mon Jun 16 18:34:20 2025 CST" }, "smart_status": { "passed": true }, "ata_smart_data": { "offline_data_collection": { "status": { "value": 130, "string": "was completed without error", "passed": true }, "completion_seconds": 93 }, "self_test": { "status": { "value": 0, "string": "completed without error", "passed": true }, "polling_minutes": { "short": 2, "extended": 1250 } }, "capabilities": { "values": [ 91, 3 ], "exec_offline_immediate_supported": true, "offline_is_aborted_upon_new_cmd": false, "offline_surface_scan_supported": true, "self_tests_supported": true, "conveyance_self_test_supported": false, "selective_self_test_supported": true, "attribute_autosave_enabled": true, "error_logging_supported": true, "gp_logging_supported": true } }, "ata_sct_capabilities": { "value": 61, "error_recovery_control_supported": true, "feature_control_supported": true, "data_table_supported": true }, "ata_smart_attributes": { "revision": 16, "table": [ { "id": 1, "name": "Raw_Read_Error_Rate", "value": 100, "worst": 79, "thresh": 16, "when_failed": "", "flags": { "value": 11, "string": "PO-R-- ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": true, "event_count": false, "auto_keep": false }, "raw": { "value": 0, "string": "0" } }, { "id": 2, "name": "Throughput_Performance", "value": 134, "worst": 100, "thresh": 54, "when_failed": "", "flags": { "value": 5, "string": "P-S--- ", "prefailure": true, "updated_online": false, "performance": true, "error_rate": false, "event_count": false, "auto_keep": false }, "raw": { "value": 96, "string": "96" } }, { "id": 3, "name": "Spin_Up_Time", "value": 155, "worst": 100, "thresh": 24, "when_failed": "", "flags": { "value": 7, "string": "POS--- ", "prefailure": true, "updated_online": true, "performance": true, "error_rate": false, "event_count": false, "auto_keep": false }, "raw": { "value": 34386280890, "string": "442 (Average 405)" } }, { "id": 4, "name": "Start_Stop_Count", "value": 100, "worst": 100, "thresh": 0, "when_failed": "", "flags": { "value": 18, "string": "-O--C- ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": false }, "raw": { "value": 27, "string": "27" } }, { "id": 5, "name": "Reallocated_Sector_Ct", "value": 100, "worst": 100, "thresh": 5, "when_failed": "", "flags": { "value": 51, "string": "PO--CK ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 7, "name": "Seek_Error_Rate", "value": 100, "worst": 100, "thresh": 67, "when_failed": "", "flags": { "value": 11, "string": "PO-R-- ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": true, "event_count": false, "auto_keep": false }, "raw": { "value": 0, "string": "0" } }, { "id": 8, "name": "Seek_Time_Performance", "value": 128, "worst": 100, "thresh": 20, "when_failed": "", "flags": { "value": 5, "string": "P-S--- ", "prefailure": true, "updated_online": false, "performance": true, "error_rate": false, "event_count": false, "auto_keep": false }, "raw": { "value": 18, "string": "18" } }, { "id": 9, "name": "Power_On_Hours", "value": 93, "worst": 93, "thresh": 0, "when_failed": "", "flags": { "value": 18, "string": "-O--C- ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": false }, "raw": { "value": 54075, "string": "54075" } }, { "id": 10, "name": "Spin_Retry_Count", "value": 100, "worst": 100, "thresh": 60, "when_failed": "", "flags": { "value": 19, "string": "PO--C- ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": false }, "raw": { "value": 0, "string": "0" } }, { "id": 12, "name": "Power_Cycle_Count", "value": 100, "worst": 100, "thresh": 0, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 23, "string": "23" } }, { "id": 22, "name": "Unknown_Attribute", "value": 100, "worst": 100, "thresh": 25, "when_failed": "", "flags": { "value": 35, "string": "PO---K ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": false, "event_count": false, "auto_keep": true }, "raw": { "value": 100, "string": "100" } }, { "id": 192, "name": "Power-Off_Retract_Count", "value": 99, "worst": 99, "thresh": 0, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 2119, "string": "2119" } }, { "id": 193, "name": "Load_Cycle_Count", "value": 99, "worst": 99, "thresh": 0, "when_failed": "", "flags": { "value": 18, "string": "-O--C- ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": false }, "raw": { "value": 2119, "string": "2119" } }, { "id": 194, "name": "Temperature_Celsius", "value": 240, "worst": 166, "thresh": 0, "when_failed": "", "flags": { "value": 2, "string": "-O---- ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": false, "auto_keep": false }, "raw": { "value": 154620264473, "string": "25 (Min/Max 22/36)" } }, { "id": 196, "name": "Reallocated_Event_Count", "value": 100, "worst": 100, "thresh": 0, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 197, "name": "Current_Pending_Sector", "value": 100, "worst": 100, "thresh": 0, "when_failed": "", "flags": { "value": 34, "string": "-O---K ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": false, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 198, "name": "Offline_Uncorrectable", "value": 100, "worst": 100, "thresh": 0, "when_failed": "", "flags": { "value": 8, "string": "---R-- ", "prefailure": false, "updated_online": false, "performance": false, "error_rate": true, "event_count": false, "auto_keep": false }, "raw": { "value": 0, "string": "0" } }, { "id": 199, "name": "UDMA_CRC_Error_Count", "value": 200, "worst": 200, "thresh": 0, "when_failed": "", "flags": { "value": 10, "string": "-O-R-- ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": true, "event_count": false, "auto_keep": false }, "raw": { "value": 0, "string": "0" } } ] }, "power_on_time": { "hours": 54075 }, "power_cycle_count": 23, "temperature": { "current": 25 }, "ata_smart_error_log": { "summary": { "revision": 1, "count": 170, "logged_count": 5, "table": [ { "error_number": 170, "lifetime_hours": 51289, "completion_registers": { "error": 64, "status": 67, "count": 0, "lba": 0, "device": 0 }, "error_description": "Error: UNC at LBA = 0x00000000 = 0", "previous_commands": [ { "registers": { "command": 96, "features": 0, "count": 8, "lba": 6835712, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184204448, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 8, "count": 64, "lba": 4583992, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184197528, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 97, "features": 0, "count": 208, "lba": 5204480, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184197527, "command_name": "WRITE FPDMA QUEUED" }, { "registers": { "command": 97, "features": 0, "count": 200, "lba": 5203968, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184197527, "command_name": "WRITE FPDMA QUEUED" }, { "registers": { "command": 97, "features": 0, "count": 192, "lba": 5203456, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184197527, "command_name": "WRITE FPDMA QUEUED" } ] }, { "error_number": 169, "lifetime_hours": 51289, "completion_registers": { "error": 64, "status": 67, "count": 0, "lba": 0, "device": 0 }, "error_description": "Error: UNC at LBA = 0x00000000 = 0", "previous_commands": [ { "registers": { "command": 96, "features": 0, "count": 0, "lba": 6834688, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184197219, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 16, "count": 168, "lba": 8960, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184190292, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 16, "count": 160, "lba": 8992, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184190292, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 8, "count": 152, "lba": 9176, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184190292, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 24, "count": 144, "lba": 9136, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184190292, "command_name": "READ FPDMA QUEUED" } ] }, { "error_number": 168, "lifetime_hours": 51289, "completion_registers": { "error": 64, "status": 67, "count": 0, "lba": 0, "device": 0 }, "error_description": "Error: UNC at LBA = 0x00000000 = 0", "previous_commands": [ { "registers": { "command": 96, "features": 0, "count": 0, "lba": 6834176, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184189985, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 97, "features": 8, "count": 120, "lba": 8395496, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184189538, "command_name": "WRITE FPDMA QUEUED" }, { "registers": { "command": 97, "features": 8, "count": 112, "lba": 8413448, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184189538, "command_name": "WRITE FPDMA QUEUED" }, { "registers": { "command": 97, "features": 8, "count": 104, "lba": 8529864, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184189538, "command_name": "WRITE FPDMA QUEUED" }, { "registers": { "command": 97, "features": 8, "count": 96, "lba": 4206856, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2184189538, "command_name": "WRITE FPDMA QUEUED" } ] }, { "error_number": 167, "lifetime_hours": 51289, "completion_registers": { "error": 64, "status": 67, "count": 0, "lba": 0, "device": 0 }, "error_description": "Error: UNC at LBA = 0x00000000 = 0", "previous_commands": [ { "registers": { "command": 96, "features": 0, "count": 248, "lba": 15501824, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183755972, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 0, "count": 240, "lba": 9019904, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183748858, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 0, "count": 232, "lba": 9019392, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183748858, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 0, "count": 224, "lba": 9018880, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183748858, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 0, "count": 216, "lba": 9018368, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183748858, "command_name": "READ FPDMA QUEUED" } ] }, { "error_number": 166, "lifetime_hours": 51289, "completion_registers": { "error": 64, "status": 67, "count": 0, "lba": 0, "device": 0 }, "error_description": "Error: UNC at LBA = 0x00000000 = 0", "previous_commands": [ { "registers": { "command": 96, "features": 0, "count": 168, "lba": 15501824, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183748397, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 32, "count": 136, "lba": 7669728, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183741474, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 224, "count": 64, "lba": 8783872, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183741474, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 80, "count": 136, "lba": 4948536, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183741473, "command_name": "READ FPDMA QUEUED" }, { "registers": { "command": 96, "features": 0, "count": 64, "lba": 7647680, "device": 64, "device_control": 0 }, "powerup_milliseconds": 2183741462, "command_name": "READ FPDMA QUEUED" } ] } ] } }, "ata_smart_self_test_log": { "standard": { "revision": 1, "table": [ { "type": { "value": 2, "string": "Extended offline" }, "status": { "value": 0, "string": "Completed without error", "passed": true }, "lifetime_hours": 18 }, { "type": { "value": 1, "string": "Short offline" }, "status": { "value": 0, "string": "Completed without error", "passed": true }, "lifetime_hours": 2 } ], "count": 2, "error_count_total": 0, "error_count_outdated": 0 } }, "ata_smart_selective_self_test_log": { "revision": 1, "table": [ { "lba_min": 0, "lba_max": 0, "status": { "value": 0, "string": "Not_testing" } }, { "lba_min": 0, "lba_max": 0, "status": { "value": 0, "string": "Not_testing" } }, { "lba_min": 0, "lba_max": 0, "status": { "value": 0, "string": "Not_testing" } }, { "lba_min": 0, "lba_max": 0, "status": { "value": 0, "string": "Not_testing" } }, { "lba_min": 0, "lba_max": 0, "status": { "value": 0, "string": "Not_testing" } } ], "flags": { "value": 0, "remainder_scan_enabled": false }, "power_up_scan_resume_minutes": 0 } }
分析如下
我们首先看一下硬盘的基本信息: 型号:HUH721010ALE600 序列号:JEJPJDPN 容量:10,000,831,348,736 字节(约10TB) 接口:SATA 3.2, 6.0 Gb/s 转速:7200 RPM 使用时间:54075 小时(约6.17年) 通电次数:23次 关键点分析: SMART状态:passed: true,表示SMART总体状态通过。 关键属性: Reallocated_Sector_Ct (ID 5): 原始值=0,表示没有重映射扇区。 Current_Pending_Sector (ID 197): 原始值=0,表示没有等待重映射的扇区。 Offline_Uncorrectable (ID 198): 原始值=0,表示没有离线无法修复的扇区。 UDMA_CRC_Error_Count (ID 199): 原始值=0,表示没有接口通信错误。 以上都是非常关键的健康指标,目前都为0,是良好的状态。 其他属性: Raw_Read_Error_Rate (ID 1): 原始值为0,正常。 Spin_Up_Time (ID 3): 原始值较大,但显示字符串为"442 (Average 405)",说明自检的旋转时间在正常范围。 Start_Stop_Count (ID 4): 27次,通电次数23次,说明有几次可能是意外断电?但次数不多,且属性值100(最好100)正常。 Power_Cycle_Count (ID 12): 23次,与通电次数一致。 Power_Off_Retract_Count (ID 192): 2119次,这个属性表示磁头因意外断电而缩回的次数。通常这个值应该和通电次数接近,但这里通电次数只有23次,而磁头缩回次数达到2119次,这可能意味着硬盘经常意外断电(比如突然断电),或者是因为RAID卡频繁进行重置?需要关注。 Load_Cycle_Count (ID 193): 2119次,这个值通常表示磁头加载/卸载次数,对于台式机硬盘,设计值通常为30万到60万次,所以2119次不算高,但需要结合其他情况看。 Temperature_Celsius (ID 194): 当前温度为25°C,最高36°C,最低22°C,温度控制良好。 错误日志: 在ata_smart_error_log中,我们看到有5条错误记录(error_number从166到170),这些错误都发生在大约51289小时前(注意当前是54075小时,也就是大约2790小时前,约116天前)。 所有错误都是“UNC”(Uncorrectable Error)错误,发生在LBA 0(可能是日志记录问题,实际LBA可能不同)的读取操作中,错误发生时执行的命令都是FPDMA QUEUED(即NCQ读写)。 这些错误发生在51289小时,而当前已经54075小时,说明是过去发生的错误,而且没有新的错误发生。但是,为什么会有5次读取错误?这可能是因为当时有介质错误或者传输问题,但后续可能已经通过重试成功,或者没有再次发生。 自检日志: 最后一次自检是扩展自检(Extended offline)在18小时(从开始使用算起)完成且无错误,短自检在2小时时完成无错误。但注意,这些自检是很久之前做的(因为使用时间已经5万多小时),所以建议近期再做一次自检。 注意事项: 硬盘已经使用了超过5.4万小时,虽然关键属性都正常,但需要注意备份重要数据,因为任何硬盘在这个使用时间后风险都会增加。 错误日志中记录的错误虽然发生在过去,但也说明硬盘曾经出现过读取错误,这可能是一个早期警告。建议关注后续是否有新的错误出现。 另外,关于192属性(Power-Off_Retract_Count)和193属性(Load_Cycle_Count)都是2119次,而通电次数只有23次,这个比例很奇怪。通常,每次通电可能会有多次磁头加载/卸载,但2000多次相对于23次通电,平均每次通电要发生90多次,这有些偏高。可能的原因是硬盘经常进入节能模式(磁头缩回),或者是RAID卡频繁重置导致。虽然这个值本身并不代表故障,但频繁的磁头加载/卸载会消耗硬盘的机械寿命。 结论: 这块硬盘目前从SMART数据上看是健康的,但是使用时间已经很长(6年多),并且过去发生过读取错误,磁头缩回次数相对通电次数偏高。建议: - 运行一次完整的SMART自检(长测试)以确认当前状态。 - 密切关注硬盘的SMART数据变化,特别是重映射扇区和待处理扇区的数量。 - 确保重要数据已经备份,因为机械硬盘在长时间使用后故障率会上升。 - 如果可能,检查电源或RAID卡设置,以减少意外断电或硬盘重置的情况。 注意:由于该硬盘不在smartctl数据库(in_smartctl_database: false),一些属性(如ID 22)是未知属性,但我们分析的关键属性都是已知且正常的。
-
Disk State In Storcli
总结一下,在storcli64 /c0 show all的磁盘列表中,常见的物理磁盘状态有:
Onln: 在线(通常指已配置在虚拟磁盘中且正常工作) UGood: 未配置但良好 JBOD: 配置为直通磁盘 GHS: 全局热备 DHS: 专用热备 UBad: 未配置但故障 Offln: 离线(故障) Msng: 缺失 Rbld: 重建中 Pdgd: 预测故障(即将失效) Frn: 外来磁盘(带有其他控制器的配置)
-
马来西亚-流水帐
6.1 凌晨1点飞吉隆坡,上午7点到达。
和曾可他们联系了好一会,怎么都找不到对方,发现不在一个航站楼。。
打车到酒店,寄存下行李(发现自己英语啥也听不懂),走去双子塔吃饭,一家网红餐厅,还不错。
然后打车去Best榴莲,吃了一个拼盘,然后又买了两个整个的。味道不错。价格比后面的沙巴以及国内便宜很多。
回酒店睡觉。晚8点,去夜市吃个海鲜。
吃完去双子塔看夜景,拍照。
6.2 上午飞亚庇,入住后,打车去网红餐厅,但关门了。就去了边上一家。吃完去订了后天的环滩岛。
然后去游泳池,泡一会,一边打游戏,一边等日落。
晚上去金潮海鲜吃饭,皮皮虾很大,也很贵。
6.3 上午无事,中午去另一家网红餐厅吃饭,结果还是关门。隔壁有家排着长队,感觉不错,进去吃了。味道一般。
下午海钓。船上晚餐。
然后去天桥下榴莲街。小摊不行,都骗人的。榴莲仔还行,就是价格和味道都不如吉隆坡。
6.4 没起来,环滩岛没去成。曾可他们去了。
我们中午吃了第一天想去的网红餐厅,然后按摩,再去咖啡店。
等曾可他们回来,去吃了最后一顿海鲜,敬文。价格美丽,味道也不错。
旁边有个榴莲摊,味道和价格都比榴莲仔略好一点。吃了两个。
-
Remove 200b In Vim
:%s/\%u200b//g
-
Sticky Permission
在 Linux 系统中,目录的 sticky 权限(sticky bit)是一种特殊的权限设置,主要用于控制目录内文件的删除或重命名权限。它的核心特点是:即使目录对所有用户开放了写权限,也只有特定用户(文件所有者、目录所有者或 root)才能删除或重命名目录中的文件。
定义与作用
粘滞位(Sticky Bit) 是一种目录级权限,用 t 表示。
核心作用:保护目录中的文件不被任意用户删除,即使这些用户对目录有写权限。
典型场景:多用户共享的临时目录(如 /tmp),用户可以在其中创建文件,但无法删除他人的文件。
与普通目录权限的对比
假设目录权限为 drwxrwxrwt(sticky 位启用):
普通目录权限(如 drwxrwxrwx):
若用户对目录有写权限(w),则可以删除或重命名目录中的任何文件(即使文件不属于该用户)。
启用 sticky 位的目录(drwxrwxrwt):
即使用户对目录有写权限,只有以下用户可以删除或重命名文件:
文件的所有者 目录的所有者 root 用户
如何设置/取消 sticky 位
设置 sticky 位: chmod +t 目录名 # 或通过八进制模式(1000 是 sticky 位的值) chmod 1777 目录名 取消 sticky 位: chmod -t 目录名 # 或通过八进制模式 chmod 0777 目录名
典型示例
场景:共享临时目录 /tmp
默认权限:
ls -ld /tmp # 输出:drwxrwxrwt root root ...
效果:
用户 A 在 /tmp 中创建文件
file_a
。用户 B 无法删除
file_a
,即使对 /tmp 有写权限。只有用户 A、root 或 /tmp 的所有者(root)可以删除 file_a。
注意事项
仅对目录有效:
sticky 位对文件无效(文件的 t 权限无实际意义)。
不影响文件内容修改:
用户仍可以修改自己拥有的文件内容(如写入数据),但不能删除或重命名文件。
与 ACL 的区别:
sticky 位是粗粒度的权限控制,而 ACL(访问控制列表)可实现更细粒度的权限管理。
查看 sticky 位
使用 ls -ld 命令查看目录权限:
ls -ld /tmp # 输出:drwxrwxrwt root root ... # 最后一位 `t` 表示 sticky 位已启用
常见问题
Q1:为什么 /tmp 需要 sticky 位? A:防止用户误删或恶意删除他人的临时文件,同时允许所有人在目录中创建文件。
Q2:如果忘记设置 sticky 位会怎样? A:例如,若 /tmp 的权限为 drwxrwxrwx,任何用户都可以删除他人的临时文件,导致安全隐患。
Q3:sticky 位和 chattr +i(不可修改属性)有何区别? A:
sticky 位:仅限制删除/重命名操作,不影响文件内容修改。 chattr +i:完全锁定文件(禁止删除、修改、重命名等),需 root 权限设置。 总结 目录的 sticky 权限(t)是一种保护机制,确保多用户环境下共享目录的安全性。它在需要临时文件共存但不允许随意删除的场景(如 /tmp)中至关重要。使用时需注意其作用范围(仅目录)和权限设置的合理性。
-
Bpftrace Block Dev
#!/usr/bin/env bpftrace tracepoint:block:block_rq_issue / args->dev == (uint32)((8<<20)+144) / // 8:144 对应 /dev/sdj 的主/次设备号 { printf("%-6d %-16s %-6d\n",pid,comm,args->dev); }
-
Bpftrace Hang
解决方法:
export DEBUGINFOD_URLS=""
通过 strace 看到 connect(106, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr(“18.219.164.54”)}, 16) = -1 EINPROGRESS (Operation now in progress)
浏览器里面访问 18.219.164.54,看到报错
This server couldn’t prove that it’s 18.219.164.54; its security certificate is from debuginfod.centos.org. This may be caused by a misconfiguration or an attacker intercepting your connection.
- •
- 1
- 2