This commit is contained in:
50
Docs/Linux中如何让目录和文件不能被删除.md
Normal file
50
Docs/Linux中如何让目录和文件不能被删除.md
Normal file
@@ -0,0 +1,50 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Linux中如何让目录和文件不能被删除
|
||||
|
||||
## 如何让文件不能删除
|
||||
|
||||
1. 创建文件
|
||||
|
||||
```bash
|
||||
touch offends.sh
|
||||
```
|
||||
|
||||
2. 添加文件属性
|
||||
|
||||
```bash
|
||||
sudo chattr +i offends.sh
|
||||
sudo chattr +i -V offends.sh
|
||||
```
|
||||
|
||||
3. 查看文件属性
|
||||
|
||||
```bash
|
||||
lsattr offends.sh
|
||||
```
|
||||
|
||||
> 恢复
|
||||
>
|
||||
> ```bash
|
||||
> sudo chattr -i offends.sh
|
||||
> ```
|
||||
|
||||
## 如何让目录不能删除
|
||||
|
||||
1. 创建目录
|
||||
|
||||
```bash
|
||||
mkdir offends
|
||||
```
|
||||
|
||||
2. 添加目录属性
|
||||
|
||||
```bash
|
||||
sudo chattr +i -RV offends/
|
||||
```
|
||||
|
||||
> 恢复
|
||||
>
|
||||
> ```bash
|
||||
> sudo chattr -i -RV offends/
|
||||
> ```
|
Reference in New Issue
Block a user