网站首页 > 技术教程 正文
方法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-07-10 Linux系统下批量克隆目录结构,在另一台Linux下创建同样的目录
- 2025-07-10 Linux目录同步(rsync使用方法)(linux两个目录同步)
- 2025-07-10 inode文件索引,你了解嘛?你的Linux基础真的扎实嘛?
- 2025-07-10 Linux文件和目录管理常用重要命令(二)
- 2025-07-10 如何在 Linux 中使用 mv 命令移动文件和目录?
- 2025-07-10 「Linux 」各目录及每个目录的详细介绍
- 2025-07-10 linux中创建和删除mkdir、rmdir、touch、rm命令
- 2025-07-10 Linux目录管理(linux目录权限详解)
- 2025-07-10 Linux 用户主目录中隐藏的文件和文件夹如何理解?
- 2025-07-10 forfiles命令,在Windows删除旧文件
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)