Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios

Files and Paths

Single-page view · as markdown

Files, Names, and Security

Peios / Using Peios / Files and Paths

File commands change names, contents, or metadata. Knowing which of those a command changes tells you whether data can be lost, and which security the result has. Every file on Peios has a security descriptor that decides who can use it, and copying, moving, and creating files treat that descriptor differently.

A name and an object are different #

A file is an object with contents, metadata, and a security descriptor. A name is an entry in a directory that refers to the object. One object can have several names, called hard links, and removing one name leaves the others. A symbolic link is a separate kind of file that stores a path, and that path can later lead to a different object, or to nothing.

Which security a file gets #

The command you use decides which security descriptor the result has:

OperationResult
Rename a file, including moving it within one filesystemThe same object, with its own security descriptor
Copy a file, including moving it to another filesystemA new object, which inherits security from its destination directory
Create a file or directoryA new object, which inherits security from its parent directory
Add a hard linkAnother name for the same object and descriptor

Moving a file into another directory doesn't apply that directory's inherited rules to it. Inheritance happens once, when an object is created, and doesn't keep existing objects in step with their parent.

cp, mv, mkdir, and the other creation commands can request specific security instead. Managing Files and Directories shows how. To see or change a file's security descriptor, use sd.

Results that need checking #

A recursive operation can fail after it has already changed part of a tree, and a command can report success while skipping files under an update policy. Check the result when every file matters.

Removing a name doesn't erase its data. Other hard links, snapshots, backups, and the storage device itself can keep copies.

What a listing shows #

A listing is for people to read. File names can contain spaces, tabs, and newlines, so don't parse ls output to find file names in a script.

The mode, user, and group fields that ls and stat print are kept for compatibility. They summarize some metadata, but they don't describe who can use a file: the security descriptor does.

Every listing, metadata query, or path check describes one moment. The file can change, be replaced, or disappear before the next command runs, so a program that must act on a particular file checks the file it opens.

Managing Files and Directories

Peios / Using Peios / Files and Paths

Use these commands to copy, move, create, link, and remove files in a terminal. Each section shows the common case and the Peios behavior that affects it. The man page for each command lists every option.

Before you start #

Use a terminal on a machine with the command-line utilities installed. To try the examples, work in an empty directory so that nothing you need is overwritten. The examples name files such as report.txt; create them first, or substitute your own.

Copy files #

Use cp to make a new file or directory tree from existing data:

cp -i report.txt report-backup.txt

-i asks before overwriting a file that already exists. To copy a directory and everything in it, use cp -R notes notes-copy. If the destination already exists as a directory, cp copies the source into it.

A copy is a new object, so it inherits security from its destination directory, and copying to another location can change who can read the data. To keep particular attributes, ask for them:

  • --preserve=timestamps keeps the access and modification times.
  • --sd-explicit carries the source's explicit access rules, and lets the destination directory add its inherited rules.
  • --sd copies the source's owner and its full access and audit lists.

Neither security option copies the security descriptor's group, so a copy is not a complete security backup. cp(1) describes every preservation option and the access each one needs.

Move and rename files #

Use mv to change a file's name or location:

mv -i draft.txt report.txt

Within one filesystem, a move is a rename: the file keeps its security descriptor, even in a directory with different inherited rules. Across filesystems, mv copies the file and then removes the source, and the copy inherits security from its destination. Requesting particular attributes also makes mv copy, even within one filesystem. See mv(1).

Create files and directories #

Create a directory, with any missing parents:

mkdir -p reports/2026/drafts

touch build.marker creates an empty file, or updates the timestamps of a file that exists without changing its contents. mkfifo creates a named pipe that passes a stream from one program to another, and mknod creates device nodes, which needs the relevant authority. mktemp -d creates a directory with a unique name and prints it, so another program can't claim the name first.

