Yes, it is possible for a file in Linux to have permissions of ----------, meaning it has no read, write, or execute permissions for the owner, group, or others. Here’s a detailed breakdown:
How a file can have ---------- permissions
- Using
chmodto remove all permissions:
chmod 000 filename
This removes all permissions for the file.
- File Attributes:
The file might also have special attributes set withchattr, such as the immutable (i) attribute, which can prevent modifications regardless of the file’s permissions.
Can root delete it?
Yes, root can delete a file with ---------- permissions because:
- Root Bypasses File Permissions:
The root user has elevated privileges and can override standard file permission checks. Root can delete the file even if it has no permissions. - Directory Permissions Matter:
The ability to delete a file is determined by the write permissions on the parent directory where the file resides. If the parent directory allows write access (e.g.,drwxr-xr-x), root can delete the file even if the file itself has----------permissions.
Exceptions
If the file has special attributes set using chattr, such as the immutable (i) attribute, even root cannot delete it unless the attribute is first removed. To remove the immutable attribute:
- Check the attributes:
lsattr filename
Example output:
----i-------- filename
- Remove the
immutableattribute:
chattr -i filename
Once the attribute is removed, root can delete the file as usual:
rm filename