can anyone let me know the difference between the permissions 0755 and 04755?
Who is Participating?
subratabiswasConnect With a Mentor Commented:
The difference between the above two is 4 at the beginning, which is called the 'set user or group ID on execution' bit. On being set on an executable / directory, this allows the user to assume the effect userid of the owner of the executable / directory. Following is a quick test  / example.

1) Create a c file with the following contents and compile it to a.out:

#include <stdio.h>
main() {
        FILE *outfile;
        outfile = fopen("Test", "w");
        fprintf(outfile, "Hello\n");

2) Chown the ownership of the executable file a.out to a test user

chown root:root a,out

3) Change the permission so that other people can execute it normally:

chmod 755 a.out

4) Execute the file as a user other than the owner of a.out above, and see the permissions / ownership of the newly created file "Test" in your current folder.

5) Change the permission of the file to set the special privilege bit, you may be required to be root for this:

chmod 4755 a.out

6) Remove the file "Test" created earlier from your local directory, then execute a.out to get "Test" created again. Check the permission and ownership of the file

You will observe that in the first instance, the file "Test" is created with the ownership belonging to the user executing the file a.out.
In the second instance, the ownership of the file will be to the user that owns the executable, not the user executing the file.

The SUID are set. On a directory it means the group or the owner of this directory are used if a ned file is created.

For files:
04nnn = SUID bit - program will be executed with the effective rights of the owning user, not the user starting it.
02nnn = SETGID bit - program will be executed with the effective rights of the owning group, not the group where the user starting it is in.
01nnn - SAVE-TEXT - sets the save-text attribute.

For directories:
04nnn = SUID bit - ignored for directories
02nnn = SETGID bit - new files and subdirectories created within the directory will inherit its group id, not the group id of the user creating them.
01nnn = Sticky bit - only file owners can link or unlink files in the specified directory.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.