A new object inherits security from its parent directory. mkdir, touch, mkfifo, and mknod can request an owner, group, integrity label, or complete security descriptor for the object they create. mkfifo and mknod also accept a -m mode option, but it isn't how security is set on Peios. Check the result with sd show before you share the location, because choosing an owner doesn't on its own give that owner the access you meant. See mkdir(1) for the security options.

Link files #

Create a symbolic link, a file that stores a path to another file:

ln -s report.txt latest

A relative path in a symbolic link is resolved from the directory that contains the link. Without -s, ln creates a hard link: another name for the same object, sharing its contents and security. Hard links can't usually cross filesystems. link and unlink add or remove exactly one hard link, without the other choices ln and rm offer.

Remove files and directories #

Remove a file, with a confirmation prompt:

rm -i disposable.txt

Removal has no undo. rm removes a directory and its contents only when you ask for recursion. A prompt doesn't decide whether you can delete the file: the file's security descriptor does. rmdir removes only empty directories, which protects you from removing contents by mistake.

rm asks before deleting a read-only file, and needs -f to delete one in a script. See Read-Only Files and Creation Dates.

rm normally removes a file's name at once, even if a program still has the file open; that program carries on with a file that no longer has a name. To leave the name in place until the last program using the file closes it, as Windows does, use --when-closed:

rm --when-closed build.log

If a program has the file open, rm says the file will be removed when it is closed. Until then the name stays, and opening the file again fails. A directory goes when its last user closes it, if it is empty then. If a program has opened the file without allowing it to be deleted, rm reports it as in use either way.

shred overwrites a file's data before removing it, but snapshots, backups, journals, and the storage device can keep copies that it doesn't reach. When data must become unrecoverable, use a method designed for the storage, such as encryption with a key you can destroy.

Change a file's length #

truncate -s 1K size-sample.bin sets a file's length. Shrinking a file discards its end, and growing it again doesn't bring that data back. Work on a copy when you're unsure.

Check the result #

List the result and its security:

ls -l
sd show ./report-backup.txt

Check the security descriptor of anything you copied or created somewhere other people can reach. A recursive command that failed part way through can leave some files changed.

Commands on this page #

This page covers these commands:

CommandUse it toManual
cpCopy files and directory treescp(1)
mvMove or rename filesmv(1)
mkdirCreate directoriesmkdir(1)
touchCreate a file or update its timestampstouch(1)
mkfifoCreate a named pipemkfifo(1)
mknodCreate a device nodemknod(1)
mktempCreate a uniquely named file or directorymktemp(1)
lnCreate symbolic or hard linksln(1)
link, unlinkAdd or remove one hard linklink(1), unlink(1)
rmRemove files and directory treesrm(1)
rmdirRemove empty directoriesrmdir(1)
shredOverwrite a file's datashred(1)
truncateChange a file's lengthtruncate(1)

Read-Only Files and Creation Dates

Peios / Using Peios / Files and Paths

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.

Keep files out of search #

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)

Inspecting Files and Paths

Peios / Using Peios / Files and Paths

Use these commands to see what is in a directory, read a file's metadata, and work out what a path refers to. A path can be text you are building, a link's stored target, or a route to an existing file, and each needs a different command. The man page for each command lists every option.

The examples use sample file names such as report.txt. Create those files first, or substitute your own.

List a directory #

Show a directory's entries, with their metadata:

ls -l sample-directory

Names that begin with a dot are hidden. -a includes them, and -A includes them without the . and .. entries. dir and vdir use the same listing engine with fixed layouts: columns for dir, one detailed row per entry for vdir.

The ownership and permission fields in a long listing are kept for compatibility, and don't describe who can use the file. Use sd show for that. Don't parse ls output in a script: names can contain spaces and newlines, and the listing is meant for people.

To color listings, dircolors -b prints a shell setting that maps kinds of file to colors. Review the settings before adding them to your shell configuration, and keep listings readable without color.

Read a file's metadata #

Print selected properties of a file:

