Main Content

UnixPermissions

Permissions of file, folder, or symbolic link in UNIX

Since R2025a

Description

Use a UnixPermissions object to view and edit the permissions of a file, folder, or symbolic link located on a UNIX® system.

Creation

Create a UnixPermissions object using the filePermissions function.

You can then view and edit individual permissions of the specified file, folder, or symbolic link by using the getPermissions and setPermissions functions, respectively.

Properties

expand all

This property is read-only.

Absolute path of the file, folder, or symbolic link, returned as a string scalar.

This property is read-only.

Type, returned as File, Folder, Symbolic Link, or None. Type is None if MATLAB® cannot resolve the path in AbsolutePath.

Readable permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that you can read the file, folder, or symbolic link.

Writable permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that you can write to the file, folder, or symbolic link.

User execute permission, specified as a numeric or logical 1 (true) or 0 (false). For a file, a value of 1 indicates that you can execute the file. For a folder, a value of 1 indicates that you can access file contents and folder metadata.

Group read permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that your group can read the file, folder, or symbolic link.

Group write permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that your group can write to the file, folder, or symbolic link.

Group execute permission, specified as a numeric or logical 1 (true) or 0 (false). For a file, a value of 1 indicates that your group can execute the file. For a folder, a value of 1 indicates that your group can access file contents and folder metadata.

Others read permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that users other than you or your group can read the file, folder, or symbolic link.

Others write permission, specified as a numeric or logical 1 (true) or 0 (false). A value of 1 indicates that users other than you or your group can write to the file, folder, or symbolic link.

Others execute permission, specified as a numeric or logical 1 (true) or 0 (false). For a file, a value of 1 indicates that users other than you or your group can execute the file. For a folder, a value of 1 indicates that users other than you or your group can access file contents and folder metadata.

Object Functions

getPermissionsGet individual permissions
setPermissionsSet individual permissions

Examples

collapse all

View the permissions of a file on a UNIX operating system.

perms = filePermissions("example.txt")
perms = 

        AbsolutePath         Type     Readable    Writable    UserExecute    GroupRead    GroupWrite    GroupExecute    OtherRead    OtherWrite    OtherExecute  
    ____________________     ____     ________    ________    ___________    _________    __________    ____________    _________    __________    ____________

    "/home/example.txt"      File       true        true         true          true          true           true          true          true           true

Version History

Introduced in R2025a