Monday, March 17, 2025

Dot at the end of Linux file permissions - How to Remove them


In Linux, when you list files using the ls -l command, a trailing dot (.) at the end of the permission string indicates that the file has an SELinux security context associated with it. This dot signifies that SELinux attributes are present, even if SELinux is disabled on the system.


To remove this trailing dot, you need to clear the SELinux security context from the files. This can be achieved using the setfattr command, which allows you to manipulate extended attributes on filesystem objects. Here's how you can do it:

  1. Remove SELinux attribute from a single file or directory:

    bash
    sudo setfattr -h -x security.selinux /path/to/file_or_directory

    Replace /path/to/file_or_directory with the actual path of your file or directory.

  2. Remove SELinux attributes recursively from a directory and its contents:

    bash
    find /path/to/directory -exec sudo setfattr -h -x security.selinux {} \;

    This command will traverse through the specified directory and remove the SELinux security context from all files and subdirectories within it.

Caution: Modifying or removing SELinux security contexts can have security implications. Ensure that you understand the consequences and have appropriate backups before making these changes.

After performing these steps, the trailing dot should no longer appear in the file permissions when you list them using ls -l

No comments: