网站首页 > 精选文章 正文
方法1
删除当前路径下属主为root的所有文件和文件夹
find ./* -user root -print0 | xargs -0 rm -rf
删除当前路径下属组为root的所有文件和文件夹
find ./* -group root -print0 | xargs -0 rm -rf
为了防止删错,开始时最好分步执行命令,当确定该删时才合并执行:
# 第一步
ls -l
# 第二步:
find ./* -user root
# 第三步:
find ./* -user root -print0
# 第四步:合并命令正式执行删除操作
find ./* -user root -print0 | xargs -0 rm -rf
方法2: 不要轻易执行rm -rf删除操作,若删除就后悔莫及了
find ./* -user root -exec ls -l {} +
find ./* -user root -exec rm -rf {} +
方法3:此方法不可靠,容易删错文件
step 1:
root@tdar-srv:/home/decisionmaker/.vscode# ls -al
total 172
drwxrwxr-x 17 decisionmaker decisionmaker 4096 9月 18 21:20 .
drwxr-xr-x 29 decisionmaker decisionmaker 4096 9月 18 21:37 ..
-rw-rw-r-- 1 decisionmaker decisionmaker 984 9月 18 20:50 argv.json
drwxr-xr-x 2 root root 4096 9月 18 21:17 Backups
drwx------ 3 root root 4096 9月 18 21:17 blob_storage
drwx------ 3 root root 4096 9月 18 21:18 Cache
drwxr-xr-x 3 root root 4096 9月 18 21:17 CachedData
drwxr-xr-x 2 root root 4096 9月 18 21:17 CachedExtensions
drwx------ 4 root root 4096 9月 18 21:17 'Code Cache'
-rw------- 1 root root 20480 9月 18 21:18 Cookies
-rw------- 1 root root 0 9月 18 21:18 Cookies-journal
drwx------ 2 root root 4096 9月 18 21:17 'Crash Reports'
drwx------ 2 root root 4096 9月 18 21:17 Dictionaries
drwxrwxr-x 3 decisionmaker decisionmaker 4096 9月 18 20:50 extensions
drwx------ 2 root root 4096 9月 18 21:17 'exthost Crash Reports'
drwx------ 2 root root 4096 9月 18 21:17 GPUCache
-rw-r--r-- 1 root root 2 9月 18 21:17 languagepacks.json
drwx------ 3 root root 4096 9月 18 21:17 'Local Storage'
drwxr-xr-x 3 root root 4096 9月 18 21:17 logs
-rw-r--r-- 1 root root 36 9月 18 21:17 machineid
-rw------- 1 root root 365 9月 18 21:18 'Network Persistent State'
-rw-r--r-- 1 root root 446 9月 18 21:17 rapid_render.json
drwx------ 2 root root 4096 9月 18 21:20 'Session Storage'
-rw-r--r-- 1 root root 59724 9月 18 21:17 storage.json
-rw------- 1 root root 406 9月 18 21:18 TransportSecurity
drwxr-xr-x 4 root root 4096 9月 18 21:17 User
step 2:
root@tdar-srv:/home/decisionmaker/.vscode# ls -al | grep root
drwxr-xr-x 2 root root 4096 9月 18 21:17 Backups
drwx------ 3 root root 4096 9月 18 21:17 blob_storage
drwx------ 3 root root 4096 9月 18 21:18 Cache
drwxr-xr-x 3 root root 4096 9月 18 21:17 CachedData
drwxr-xr-x 2 root root 4096 9月 18 21:17 CachedExtensions
drwx------ 4 root root 4096 9月 18 21:17 Code Cache
-rw------- 1 root root 20480 9月 18 21:18 Cookies
-rw------- 1 root root 0 9月 18 21:18 Cookies-journal
drwx------ 2 root root 4096 9月 18 21:17 Crash Reports
drwx------ 2 root root 4096 9月 18 21:17 Dictionaries
drwx------ 2 root root 4096 9月 18 21:17 exthost Crash Reports
drwx------ 2 root root 4096 9月 18 21:17 GPUCache
-rw-r--r-- 1 root root 2 9月 18 21:17 languagepacks.json
drwx------ 3 root root 4096 9月 18 21:17 Local Storage
drwxr-xr-x 3 root root 4096 9月 18 21:17 logs
-rw-r--r-- 1 root root 36 9月 18 21:17 machineid
-rw------- 1 root root 365 9月 18 21:18 Network Persistent State
-rw-r--r-- 1 root root 446 9月 18 21:17 rapid_render.json
drwx------ 2 root root 4096 9月 18 21:20 Session Storage
-rw-r--r-- 1 root root 59724 9月 18 21:17 storage.json
-rw------- 1 root root 406 9月 18 21:18 TransportSecurity
drwxr-xr-x 4 root root 4096 9月 18 21:17 User
step 3:
root@tdar-srv:/home/decisionmaker/.vscode# ls -al | grep root | awk '{print $9}'
Backups
blob_storage
Cache
CachedData
CachedExtensions
Code
Cookies
Cookies-journal
Crash
Dictionaries
exthost
GPUCache
languagepacks.json
Local
logs
machineid
Network
rapid_render.json
Session
storage.json
TransportSecurity
User
step 4:
root@tdar-srv:/home/decisionmaker/.vscode# ls -al | grep root | awk '{print $9}' | xargs
Backups blob_storage Cache CachedData CachedExtensions Code Cookies Cookies-journal Crash Dictionaries exthost GPUCache languagepacks.json Local logs machineid Network rapid_render.json Session storage.json TransportSecurity User
step 5:
root@tdar-srv:/home/decisionmaker/.vscode# ls -al | grep root | awk '{print $9}' | xargs rm -rf
猜你喜欢
- 2025-06-10 Visual Studio Code 扩展介绍 - SVG
- 2025-06-10 VS Code 1.39 发布,Web 版 VS Code 可能不远了
- 2025-06-10 我在用的软件和服务清单(我在用的软件和服务清单怎么删除)
- 2025-06-10 vscode+cline\roo code+deepseek(vscode接入本地deepseek)
- 2025-06-10 Flutter Widget IDE 预览新进展(flutter的widget)
- 2025-06-10 Node.js 开发后台实现基本的增删改查功能
- 2025-06-10 不懂技术的产品经理,如何让 AI 码农帮敲代码?
- 2025-06-10 快速清理 .NET 项目文件夹中不需要的文件和文件夹
- 2025-06-10 Web3教程:使用 Solidity 构建 Web3 应用程序(1)
- 2025-06-10 ubuntu24.04 vscode调用 c++ opencv报错问题
- 08-06如何实现服务器架构优化?
- 08-06快速搭建一个自己的邮箱服务器
- 08-06超强 useMCP() 钩子来了,3 行代码搞定各种 MCP 服务器!
- 08-066款应该会用的办公软件
- 08-06快速搭建一个本地的FTP服务器
- 08-06Nginx 深度解析指南:一文掌握高性能 Web 服务器秘诀
- 08-06详解Web服务器安全攻击及防护机制
- 08-06163邮箱绑定foxmail邮件客户端使用指南
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)