To verify file permissions in Linux, you can use the ls command with the -l option. Here’s how to do it:
-
Open the terminal.
-
Use the
ls -lcommand followed by the filename or directory name. The syntax is:ls -l filenameor for a directory:
ls -ld directoryname -
Example: To check the permissions of a file named
example.txt, you would run:ls -l example.txt -
Output Explanation: The output will look something like this:
-rw-r--r-- 1 user group 0 Oct 25 12:34 example.txt- The first column shows the file type and permissions.
- The first character indicates the file type (
-for a regular file,dfor a directory). - The next nine characters represent the permissions in three groups (owner, group, others):
- The first three characters show the owner's permissions.
- The next three show the group's permissions.
- The last three show permissions for others.
-
To check permissions for all files in a directory, simply run:
ls -l
This will display the permissions for all files and directories in the current directory.
