I wanted to create few files which are Write Once Read Many (WORM). How do I do this? I assigned a permission level of 4000 to a file. Also I have to set retention to the files.

So I created a file. Set the permission levels to 4000 and then used the touch command to set the retention to a specific time.

touch -a -t 201303240215.10 a.txt.

When I ran the stat command I got this.

File: `a.txt'
  Size: 6               Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 19267589    Links: 1
Access: (0400/-r--------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-03-24 02:15:10.000000000 -0600
Modify: 2013-03-23 05:41:45.000000000 -0600
Change: 2013-03-24 02:00:53.000000000 -0600

Is this the way to create a WORM file?

  • 1
    Permission bits of 4000 make no sense. Did you mean 0400? If so, that's a read-only file, not a WORM file. Also, what's the "retention"? I do not believe that any such thing as "retention time" actually exists. Most importantly, what are you actually trying to do?
    – Celada
    Mar 24, 2013 at 12:07
  • touch -t does set a retention time? I always thought it only changed the access and modification timestamps. More interesting point: What is a WORM-file in your eyes? A file you create before, only one process can write into it and then it can only be read? Or is it a file that a certain process is writing continuously while others only can read it? (In the latter case you cout open it in your process for writing and immediately after this change its rights to read-only). And why do you set the suid-bit?
    – ohno
    Mar 24, 2013 at 12:11
  • Yes i meant permission of 0400. So the WORM file meaning, write once and then it can only be read later on. Also as far as the retention thing goes, in order to delete the file, the retention time should be completed. So in this case satisfying these 2 conditions how do I create these files. Here my main motive is to create these files and then back it up using a backup ISV. Then delete these and restore them. After the restore the file should still be a WORM file.
    – Srikant
    Mar 24, 2013 at 17:43
  • Also for setting a retention time to a file, I used the following command. touch -a -t 202011210600 document.txt Here the time set is in the format yyyymmddhhmm.ss Also, I want that this file cannot be deleted until the retention time set is not finished. But in my case it does. Yes if I use the chattr +i command it becomes immutable. But this does not solve my need for keeping the file in an non deletable position till the retention time does not expire.
    – Srikant
    Mar 24, 2013 at 18:06

1 Answer 1


You can set a file on the ext2 to ext4 filesystems to immutable or append-only with chattr(1), see also lsattr(1)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .