Board index COMMANDS Basic Commands

How to remove a file using inode number + linux

Postby a24uall » Sat Apr 20, 2013 12:02 pm

Below command list the files and its inode number
ls -il

Example

[email protected] [~/456]# ls -il
total 12
187957285 drwxrwxr-x 3 root root 4096 Apr 19 22:44 ./
184784128 drwx------ 15 root root 4096 Apr 19 22:44 ../
187957289 -rw-rw-r-- 1 root root 0 Apr 19 22:44 1
187957284 drwxrwxr-x 2 root root 4096 Apr 19 22:44 456.bak/
[email protected] [~/456]#


Below command is used to delete the file using inode number.
find . -inum [inode-number] -exec rm -i {} \;


Example :
Removing file named "1" with inode number 187957289
[/quote][email protected] [~/456]# find . -inum 187957289 -exec rm -i {} \;
rm: remove regular empty file `./1'? y
[email protected] [~/456]#[/quote]

File removed and you can verify that from below :
[email protected] [~/456]# ll
total 12
drwxrwxr-x 3 root root 4096 Apr 20 02:25 ./
drwx------ 15 root root 4096 Apr 19 22:44 ../
drwxrwxr-x 2 root root 4096 Apr 19 22:44 456.bak/
[email protected] [~/456]#
Arun
WebhostingDevelopment.com
a24uall
Site Admin
 
Posts: 166
Joined: Sun Jul 01, 2012 9:07 am

Return to Basic Commands

Who is online

Users browsing this forum: No registered users and 1 guest


cron