stat -c '%n: %s bytes' report.txt

Like ls, stat prints mode, user, and group fields for compatibility, and they don't describe access. A symbolic link has metadata of its own, so decide whether you want the link or the file it points to. A size can change before you read the file, so a program that limits how much it reads checks the file it has opened.

Without -c, stat also prints a file's creation date and its attributes. Birth is when the filesystem created the file. Created is the date a copy can carry over from its original, and is the birth time, marked (birth), if none has been set. Attributes shows read-only for a file that no one can change or delete until the flag is cleared. See Read-Only Files and Creation Dates.

Resolve a path #

Choose the command by the question you are asking:

  • What does this link store? readlink latest prints the path stored in a symbolic link. The path can be relative, and its target might not exist.
  • Where is this existing file? realpath -e reports/draft.txt follows every link and prints the absolute path. With -e, every part of the path must exist.
  • Where would this new file go? realpath reports/planned.txt allows the last part to be missing, and realpath -m allows missing parent directories too. The result is a planned path, not proof that you can create the file there.
  • Where am I? pwd -P prints the working directory with every symbolic link resolved. Your shell also has its own pwd.

A resolved path doesn't reserve a name or check access, and another program can change the file before you open it. The quiet mode of realpath hides error messages but not a failing exit status, so check the status before using the output.

Split and check path text #

basename and dirname work on the text of a path without reading the filesystem:

basename reports/draft.txt .txt
dirname reports/draft.txt

The first prints draft, the second reports. Neither checks that the file exists. pathchk reports/draft.txt checks that a proposed path meets naming limits, but success doesn't promise that creating the file will work.

Commands on this page #

This page covers these commands:

CommandUse it toManual
lsList directory entriesls(1)
dir, vdirList entries in a fixed layoutdir(1), vdir(1)
dircolorsConfigure listing colorsdircolors(1)
statRead file or filesystem metadatastat(1)
readlinkRead a symbolic link's stored pathreadlink(1)
realpathResolve a path to an absolute pathrealpath(1)
pwdPrint the working directorypwd(1)
basename, dirnameSplit a path's textbasename(1), dirname(1)
pathchkCheck a proposed path namepathchk(1)

Measuring Space and Copying Raw Data

Peios / Using Peios / Files and Paths

Use df and du to find out how much space is available and what is using it, and dd to copy an exact number of bytes. These commands measure and copy storage rather than files, so read their results with the storage model in mind.

The examples use sample file names such as source.bin. Create those files first, or substitute your own.

Check available space #

Show the space on the filesystem that holds the current directory:

df -h .

df reports space for the whole filesystem. Reserved space, metadata, snapshots, and files that are still open after removal all affect its totals, so free space isn't the size minus the files you can see.

Measure a directory tree #

Total the space used by a directory and everything in it:

du -sh measurements

du adds up the files it can reach. It can report allocated size, the storage blocks a file occupies, or apparent size, the file's logical length; the two differ for sparse and compressed files. A directory that du can't read makes its total incomplete, so check for errors.

df and du answer different questions, and a difference between them is a reason to look at what each one counts, not proof that either is wrong. For a full procedure, see Diagnosing Storage Pressure.

Copy an exact range of bytes #

Copy the first 4 bytes of a file into another file:

dd if=source.bin of=prefix.bin bs=4 count=1 status=none

if= names the input and of= names the output. dd overwrites the output without asking, so check of= before you run it, especially if it names a device: a mistake there affects a whole disk, not one file. Counts are in units of the block size bs= unless you choose byte units. dd finishing doesn't mean the data has reached the storage device; use its synchronization options or sync when that matters.

Commands on this page #

This page covers these commands:

CommandUse it toManual
dfShow filesystem capacitydf(1)
duMeasure a directory treedu(1)
ddCopy a byte stream in blocksdd(1)

Peios Learn — documentation for Peios software.

Built with Trail.