In Linux, the information about a file or directory is stored in its inode. I was wondering what is the data structure for information about a file or directory in Windows 7?
In both operating systems, this depends on which file system is being used.
Windows uses NTFS by default, which has "attribute lists" in its Master File Table. There is some documentation in Wikipedia, at NTFS.com and Linux NTFS.
The older FAT32 filesystem (still used often in removable drives) is much simpler, and keeps everything in a single file allocation table.
How to get the information about a file or directory in Linux and in Windows 7, in terminal and command line window?
In Linux, use the
In Windows PowerShell, use
cmd.exe, you have to use either external tools or mess with
Is the owner of a file or directory always its creator? Will it be able to change?
On Windows NT (including XP, 2003, Vista, 7, and future versions), newly created objects1 are owned by their creator, unless someone else takes ownership. (Administrators can do this by using
SeTakeOwnership privilege; non-Administrators can take ownership if the object's ACL allows it.)
On server editions of Windows NT, Administrators can assign object ownership to another user. Consumer editions (such as Windows XP or 7) only allow taking ownership to yourself.
In Windows 2000 and earlier versions, if the creator is member of the Administrators group, the objects he creates will be owned by Administrators, not the user. This changed in Windows XP, where the user will always own objects he creates.
The FAT filesystems do not support file ownership.
All Unix systems use the file's creator as its owner.
root can use
chown to change the owner.
Is there a creation timestamp for a file in Linux and in Windows 7? How to get it?
In Windows, both FAT32 and NTFS store a creation timestamp. In
dir /tc will show it.
FreeBSD's UFS2 stores the creation time as
On Linux, creation times are supported by some filesystems (ntfs, possibly ext4), but not yet by the OS itself. (The
stat command already shows birth times, if supported by the syscall of same name.)
Note: On Windows and FreeBSD, the creation time is easy to change.
1 This applies to many other types of Windows NT objects, not limited to files. Examples: named pipes, Registry keys, processes, services, desktops, devices, mutexes...