Tuesday, November 22, 2011

Tips 17: How to change file permissions ?

To change a file's permissions, you need to use a program called chmod. With that command you can change one or multiple file permissions. Here are a few examples:

$ chmod 755 filename
$ ls -l filename
-rwxr-xr-x 1 root users 1656 Mar 22 00:27 filename
$ chmod 700 filename
$ ls -l filename
-rwx------ 1 root users 1656 Mar 22 00:27 filename
$ chmod 664 filename
$ ls -l filename
-rw-rw-r-- 1 root users 1656 Mar 22 00:27 filename

The numbers are based on the 3 types of permissions. Read = 4, write = 2 and execute = 1. A permission of 755 means the user will have read, write and execute permissions (4 + 2 + 1 = 7), and everyone else will have read and execute permissions (4 + 1 = 5).

No comments:

Post a Comment