Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a file to this drwxrwsrwx permission on ubuntu [closed]

How do I set my file permissions to this drwxrwsrwx? I need it to be the same as my folders.

Thanks

like image 849
Morne Zeelie Avatar asked Feb 03 '12 14:02

Morne Zeelie


1 Answers

chmod 777 does not apply rwxrwsrwx. This implicitly means chmod 0777, would apply rwxrwxrwx, and is significantly different from rwxrwsrwx.

The permission rwxrwsrwx can be applied with:

chmod 2777 your_target

You can show the effective permission string of a file or directory with:

ls -lad your_target

A file would look like:

-rwxrwsrwx    1 user  group         0 Feb  3 13:24 foo

And a directory would look like:

drwxrwsrwx    2 user  group      4096 Feb  3 13:24 bar

The first character of the string indicates the type of object that it is. A normal file will have - and a directory will have d. There are other possibilities for other objects.

The remaining 9 characters, in order, refer to the read/write/execute permission for the user owner, the read/write/execute permission for the group owner, and then the read/write/execute permission for everyone else.

In your example, the user owner and everyone permissions are rwx, which means that the user owner and everyone have permission to read, write, and execute the object.

The group owner permissions in your example are rws, which means that the group owner has read, write, and execute process AND the object has the setguid bit set (this is the s in rws). On a file, the setgid bit means that, if the file were executed, that it would be run with the effective rights of the group owner (instead of that of the user who executed it). On a directory, the setgid bit means that, if a file is created in the directory, its group-owner would be that of the directory (instead of that of the user who created it).

You can read about Linux permissions, including what read/write/execute means on files and directories, here and here.

like image 127
Christopher Neylan Avatar answered Sep 22 '22 01:09

Christopher Neylan