Remove directory/file using inode number in linux
-----------------------------------------------------------------
[oracle@stby oracle]$ ls -lrt
total 32
drwxrwxr-x. 3 oracle oinstall 4096 Feb 26 07:43 product
drwxrwxr-x. 11 oracle oinstall 4096 Feb 26 09:50 diag
drwxr-xr-x. 2 oracle oinstall 4096 Feb 26 09:53 checkpoints
drwxr-xr-x. 3 oracle oinstall 4096 Feb 26 10:31 cfgtoollogs
drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:01 admin
drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 fast_recovery_area
drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 oradata
drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:12 -p
[oracle@stby oracle]$
[oracle@stby oracle]$ ls -li
total 32
143126 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:01 admin
143086 drwxr-xr-x. 3 oracle oinstall 4096 Feb 26 10:31 cfgtoollogs
143085 drwxr-xr-x. 2 oracle oinstall 4096 Feb 26 09:53 checkpoints
143089 drwxrwxr-x. 11 oracle oinstall 4096 Feb 26 09:50 diag
131827 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 fast_recovery_area
140990 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 oradata
140979 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:31 -p
140980 drwxrwxr-x. 3 oracle oinstall 4096 Feb 26 07:43 product
[oracle@stby oracle]$
[oracle@stby oracle]$ find . -inum 140979 -exec rm -rf {} \;
find: `./-p': No such file or directory
[oracle@stby oracle]$ ls -li
total 28
143126 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:01 admin
143086 drwxr-xr-x. 3 oracle oinstall 4096 Feb 26 10:31 cfgtoollogs
143085 drwxr-xr-x. 2 oracle oinstall 4096 Feb 26 09:53 checkpoints
143089 drwxrwxr-x. 11 oracle oinstall 4096 Feb 26 09:50 diag
131827 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 fast_recovery_area
140990 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 oradata
140980 drwxrwxr-x. 3 oracle oinstall 4096 Feb 26 07:43 product
[oracle@stby oracle]$
find . -inum 140979 -exec rm -rf {} \;
Remove file using below command
find . -inum 140979 -exec rm -i {} \;
[oracle@stby oracle]$ ls -li
total 28
143126 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:01 admin
140979 -rw-r--r--. 1 oracle oinstall 0 Mar 2 22:37 a.txt
143086 drwxr-xr-x. 3 oracle oinstall 4096 Feb 26 10:31 cfgtoollogs
143085 drwxr-xr-x. 2 oracle oinstall 4096 Feb 26 09:53 checkpoints
143089 drwxrwxr-x. 11 oracle oinstall 4096 Feb 26 09:50 diag
131827 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 fast_recovery_area
140990 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 oradata
140980 drwxrwxr-x. 3 oracle oinstall 4096 Feb 26 07:43 product
[oracle@stby oracle]$
[oracle@stby oracle]$ find . -inum 140979 -exec rm -i {} \;
rm: remove regular empty file `./a.txt'? y
[oracle@stby oracle]$
[oracle@stby oracle]$ ls -li
total 28
143126 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:01 admin
143086 drwxr-xr-x. 3 oracle oinstall 4096 Feb 26 10:31 cfgtoollogs
143085 drwxr-xr-x. 2 oracle oinstall 4096 Feb 26 09:53 checkpoints
143089 drwxrwxr-x. 11 oracle oinstall 4096 Feb 26 09:50 diag
131827 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 fast_recovery_area
140990 drwxr-xr-x. 2 oracle oinstall 4096 Mar 2 22:02 oradata
140980 drwxrwxr-x. 3 oracle oinstall 4096 Feb 26 07:43 product
[oracle@stby oracle]$
No comments:
Post a Comment