In this article, we will explain how to make files and directories unremovable, undeletable or immutable by system users and even by the root user in Linux. man chattr man lsattr 例えば rootでも変更・削除できないファイルを作成するには、chatt +i で'i' immutable属性を設定すればいい、ということは知ってたんだけど、気になったので他の属性も見てみた。互換性があるので、ext2, ext3, ext4でも可能。. chattr is the command in the Linux operating system that allows a user to set certain attributes of a file residing on a Linux file system. lsattr is the command that displays the attributes of a file. chattr - Linux 第 2 拡張ファイルシステム (ext2fs) 上にある ファイルの属性 (attribute) を変更する.
A file with the a attribute set can only be open in append mode for writing.
How to Make File and Directory Undeletable, Even By Root in Linux
Modern BSD-like systems , including OS X , have analogous chflags to set, but no command specifically meant to display them; specific options to the ls command are used instead. Retrieved from " https: The h attribute indicates the file is storing its blocks in units of the filesystem blocksize instead of in units of sectors.
Notify me of followup comments via e-mail. 6. Note that you need superuser privileges to set or remove this attribute, using the sudo command: A write to this file compresses data before storing them on the disk.
When a directory with the D attribute set is modified, the changes are written synchronously on the disk This is equivalent to the dirsync mount option , applied to a subset of the files.
extファイルシステムの拡張属性 - うまいぼうぶろぐ
The btrfs file system includes the attribute functionality, including C which turns off the copy-on-write built in feature of btrfs due to slower performance associated with CoW. A read from this file returns uncompressed data. Extended filesystems (Ext, Ext2, Ext3) Extended filesystem (ext fs), second extended filesystem (ext2fs) and third extended filesystem (ext3fs) were designed and implemented on Linux by Rmy Card, Laboratoire MASI--Institut Blaise Pascal,, Theodore Ts'o, Massachussets Institute of Technology.
The X attribute is used by the experimental compression patches to indicate that a raw contents of a compressed file can be accessed directly.
Support us by taking our online Linux courses We are thankful for your never ending support. To make a file mutable again, use -i sign to remove the above attribute, as follows.
It cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
How to Install Ubuntu Note that you need superuser privileges to set or remove this attribute, using the sudo command:. To make a file undeletable by any system user, including root, you need to make it unmodifiable using using the chattr command. How to Install Nagios 4.
Got something to say? This is a hint to the block allocator used by ext3 and ext4 that the subdirectories under this directory are not related, and thus should be spread apart for allocation purposes.
chattr - コマンド (プログラム) の説明 - Linux コマンド集 一覧表
The form of the chattr command is:. This allows the user to ask for its undeletion. Your email address will not be published. Unix file system-related software. The ls command will do with either the -lo , or the -lO , depending on the system, flags passed. File is hidden by default in the GUI but not in ls.
Unix command-line interface programs and shell builtins.Attribute in Linux. S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge. In this article, we will explain how to make files and directories unremovable, undeletable or immutable by system users and even by the root user in Linux.
chattr - コマンド (プログラム) の説明 - Linux コマンド集 一覧表
In particular, some Linux-native filesystems support several attributes that you can adjust with the chattr command. Thank you so much for this explanation!
The Z attribute is used by the experimental compression patches to indicate a compressed file is "dirty". When a file with the s attribute set is deleted, its blocks are zeroed and written back to the disk. The chflags command is not specific to particular file systems. This is necessary for applications such as LILO which read the filesystem directly, and which don't understand tail-merged files.
When a file with the A attribute set is accessed, its atime record is not modified. Your name can also be listed here.
It means that the file is, or at one time was, larger than 2TB. Other Unices , in general, have no analogous commands.
For directories where this attribute is not set, the Orlov block allocator will try to group subdirectories closer together where possible. Using the -R flag, you can recursively change attributes of directories and their contents as follows.
The Solaris system has no commands specifically meant to manipulate them. A file with the i attribute cannot be modified.
In this article, we showed how to make files unremovable even by the root user in Linux. When a file with the u attribute set is deleted, its contents are saved.
Cancel reply Your email address will not be published. The e attribute indicates that the file is using extents for mapping the blocks on disk.
When a file with the S attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the 'sync' mount option applied to a subset of the files. Updates to these files may not be subject to atomic snapshots, and may lack some reliability information on some filesystems and kernels.
A directory with the T attribute will be deemed to be the top of directory hierarchies for the purposes of the Orlov block allocator. Some filesystems support additional attributes (other than those described in the preceding sections).
The form of the chflags command is:. View Linux File Attributes.