File permissions commands
You can check and change file permissions using commands in a terminal or shell. The commands may vary depending on the operating system and the file system, but some common ones are:
- ls -l : This command lists the files and directories in the current or specified directory, along with their permissions, owner, group, size, and modification date. The permissions are displayed as a sequence of 10 characters, such as -rw-r--r-- , where the first character indicates the file type (e.g., - for regular file, d for directory, l for symbolic link), the next three characters indicate the permissions for the owner (e.g., rw- for read and write), the next three characters indicate the permissions for the group (e.g., r-- for read only), and the last three characters indicate the permissions for other users (e.g., r-- for read only).
- chmod : This command changes the permissions of files and directories. You can use either symbolic or numeric notation to specify the permissions. For example, chmod u+x file adds execute permission to the owner of the file, while chmod 755 file sets the permissions to read, write, and execute for the owner, and read and execute for the group and other users.
- chown : This command changes the owner and group of files and directories. You can use either the user name or the user ID to specify the owner, and either the group name or the group ID to specify the group. For example, chown alice file changes the owner of the file to alice, while chown alice:staff file changes the owner to alice and the group to staff.