List the file permissions.
# ls -l filename |
-l |
Displays the long listing, which includes current permissions for the file. |
filename |
Is the specified file or directory. |
# chmod nnn filename |
nnn |
Are numbers representing the permissions you are assigning to the file owner, the group owner, and all others, in that order. |
filename |
Is the specified file or directory. |
Permissions are changed using the numbers you specify.
You can change permissions on groups of files or on all files in a directory using meta characters such as (*) in place of file names or in combination with them.
Verify that the permissions have been changed by using the ls -l command.
$ ls -l filename |
The long listing shows the current permissions for the file.
This example shows changing the permissions of a public directory from 744 (read/write/execute, read-only, and read-only) to 755 (read/write/execute, read/execute, and read/execute).
$ ls -ld public_dir drwxr--r-- 1 ignatz staff 6023 Aug 5 12:06 public_dir $ chmod 755 public_dir $ ls -ld public_dir drwxr-xr-x 1 ignatz staff 6023 Aug 5 12:06 public_dir |
This example show changing the permissions of an executable shell script from read/write to read/write/execute.
$ ls -l my_script -rw------- 1 ignatz staff 6023 Aug 5 12:06 my_script $ chmod 700 my_script $ ls -l my_script -rwx------ 1 ignatz staff 6023 Aug 5 12:06 my_script |