Inode number changes for a file in Redhat Linux

Hi,

I have created a file abc.log in Redhat Linux.

Inode number for a file get changes every time i update the file using vi editor.

Is there any setting that can be made , such that inode number never gets changed?

Or if we cannot restrict from inode number getting changed , is there any way to identify the file uniquely as inode number does.

Kindly reply me.

Thanks in Advance.
Raghu A

To do that it must be editing a temp copy and replacing the original file like mv copy original

You could edit a copy, then cat copy > original to update the original without changing its inode.

I cannot reproduce this.

$
$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.1 (Tikanga)
$ echo hello > testfile
$ ls -i testfile
3180926 testfile
$ vi testfile
$ cat testfile
hello there
$ ls -i testfile
3180926 testfile
$

hi perderabo,

thanks for the reply, in my machine i can still see the inode number changing after editing with vi. are there any settings that i have to do to solve this particular problem.

vi doesn't appear to have a "do not change the inode" setting, no. You can do what I suggested. Or you can check if it's a script that's using vi or something which is doing the switcheroo.

thanks corona,

i am not using any script, i am manually using vi to put some text in to the file and then checking for the inode number.

whatever you suggested is right but, i should not restrict the user to redirect the data from another file. user can edit the file using vi as well.

What version of vi are you using? is it the standard one installed? Is it real vi, or vim or something?

I am using version 7.0.109.

A more complete response is to post something like:

$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.1 (Tikanga)
$ /bin/vi --version
VIM - Vi IMproved 7.0 (2006 May 7, compiled May  4 2007 05:54:34)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-235, 237
Compiled by <bugzilla@redhat.com>
Tiny version without GUI.  Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent
-clientserver -clipboard -cmdline_compl -cmdline_hist -cmdline_info -comments
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
-eval -ex_extra -extra_search -farsi -file_in_path -find_in_path -folding
-footer +fork() -gettext -hangul_input +iconv -insert_expand -jumplist -keymap
-langmap -libcall -linebreak -lispindent -listcmds -localmap -menu -mksession
-modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype
-path_extra -perl -printer -profile -python -quickfix -reltime -rightleft -ruby
 -scrollbind -signs -smartindent -sniff -statusline -sun_workshop -syntax
-tag_binary -tag_old_static -tag_any_white -tcl +terminfo -termresponse
-textobjects -title -toolbar -user_commands -vertsplit -virtualedit -visual
-viminfo -vreplace +wildignore -wildmenu -windows +writebackup -X11 -xfontset
-xim -xsmp -xterm_clipboard -xterm_save
   system vimrc file: "/etc/virc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
        --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
Linking: gcc   -L/usr/local/lib -o vim       -lselinux -ltermcap -lacl
$

I don't think that the real vi is available on RedHat. I assume that the same is true for other distros as well.

[root@host1 noaccess]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)
[root@host1 noaccess]#
[root@host1 noaccess]# /bin/vi --version
VIM - Vi IMproved 7.0 (2006 May 7, compiled Sep 28 2006 23:02:46)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109
Compiled by <bugzilla@redhat.com>
Tiny version without GUI. Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent
-clientserver -clipboard -cmdline_compl -cmdline_hist -cmdline_info -comments
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
-eval -ex_extra -extra_search -farsi -file_in_path -find_in_path -folding
-footer +fork() -gettext -hangul_input +iconv -insert_expand -jumplist -keymap
-langmap -libcall -linebreak -lispindent -listcmds -localmap -menu -mksession
-modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype
-path_extra -perl -printer -profile -python -quickfix -reltime -rightleft -ruby
-scrollbind -signs -smartindent -sniff -statusline -sun_workshop -syntax
-tag_binary -tag_old_static -tag_any_white -tcl +terminfo -termresponse
-textobjects -title -toolbar -user_commands -vertsplit -virtualedit -visual
-viminfo -vreplace +wildignore -wildmenu -windows +writebackup -X11 -xfontset
-xim -xsmp -xterm_clipboard -xterm_save
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
Linking: gcc -L/usr/local/lib -o vim -lselinux -ltermcap -lacl
[root@host1 noaccess]#

This is the output. Thanks for replying my previous post.