Removing a file using inode number

Note: All the commands given here are tried in AIX. Respective commands (may be command options) may differ for various flavors of UNIX.

Issue:
Unable to remove a file even after having all the permissions. The command rm –R <filename> in an AIX server giving error like file does not exist and were not able to do any operation on the file.

Operations tried on the file:
root@mybox# ls –ld myfile
ls: 0653-341 The file myfile does not exist.

root@mybox# ls -ld *myfile*    #to check if there is any hidden characters in file
ls: 0653-341 The file *myfile* does not exist.

You may use ls –lq or ls –lb for showing non-printing characters

root@mybox# cd myfile
ksh: myfile:  not found.

But, ls –l showing the file name and consuming the file system space.

root@mybox# ls –l
total 272
------------------------Truncated----------------
drwxr-x---   6 root      system             512 Mar 23 2009  myfile
------------------------Truncated----------------


Solution:

1) Find i-node number of the file
root@mybox#ls –i
------------------------Truncated----------------
180227 drwxr-x---   6 root      system             512 Mar 23 2009  myfile
------------------------Truncated----------------

2) Confirm the inode
root@mybox# find . -inum 180227 -ls
180227    4 drwxr-x---  6 root      system             512 Mar 23  2009 ./myfile
        
3) Unlink respective inode with the file/directory.
root@mybox# find . -inum 180227 -exec rm {} \;


Comments

Popular posts from this blog

Jenkins Dynmaic Parameter - List All Branches in a Git Repository

JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'XYZ' with connection mode 'Client' and host name 'x.x.x.x(1415)'. Please check if the supplied username and password are correct on the QueueManager to which you are connecting.