Read-Only Files and Creation Dates

Every file on Peios can carry two special attributes besides its security descriptor: a read-only flag, and a creation date that copies can carry over. Windows programs set and check both, and Peios keeps them the same way.

The examples use a sample file named report.txt. Create it first, or substitute your own.

Make a file read-only #

Mark a file read-only:

attrib +r report.txt

No program can then open the file for writing, truncate it, replace it, or delete it, whoever runs the program, the file's owner included. Clear the flag to change the file again:

attrib -r report.txt

Run attrib with only file names to see which are read-only. The first column shows R for a read-only file and - for a writable one; the second shows the indexing preference described below:

attrib report.txt notes.md

Read-only guards against accidental change, not against other people. It grants and denies no one access, and anyone allowed to write the file's attributes can clear it. Use sd to decide who can use a file. A program that already had the file open for writing keeps that access, and you can still rename the file. A directory keeps the flag but isn't protected by it.

Delete a read-only file #

rm asks before deleting a read-only file:

rm report.txt

Answer y to delete it. rm -f deletes it without asking. In a script, where rm can't ask, it refuses and leaves the file unless you give -f, so a read-only file survives a cleanup that didn't mean to remove it. Deleting a read-only file needs the right to change its attributes as well as the right to delete it.

A file or folder can say how far a search index may record it. Keep a file's contents out of search, while its name can still be found:

attrib +i report.txt

attrib then shows I in its second column. Keep a folder and everything in it out of search entirely, names included:

attrib --indexing=none Private

A folder's preference covers everything beneath it, so files created there later are covered too. To index one subfolder normally again, give it its own preference with attrib --indexing=all Private/Shared. attrib -i removes a file's own preference, so it follows its folder's again.

The preference narrows what a search indexer records. It doesn't hide the file from listings or change who can open it. Windows sees it as the file's "not content indexed" attribute through a share. A filesystem that keeps no extended attributes, such as a USB drive formatted for another system, can't keep it, and attrib says so.

See and set a creation date #

A file has two creation dates. Its birth time is when the filesystem created it, and nobody can change it. Its Created At is the date people and copy tools mean: a copy can carry its original's date, and you can set one. Until a file has a Created At, its creation date is its birth time.

stat shows both:

stat report.txt

Birth is the birth time. Created is the creation date, marked (birth) when it is only the birth time. Attributes shows read-only for a read-only file. For one value, use stat -c %k report.txt, or %K for seconds since the Epoch.

Set a file's Created At with touch, writing the date in any form touch -d accepts:

touch --created-at='2026-03-14 09:12' report.txt

This changes only the creation date. Add -d, -t, -r, -a, or -m to change the access and modification times as well. Remove the date again, so that the creation date is the birth time:

touch --no-created-at report.txt

Copy and move files #

A plain cp makes a new file, with today's creation date and no read-only flag. cp -p and cp -a keep the original's creation date and, if it is read-only, make the copy read-only too:

cp -p report.txt report-copy.txt

To keep the creation date without the flag, use --preserve without a value, or remove the flag from the selection with --no-preserve=readonly. Moving a file keeps both.

cp won't copy over a read-only file. cp -f clears the destination's read-only flag and copies over it, as xcopy /R does on Windows:

cp -f report.txt report-copy.txt

The copy is read-only afterwards only if you also preserve the flag and the original is read-only, as with cp -pf. A filesystem that has no special attributes, such as a USB drive formatted for another system, can't keep a creation date or the flag.

Commands on this page #

CommandUse it toManual
attribShow, set, or clear the read-only flag and the indexing preferenceattrib(1)
touchSet or unset a file's Created Attouch(1)
statShow a file's creation date and attributesstat(1)
cp, mvCopy or move a file, with its creation date and flagcp(1), mv(1)
rmDelete a read-only filerm(1)

Edit this page